Created
April 10, 2013 08:16
-
-
Save dittos/5352785 to your computer and use it in GitHub Desktop.
Prefix matching for elements in Postgres array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
area_filter = sql.text( | |
"EXISTS (" | |
"SELECT a FROM unnest(model.areas) AS a " | |
"WHERE a LIKE :prefix || '%'" | |
")", bindparams=[sql.bindparam('prefix', area_prefix)]) | |
session.query(Model).filter(area_filter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment