test moved to another file, cosmetical fixes
This commit is contained in:
parent
dfa8eaf24e
commit
aab0599280
@ -41,10 +41,10 @@ syntax::
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
(version **0.9.0+**) if your field name is like mongodb operator name (for example
|
(version **0.9.1+**) if your field name is like mongodb operator name (for example
|
||||||
type, lte, lt...) and you want to place it at the end of lookup keyword
|
type, lte, lt...) and you want to place it at the end of lookup keyword
|
||||||
mongoengine automatically prepend $ to it. To avoid this use __ at the end of
|
mongoengine automatically prepend $ to it. To avoid this use __ at the end of
|
||||||
your lookup keyword. For example if you field name is ``type`` and you want to
|
your lookup keyword. For example if your field name is ``type`` and you want to
|
||||||
query by this field you must use ``.objects(user__type__="admin")`` instead of
|
query by this field you must use ``.objects(user__type__="admin")`` instead of
|
||||||
``.objects(user__type="admin")``
|
``.objects(user__type="admin")``
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ def query(_doc_cls=None, _field_operation=False, **query):
|
|||||||
op = parts.pop()
|
op = parts.pop()
|
||||||
|
|
||||||
#if user escape field name by __
|
#if user escape field name by __
|
||||||
if len(parts) > 1 and parts[-1]=="":
|
if len(parts) > 1 and parts[-1] == "":
|
||||||
parts.pop()
|
parts.pop()
|
||||||
|
|
||||||
negate = False
|
negate = False
|
||||||
|
@ -4592,21 +4592,6 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
self.assertEquals(Animal.objects(folded_ears=True).count(), 1)
|
self.assertEquals(Animal.objects(folded_ears=True).count(), 1)
|
||||||
self.assertEquals(Animal.objects(whiskers_length=5.1).count(), 1)
|
self.assertEquals(Animal.objects(whiskers_length=5.1).count(), 1)
|
||||||
|
|
||||||
def test_last_field_name_like_operator(self):
|
|
||||||
class EmbeddedItem(EmbeddedDocument):
|
|
||||||
type = StringField()
|
|
||||||
name = StringField()
|
|
||||||
|
|
||||||
class Doc(Document):
|
|
||||||
item = EmbeddedDocumentField(EmbeddedItem)
|
|
||||||
|
|
||||||
Doc.drop_collection()
|
|
||||||
|
|
||||||
doc = Doc(item=EmbeddedItem(type="axe", name="Heroic axe"))
|
|
||||||
doc.save()
|
|
||||||
|
|
||||||
self.assertEqual(1, Doc.objects(item__type__="axe").count())
|
|
||||||
self.assertEqual(1, Doc.objects(item__name__="Heroic axe").count())
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -208,6 +208,22 @@ class TransformTest(unittest.TestCase):
|
|||||||
self.assertEqual(Doc.objects(df__type=2).count(), 1) # str
|
self.assertEqual(Doc.objects(df__type=2).count(), 1) # str
|
||||||
self.assertEqual(Doc.objects(df__type=16).count(), 1) # int
|
self.assertEqual(Doc.objects(df__type=16).count(), 1) # int
|
||||||
|
|
||||||
|
def test_last_field_name_like_operator(self):
|
||||||
|
class EmbeddedItem(EmbeddedDocument):
|
||||||
|
type = StringField()
|
||||||
|
name = StringField()
|
||||||
|
|
||||||
|
class Doc(Document):
|
||||||
|
item = EmbeddedDocumentField(EmbeddedItem)
|
||||||
|
|
||||||
|
Doc.drop_collection()
|
||||||
|
|
||||||
|
doc = Doc(item=EmbeddedItem(type="axe", name="Heroic axe"))
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
self.assertEqual(1, Doc.objects(item__type__="axe").count())
|
||||||
|
self.assertEqual(1, Doc.objects(item__name__="Heroic axe").count())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user