It's missing something, presumably you want to return the traversed FKs (or their .q expression) in addition to the classes found in the search (building the expressions as X.id == Y.id will not get the results intended, you want X.fkToYID == Y.id). I'd probably let .q handle more of the work in BuildJoinExpression too, so for instance:
(in BFS:) pfkeys = fkeys + [(cls, col)] (in BJE:) exprs = [] prevTable = baseTable for (table, col) in tables: # col in prevTable references table left = getattr(prevTable.q, col.name) rght = table.q.id exprs.append(left == rght) prevTable = table return AND(*exprs) --- Using .q notation for traversing Joins and FKs is in trunk, so the non-automated way to address your problem is much simpler now: Foo.select(AND(Foo.q.bar, Bar.q.blah), orderBy=Blah.q.sortme) or equivalently if you define the matching SQL*Joins: Foo.select(AND(Bar.q.foos, Blah.q.bars), orderBy=Blah.q.sortme) Oleg poked me again about documentation, so I'm getting on it. Can't come up with a straightforward cyclical example that breaks BFS using only FKs, if this were extended to other joins you'd also presumably be more pressed to deal with hinting for disambiguation of multiple paths. Nice work, - Luke ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss