Hi,
I'm fairly new to SQLObject and I have a question about RelatedJoin: is it possible to use an alternateID as the data for the otherColumn.
I have something like the following
in the DB:
users table with columns id ( int) and username (char 8)
roles table with columns id (int) and name (char 8)
user_roles table with columns username and role_id
in the model.py:
class User(SQLObject):
class sqlmeta:
table = 'users'
username = UnicodeCol(alternateID=True, varchar=False, length=8,alternateMethodName='by_username')
class Role(SQLObject):
class sqlmeta:
table = 'roles'
name = UnicodeCol(varchar=False, length=8)
users = RelatedJoin('User', intermediateTable='user_roles',
joinColumn='role_id', otherColumn='username')
but this isn't working because when I try to get role.users it attempts to find users whose ID is their username.
Is there a way for this to work using the user's alternateID username in the join table?
Thanks in advance,
Slaalo
|