Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2055 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

[PATCH] jsonify doesn't undestands sqlalchemy.engine.base.RowProxy

Reported by: jorge.vargas Owned by: jorge.vargas
Priority: normal Milestone: 2.0
Component: TurboJson Version: 1.9.x
Severity: normal Keywords:


I'm writing a jsonrpc method using SQLAlchemy's sql layer and jsonify fails.

Using this sample code.

    def values(self):
        field = <<some valid field object>>
        s = select([field]).distinct()
        conn = DBSession.connection()
        results = conn.execute(s).fetchall()
        print results,type(results),type(results[0])
        return dict(results=results)

the print outputs

[(u'123324',), (u'122245',), (u'123323',), (u'123322',)] <type 'list'> <class 'sqlalchemy.engine.base.RowProxy'>

while the server throws this traceback:  http://paste.chrisarndt.de/paste/0f8abe7de1304d75bb8952628d29e6fe


jsonify_resultProxy.patch Download (1.8 KB) - added by jorge.vargas 11 years ago.
a patch to fix this only one test faling

Change History

Changed 11 years ago by jorge.vargas

a patch to fix this only one test faling

comment:1 Changed 11 years ago by jorge.vargas

  • Status changed from new to assigned
  • Owner changed from chrisz to jorge.vargas
  • Summary changed from jsonify doesn't undestands sqlalchemy.engine.base.RowProxy to [PATCH] jsonify doesn't undestands sqlalchemy.engine.base.RowProxy

Ok I sat down with this and wrote a little patch for it. It has two problems

1- I'm not sure of a list of lists is the best implementation here, maybe we should do a list of dicts key=column value=field 2- the test for lists is failing and I'm not sure why.

comment:2 Changed 11 years ago by chrisz

Already commited in r5835. The test failed only because of a typo. I'll think about #1 before closing this.

comment:3 Changed 11 years ago by chrisz

Sorry, didn't notice that you just forced the test to pass. The problem here is that the select doesn't get you instances of the mapped class (Test3), so the explicit jsonification in Test3 doesn't pitch in. So we really don't expect this test to pass and I just removed it.

Concerning your point #1, I agree that it should be a list of dicts and changed it accordingly. Committed these changes in r5836.

comment:4 Changed 11 years ago by jorge.vargas

Oh yes sorry I notice that test was not needed but I left it in just for completion, but your right it should be removed as it's not applicable.

Many thanks for the quick response, now to upgrade my system to trunk :)

Should I close the ticket now?

comment:5 Changed 11 years ago by chrisz

  • Status changed from assigned to closed
  • Resolution set to fixed

Ok, we are closing this. If you still find any problems please reopen.

Note: See TracTickets for help on using tickets.