[SQLObject] Re: Strange bug with SQLObject 0.6
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Carlos R. <car...@gm...> - 2004-10-18 12:07:58
|
Hello all,
I just update my sqlobject installation, but I'm still having problems
with MultipleJoins. This time the problem seems to be a little easier
to diagnose, given the result of my test session:
>>> execfile('test_sqlobj.py')
>>> new_db()
>>> u = dbUser.get(1)
>>> u
<dbUser 1 user_address1='' user_password='' user_address2=''
user_city='' user_name='Carlos Ribeiro' user_nickname='cribeiro'
user_comments=''>
>>> u.workitems
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "<string>", line 1, in <lambda>
File "C:\Python23\Lib\site-packages\sqlobject\joins.py", line 127,
in performJoin
inst.id)
File "C:\Python23\Lib\site-packages\sqlobject\dbconnection.py", line
408, in _SO_selectJoin
return self.queryAll("SELECT %s FROM %s WHERE %s = %s" %
File "C:\Python23\Lib\site-packages\sqlobject\dbconnection.py", line
217, in queryAll
return self._runWithConnection(self._queryAll, s)
File "C:\Python23\Lib\site-packages\sqlobject\dbconnection.py", line
125, in _runWithConnection
val = meth(conn, *args)
File "C:\Python23\Lib\site-packages\sqlobject\dbconnection.py", line
210, in _queryAll
self._executeRetry(conn, c, s)
File "C:\Python23\Lib\site-packages\sqlobject\dbconnection.py", line
196, in _executeRetry
return cursor.execute(query)
File "C:\Python23\Lib\site-packages\sqlite\main.py", line 244, in execute
self.rs = self.con.db.execute(SQL)
DatabaseError: no such column: db_user_id
It seems that the sqlobject code that 'mangles' the column names is
trying to convert the 'uppercase-ID' convention that is used for
automatic primary keys to the 'underscore' convention. I'm not yet
familiar with sqlobject internals, though -- I'll attempt to fix it
myself, but no promises :-)
(btw, it seems that the problem was triggered by my own naming
convention. I'll just rename all entities and see what happens)
The script that defines the database is as follows:
---------------
from sqlobject import connectionForURI, SQLObject, StringCol, IntCol, \
FloatCol, ForeignKey, MultipleJoin
db = connectionForURI('sqlite:/work/test.db')
class dbWorkItem(SQLObject):
_connection = db
wi_name = StringCol(length = 60, notNone = True)
wi_description = StringCol(length = 200, notNone = True, default = '')
wi_form_class = StringCol(length = 40, notNone = True)
wi_form_id = IntCol(default=0)
owner = ForeignKey('dbUser')
workflow = ForeignKey('dbWorkFlow')
class dbUser(SQLObject):
_connection = db
user_nickname = StringCol(length = 15, notNone = True, alternateID = True)
user_password = StringCol(length = 15, notNone = True, default = '')
user_name = StringCol(length = 40, notNone = True, default = '')
user_address1 = StringCol(length = 40, notNone = False, default = '')
user_address2 = StringCol(length = 40, notNone = False, default = '')
user_city = StringCol(length = 40, notNone = False, default = '')
user_comments = StringCol(length = 400, notNone = False, default = '')
workitems = MultipleJoin('dbWorkItem')
def new_db():
dbUser.createTable()
dbWorkItem.createTable()
dbUser(user_nickname="cribeiro", user_name="Carlos Ribeiro")
dbWorkItem(wi_name='task1', wi_description='Task 1',
wi_form_class='', workflow=None, owner=1)
dbWorkItem(wi_name='task2', wi_description='Task 2',
wi_form_class='', workflow=None, owner=1)
--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: car...@gm...
mail: car...@ya...
|