Fixed GenericReferenceField query issue
This commit is contained in:
parent
d3c2dfbaee
commit
3591593ac7
@ -509,7 +509,7 @@ class GenericReferenceField(BaseField):
|
||||
return {'_cls': document.__class__.__name__, '_ref': ref}
|
||||
|
||||
def prepare_query_value(self, op, value):
|
||||
return self.to_mongo(value)['_ref']
|
||||
return self.to_mongo(value)
|
||||
|
||||
|
||||
class BinaryField(BaseField):
|
||||
|
@ -624,9 +624,6 @@ class QuerySet(object):
|
||||
# 'in', 'nin' and 'all' require a list of values
|
||||
value = [field.prepare_query_value(op, v) for v in value]
|
||||
|
||||
if field.__class__.__name__ == 'GenericReferenceField':
|
||||
parts.append('_ref')
|
||||
|
||||
# if op and op not in match_operators:
|
||||
if op:
|
||||
if op in geo_operators:
|
||||
|
@ -545,7 +545,6 @@ class FieldTest(unittest.TestCase):
|
||||
user.save()
|
||||
|
||||
user = User.objects(bookmarks__all=[post_1, link_1]).first()
|
||||
print User.objects(bookmarks__all=[post_1, link_1]).explain()
|
||||
|
||||
self.assertEqual(user.bookmarks[0], post_1)
|
||||
self.assertEqual(user.bookmarks[1], link_1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user