You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm having trouble forming a django ORM query for a query. In plain english, the query sounds like: "select a row where data[my_key] contains the string I'm looking for."
I'd like to make use the Django ORM that makes a query equivalent to the following SQL:
SELECT *
FROM hstore_test_testhstore
WHERE data->'french' LIKE 'fr%';
I can't seem to find a way to do that within the ORM. TestHstore.objects.filter(data__contains={'en_us': "english"}) works for exact matches of the value in the key/value pair, but fails to return a database row when the value doesn't match completely (TestHstore.objects.filter(data__contains={'en_us': "eng"}))
Any Suggestions?
Thanks for this cool package--really great work!
The text was updated successfully, but these errors were encountered:
nemesifier
changed the title
ORM Equivalent of SQL
Contains lookup doesn't seem to support LIKE 'value%' SQL [was ORM Equivalent of SQL]
Oct 15, 2014
A little more succinctly what I'd like to do is: do a filter operation on the value of a specific key.
The following query is incorrect syntactically, but conveys the type of query I'd like to make: SomeHstoreModel.objects.filter(hstore_attribute['specific_key']__contains="string I am looking for")
Hello, I'm having trouble forming a django ORM query for a query. In plain english, the query sounds like: "select a row where data[my_key] contains the string I'm looking for."
Concretely, consider the following model:
The following model instance:
I'd like to make use the Django ORM that makes a query equivalent to the following SQL:
I can't seem to find a way to do that within the ORM.
TestHstore.objects.filter(data__contains={'en_us': "english"})
works for exact matches of the value in the key/value pair, but fails to return a database row when the value doesn't match completely (TestHstore.objects.filter(data__contains={'en_us': "eng"})
)Any Suggestions?
Thanks for this cool package--really great work!
The text was updated successfully, but these errors were encountered: