Hi, After a query has been constructed with some filter conditions applied, but before the query has been run, what's the best way to replace the attribute in the filter clause?
Let's say I have a query like this q = session.query(Cube).join(Version).filter(Version.version == 'v1_5_1') and I can print the filters with and without the values bound print q.whereclause version.version = :version_1 q.whereclause.compile(compile_kwargs={'literal_binds':True}) version.version = 'v1_5_1' What's the best way to replace the attribute with a new parameter, like version = 'v1_3_3'? For a single condition, the type of whereclause is a BinaryExpression, and I figured out that left, operator, and right, get me the left-hand, right-hand side of the clause and the operator. And I can modify the value with q.whereclause.right.value='v1_3_3' print q.whereclause.compile(compile_kwargs={'literal_binds':True}) version.version = 'v1_3_3' Is this the best way? My bigger problem is I have a list of clauses in my query t = session.query(Cube).join(Version,Sample).filter(Version.version == 'v1_5_1', Sample.x < 10) now the t.whereclause is a BooleanClauseList and I can't figure out how to iterate over this list, such that I can do the above, and modify the version value in place. What's the best way to do this? I can't find the proper location in the documentation that describes a BooleanClauseList. Searching for it returns 0 results. Thanks. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.