On Mar 18, 2010, at 8:28 PM, ellonweb wrote: > Hi, > I have a query object to which I'm performing the following join and > filter: > Q = Q.outerjoin(Table.history_loader) > Q = Q.filter(TableHistory.tick == 123) > Table.history_loader is a dynamic loader that maps the two tables > based on their id property. > > This produces the following SQL: > LEFT OUTER JOIN table_history ON table.id = table_history.id WHERE > table_history.tick = 123 > > What I actually want is something like this: > LEFT OUTER JOIN table_history ON table.id = table_history.id AND > table_history.tick = 123 > > What should I do to get this query generated? I've tried the > following: > Q = Q.outerjoin((Table.history_loader, TableHistory.tick == > 123)) > Q = Q.outerjoin((Table.history_loader, and_(TableHistory, > TableHistory.tick == 123)))
the tuple form accepts the target, then the onclause. Table.history_loader is an onclause in itself you want query(Table).join((TableHistory, and_(TableHistory.tick==123, TableHistory.id==Table.id)). > Q = Q.outerjoin((Table.history_loader, and_(TableHistory.id == > Table.id, TableHistory.tick == 123))) > All 3 of these generate the following error: > AttributeError: 'BooleanClauseList' object has no attribute > 'is_derived_from' > > What should I be doing? > Thanks in advance > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.