Skip to content

Commit 33523c9

Browse files
committed
[soc2010/query-refactor] Implemented __gt.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13381 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 530434f commit 33523c9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

django/contrib/mongodb/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class SQLCompiler(object):
99
"exact": lambda params, value_annotation, negated: params[0],
1010
"lt": lambda params, value_annotation, negated: {"$lt": params[0]},
1111
"isnull": lambda params, value_annotation, negated: {"$ne": None} if value_annotation == negated else None,
12+
"gt": lambda params, value_annotation, negated: {"$gt": params[0]},
1213
}
1314

1415
def __init__(self, query, connection, using):

tests/regressiontests/mongodb/tests.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,35 @@ def test_isnull(self):
224224
],
225225
lambda g: g.name
226226
)
227+
228+
def test_gt(self):
229+
q = Group.objects.create(name="Queen", year_formed=1971)
230+
e = Group.objects.create(name="The E Street Band", year_formed=1972)
231+
232+
self.assertQuerysetEqual(
233+
Group.objects.filter(year_formed__gt=1970), [
234+
"Queen",
235+
"The E Street Band",
236+
],
237+
lambda g: g.name
238+
)
239+
240+
self.assertQuerysetEqual(
241+
Group.objects.filter(year_formed__gt=1971), [
242+
"The E Street Band",
243+
],
244+
lambda g: g.name
245+
)
246+
247+
self.assertQuerysetEqual(
248+
Group.objects.filter(year_formed__gt=1972),
249+
[],
250+
lambda g: g.name
251+
)
252+
253+
self.assertQuerysetEqual(
254+
Group.objects.exclude(year_formed__gt=1971), [
255+
"Queen",
256+
],
257+
lambda g: g.name,
258+
)

0 commit comments

Comments
 (0)