This is probably a feature not a bug. It might be how
SQLObject does some of its magic. If I do the following:
class Person (SQLObject) :
dbName = StringCol()
dbAddresses = MultipleJoin('Address')
class Address (SQLObject) :
dbStreet = StringCol()
person = ForeignKey('Person')
# Assume tables are created.
p = Person(dbName='me')
a = Address(dbStreet='street',person=p)
This works as expected. However, if I change 'person'
in the Address class to 'dbPerson' I get a traceback
ending with: DatabaseError: no such column: person_id.
This traceback occurs at line p = Person(dbName='me').
It appears that the column name in Addresses,
ForeignKey'ed to Person must match the class name. In
addition, you cannot overwrite the column name using
dbPerson = ForeignKey('Person', dbName='person').
Am I correct that the column name must match the
reference class to use ForeignKey?
Log in to post a comment.