[SQLObject] Bug on SQLBuilder when using strings in the query
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Carlos R. <car...@gm...> - 2004-12-14 00:59:28
|
Hello all, I'm trying to use a fairly complex query with SQLObject, and was having a problem with a "AssertionError: Database None unknown" error message. I've traced it down to this: class Catalog(SQLObject): item_code = StrCol(length=15, notNone=True, alternateID=True) item_descr = StrCol(length=40, default='') print Catalog.q.item_code == 1 # works! print Catalog.q.item_code == '001' # does not work! cribeiro@fiona:~/work/c-l-py $ python test-select-sql-object.py (catalog.item_code = 1) Traceback (most recent call last): File "test-select-sql-object.py", line 15, in ? print Catalog.q.item_code == '001' File "/usr/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 157, in __str__ return self.__sqlrepr__(None) File "/usr/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 222, in __sqlrepr__ return "(%s %s %s)" % (sqlrepr(self.expr1, db), self.op, sqlrepr(self.expr2, db)) File "/usr/lib/python2.3/site-packages/sqlobject/converters.py", line 187, in sqlrepr return converter(obj, db) File "/usr/lib/python2.3/site-packages/sqlobject/converters.py", line 98, in StringLikeConverter assert 0, "Database %s unknown" % db AssertionError: Database None unknown That's a strange bug, because it's failing for a really simple query (almost identical to the one in the tutorial for SQLObject). I'm using the latest SVN code. It does not matter if StrCol is a UnicodeCol or StringCol. It's strange because it works for ints, but doesn't work when the argument is a string. I'm trying to trace it down, but that's the first time I'm trying to understand SQLBuilder internals, so I thought that it would be good to report it. -- Carlos Ribeiro Consultoria em Projetos blog: http://rascunhosrotos.blogspot.com blog: http://pythonnotes.blogspot.com mail: car...@gm... mail: car...@ya... |