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
Hi! I'm building a long query by &-ing multiple smaller ones. It looks like when multiple __in queries on one field are combined with &, the resulting query combines all __in parameters into a single list, which produces incorrect results.
For example, running SomeModel.objects.filter(Q(some_id__in=[1]) & Q(some_id__in=[2])) should return nothing (and works correctly in upstream Django with an SQL database), but returns two objects with some_id's 1 and 2 in Django-Nonrel with MongoDB on the backend.
The SQL query is correct here: SELECT some_id, some_other_columns FROM some_table WHERE (some_table.some_id IN (1) AND some_table.some_id IN (2)).
The Mongo query, however, is (as logged by Mongo itself): "query" : {"find" : "some_collection", "filter" : {"some_id" : {"$in" : [1, 2]}}, "ntoreturn" : 21}.
Hi! I'm building a long query by
&
-ing multiple smaller ones. It looks like when multiple__in
queries on one field are combined with&
, the resulting query combines all__in
parameters into a single list, which produces incorrect results.For example, running
SomeModel.objects.filter(Q(some_id__in=[1]) & Q(some_id__in=[2]))
should return nothing (and works correctly in upstream Django with an SQL database), but returns two objects withsome_id
's1
and2
in Django-Nonrel with MongoDB on the backend.The SQL query is correct here:
SELECT some_id, some_other_columns FROM some_table WHERE (some_table.some_id IN (1) AND some_table.some_id IN (2))
.The Mongo query, however, is (as logged by Mongo itself):
"query" : {"find" : "some_collection", "filter" : {"some_id" : {"$in" : [1, 2]}}, "ntoreturn" : 21}
.Using Python 2.7.12, MongoDB 3.2.7, pip freeze:
Django==1.6.11
django-mongodb-engine==0.6.0
djangotoolbox==1.8.0
pymongo==2.8
The text was updated successfully, but these errors were encountered: