On Wed 23 Jul 2008 04:01:19 PM EDT, Oleg Broytmann wrote:
>    In what way? For .byName() to work Department.name must be an
> alternateID column (which implies uniqueness).
>    This works for me:
>
> class Department(SQLObject):
>    name = StringCol(default=None, alternateID=True)
>
> Department.createTable()
>
> Department(name='Directorat')
> Department(name='Sales')
>
> class Employee(SQLObject):
>    name = StringCol(default=None)
>    department = ForeignKey('Department', default=Department.byName('Sales'))
>
> Employee.createTable()
> Employee(name='slave')

It fails in the instance where I'm importing a model with an empty
database. So for example, my unit tests use a sqlite :memory: database,
and this won't work.

The byName lookup raises an SQLObjectNotFound exception.

Sorry, I should have been more clear.

Matt


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to