Allow fields to be named the same as query operators (#445)

This commit is contained in:
Ross Lawley 2013-08-20 13:13:17 +00:00
parent 8a3171308a
commit a707598042
3 changed files with 21 additions and 2 deletions

View File

@ -175,4 +175,5 @@ that much better:
* Paul Uithol (https://github.com/PaulUithol) * Paul Uithol (https://github.com/PaulUithol)
* Thom Knowles (https://github.com/fleat) * Thom Knowles (https://github.com/fleat)
* Paul (https://github.com/squamous) * Paul (https://github.com/squamous)
* Olivier Cortès (https://github.com/Karmak23) * Olivier Cortès (https://github.com/Karmak23)
* crazyzubr (https://github.com/crazyzubr)

View File

@ -4,7 +4,8 @@ Changelog
Changes in 0.8.4 Changes in 0.8.4
================ ================
- Fixed can now exclude subclass fields (#443) - Allow fields to be named the same as query operators (#445)
- Updated field filter logic - can now exclude subclass fields (#443)
- Fixed dereference issue with embedded listfield referencefields (#439) - Fixed dereference issue with embedded listfield referencefields (#439)
- Fixed slice when using inheritance causing fields to be excluded (#437) - Fixed slice when using inheritance causing fields to be excluded (#437)
- Fixed ._get_db() attribute after a Document.switch_db() (#441) - Fixed ._get_db() attribute after a Document.switch_db() (#441)

View File

@ -3691,6 +3691,23 @@ class QuerySetTest(unittest.TestCase):
'_cls': 'Animal.Cat' '_cls': 'Animal.Cat'
}) })
def test_can_have_field_same_name_as_query_operator(self):
class Size(Document):
name = StringField()
class Example(Document):
size = ReferenceField(Size)
Size.drop_collection()
Example.drop_collection()
instance_size = Size(name="Large").save()
Example(size=instance_size).save()
self.assertEqual(Example.objects(size=instance_size).count(), 1)
self.assertEqual(Example.objects(size__in=[instance_size]).count(), 1)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()