On Wed, May 02, 2007 at 12:01:07PM -0300, Claudio Martinez wrote: > class Person(SQLObject): > name = StringCol(length=20) > > > class A(SQLObject): > code = StringCol(length=20) > sender = ForeignKey('Person', notNone=False) > target = ForeignKey('Person', notNone=False) > > > def search(search_string): > Sender = Alias(Person, 'sender_person') > Target = Alias(Person, 'target_person') > > s = A.select(OR(A.q.code.startswith(search_string), > Sender.q.name.startswith(search_string), > Target.q.name.startswith(search_string)), > join=[LEFTJOINOn(None, Sender, Sender.q.id == A.q.senderID > ), > LEFTJOINOn(None, Target, Target.q.id == A.q.targetID > )]) > > return s > > When I try to do, for example: search('a')[0] I get this error: > OperationalError: ambiguous column name: target_person.id > > When I print the select statement I can see that the Alias tables are > getting inner and left joined, instead of just being left joined.
That's because you have used the tables (aliases) both in "where" clause and in join. Tables from "where" (from OR() in this example) are used in FROM clause in the generated SQL. Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss