solution for #949
This commit is contained in:
parent
c642eee0d2
commit
63d55cb797
@ -44,6 +44,9 @@ def query(_doc_cls=None, _field_operation=False, **query):
|
|||||||
if len(parts) > 1 and parts[-1] in MATCH_OPERATORS:
|
if len(parts) > 1 and parts[-1] in MATCH_OPERATORS:
|
||||||
op = parts.pop()
|
op = parts.pop()
|
||||||
|
|
||||||
|
if len(parts) > 1 and not parts[-1]:
|
||||||
|
parts.pop()
|
||||||
|
|
||||||
negate = False
|
negate = False
|
||||||
if len(parts) > 1 and parts[-1] == 'not':
|
if len(parts) > 1 and parts[-1] == 'not':
|
||||||
parts.pop()
|
parts.pop()
|
||||||
|
@ -4592,6 +4592,19 @@ 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()
|
||||||
|
|
||||||
|
class Doc(Document):
|
||||||
|
item = EmbeddedDocumentField(EmbeddedItem)
|
||||||
|
|
||||||
|
Doc.drop_collection()
|
||||||
|
|
||||||
|
doc = Doc(item=EmbeddedItem(type="axe"))
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
self.assertEqual(1, Doc.objects(item__type__="axe").count())
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user