Raise an error if trying to perform a join

You can't join across reference fields, so raise an error
if someone tries to.
This commit is contained in:
Ross Lawley
2012-02-29 10:10:51 +00:00
parent e9b8093dac
commit 2a391f0f16
3 changed files with 22 additions and 1 deletions

View File

@@ -610,6 +610,9 @@ class QuerySet(object):
raise InvalidQueryError('Cannot resolve field "%s"'
% field_name)
else:
from mongoengine.fields import ReferenceField, GenericReferenceField
if isinstance(field, (ReferenceField, GenericReferenceField)):
raise InvalidQueryError('Cannot perform join in mongoDB: %s' % '__'.join(parts))
# Look up subfield on the previous field
new_field = field.lookup_member(field_name)
from base import ComplexBaseField