Skip to content
Browse files

[soc2010/query-refactor] Implemented __gt.

  • Loading branch information...
1 parent 530434f commit 33523c9f95d47dec1a06ef2515af269e91be19b5 @alex alex committed
Showing with 33 additions and 0 deletions.
  1. +1 −0 django/contrib/mongodb/compiler.py
  2. +32 −0 tests/regressiontests/mongodb/tests.py
View
1 django/contrib/mongodb/compiler.py
@@ -9,6 +9,7 @@ class SQLCompiler(object):
"exact": lambda params, value_annotation, negated: 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,
+ "gt": lambda params, value_annotation, negated: {"$gt": params[0]},
}
def __init__(self, query, connection, using):
View
32 tests/regressiontests/mongodb/tests.py
@@ -224,3 +224,35 @@ def test_isnull(self):
],
lambda g: g.name
)
+
+ def test_gt(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__gt=1970), [
+ "Queen",
+ "The E Street Band",
+ ],
+ lambda g: g.name
+ )
+
+ self.assertQuerysetEqual(
+ Group.objects.filter(year_formed__gt=1971), [
+ "The E Street Band",
+ ],
+ lambda g: g.name
+ )
+
+ self.assertQuerysetEqual(
+ Group.objects.filter(year_formed__gt=1972),
+ [],
+ lambda g: g.name
+ )
+
+ self.assertQuerysetEqual(
+ Group.objects.exclude(year_formed__gt=1971), [
+ "Queen",
+ ],
+ lambda g: g.name,
+ )

0 comments on commit 33523c9

Please sign in to comment.
Something went wrong with that request. Please try again.