mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
[soc2010/query-refactor] Implemented __in.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13384 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9a895a6378
commit
3efa619541
@ -10,6 +10,7 @@ class SQLCompiler(object):
|
|||||||
"lt": lambda params, value_annotation, negated: {"$lt": params[0]},
|
"lt": lambda params, value_annotation, negated: {"$lt": params[0]},
|
||||||
"isnull": lambda params, value_annotation, negated: {"$ne": None} if value_annotation == negated else None,
|
"isnull": lambda params, value_annotation, negated: {"$ne": None} if value_annotation == negated else None,
|
||||||
"gt": lambda params, value_annotation, negated: {"$gt": params[0]},
|
"gt": lambda params, value_annotation, negated: {"$gt": params[0]},
|
||||||
|
"in": lambda params, value_annotation, negated: {"$in": params},
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, query, connection, using):
|
def __init__(self, query, connection, using):
|
||||||
|
@ -258,3 +258,29 @@ class MongoTestCase(TestCase):
|
|||||||
],
|
],
|
||||||
lambda g: g.name,
|
lambda g: g.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_in(self):
|
||||||
|
q = Group.objects.create(name="Queen", year_formed=1971)
|
||||||
|
e = Group.objects.create(name="The E Street Band", year_formed=1972)
|
||||||
|
|
||||||
|
self.assertQuerysetEqual(
|
||||||
|
Group.objects.filter(year_formed__in=[1972]), [
|
||||||
|
"The E Street Band",
|
||||||
|
],
|
||||||
|
lambda g: g.name,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertQuerysetEqual(
|
||||||
|
Group.objects.filter(year_formed__in=[1972, 1971]), [
|
||||||
|
"Queen",
|
||||||
|
"The E Street Band",
|
||||||
|
],
|
||||||
|
lambda g: g.name
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertQuerysetEqual(
|
||||||
|
Group.objects.exclude(year_formed__in=[1972]), [
|
||||||
|
"Queen",
|
||||||
|
],
|
||||||
|
lambda g: g.name,
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user