I have a fairly complex SQL query which looks like this: sql.or_( sql.and_(model.SurveyTreeItem.type=="module", model.SurveyTreeItem.skip_children==False, sql.exists().correlate(model.Risk.__table__).where(sql.and_( model.Risk.session_id==model.SurveyTreeItem.session_id, model.Risk.type=="risk", model.Risk.inventory=="no", model.Risk.depth>model.SurveyTreeItem.depth, model.Risk.path.like(model.SurveyTreeItem.path+"%")))), sql.and_(model.Risk.id==model.SurveyTreeItem.id, model.Risk.type=="risk", model.Risk.inventory=="no"))
When printing the resulting clause list I get this: tree.type = :type_1 AND tree.skip_children = :skip_children_1 AND (EXISTS (SELECT * FROM tree WHERE tree.session_id = tree.session_id AND tree.type = :type_2 AND risk.inventory = :inventory_1 AND tree.depth > tree.depth AND tree.path LIKE tree.path || :path_1)) OR tree.id = tree.id AND tree.type = :type_3 AND risk.inventory = :inventory_2 From what I can see this is not correct: there should be parenthesis to make sure the ANDs and ORs are grouped correctly. Does this look like a bug, or am I missing something? Wichert. -- Wichert Akkerman <wich...@wiggy.net> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---