Skip to content

Instantly share code, notes, and snippets.

@nickretallack
Created January 24, 2015 02:08
Show Gist options
  • Save nickretallack/e7288159f115f4c386be to your computer and use it in GitHub Desktop.
Save nickretallack/e7288159f115f4c386be to your computer and use it in GitHub Desktop.
Unfortunately, value1 gets clobbered by value2 because they both bind to value. Is there a general purpose solution to this? My real query is much more complex and dynamically constructed than this and can't be simplified by any tricks. What I want is unique parameter names that never clobber each other.
db.session.query(MyTable).filter(
db.or_(
db.text("(my_table.json_field ->> key)::text = :value").bindparams(value=value1),
db.text("(my_table.json_field ->> key)::text = :value").bindparams(value=value2),
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment