Fixed premature return for query gen
This commit is contained in:
		| @@ -321,40 +321,39 @@ class QuerySet(object): | |||||||
|  |  | ||||||
|             if key == "__raw__": |             if key == "__raw__": | ||||||
|                 mongo_query.update(value) |                 mongo_query.update(value) | ||||||
|                 return mongo_query |             else: | ||||||
|  |                 parts = key.split('__') | ||||||
|  |                 # Check for an operator and transform to mongo-style if there is | ||||||
|  |                 op = None | ||||||
|  |                 if parts[-1] in operators + match_operators: | ||||||
|  |                     op = parts.pop() | ||||||
|  |  | ||||||
|             parts = key.split('__') |                 if _doc_cls: | ||||||
|             # Check for an operator and transform to mongo-style if there is |                     # Switch field names to proper names [set in Field(name='foo')] | ||||||
|             op = None |                     fields = QuerySet._lookup_field(_doc_cls, parts) | ||||||
|             if parts[-1] in operators + match_operators: |                     parts = [field.db_field for field in fields] | ||||||
|                 op = parts.pop() |  | ||||||
|  |  | ||||||
|             if _doc_cls: |                     # Convert value to proper value | ||||||
|                 # Switch field names to proper names [set in Field(name='foo')] |                     field = fields[-1] | ||||||
|                 fields = QuerySet._lookup_field(_doc_cls, parts) |                     singular_ops = [None, 'ne', 'gt', 'gte', 'lt', 'lte'] | ||||||
|                 parts = [field.db_field for field in fields] |                     singular_ops += match_operators | ||||||
|  |                     if op in singular_ops: | ||||||
|  |                         value = field.prepare_query_value(op, value) | ||||||
|  |                     elif op in ('in', 'nin', 'all'): | ||||||
|  |                         # 'in', 'nin' and 'all' require a list of values | ||||||
|  |                         value = [field.prepare_query_value(op, v) for v in value] | ||||||
|  |  | ||||||
|                 # Convert value to proper value |                     if field.__class__.__name__ == 'GenericReferenceField': | ||||||
|                 field = fields[-1] |                         parts.append('_ref') | ||||||
|                 singular_ops = [None, 'ne', 'gt', 'gte', 'lt', 'lte'] |  | ||||||
|                 singular_ops += match_operators |  | ||||||
|                 if op in singular_ops: |  | ||||||
|                     value = field.prepare_query_value(op, value) |  | ||||||
|                 elif op in ('in', 'nin', 'all'): |  | ||||||
|                     # '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': |                 if op and op not in match_operators: | ||||||
|                     parts.append('_ref') |                     value = {'$' + op: value} | ||||||
|  |  | ||||||
|             if op and op not in match_operators: |                 key = '.'.join(parts) | ||||||
|                 value = {'$' + op: value} |                 if op is None or key not in mongo_query: | ||||||
|  |                     mongo_query[key] = value | ||||||
|             key = '.'.join(parts) |                 elif key in mongo_query and isinstance(mongo_query[key], dict): | ||||||
|             if op is None or key not in mongo_query: |                     mongo_query[key].update(value) | ||||||
|                 mongo_query[key] = value |  | ||||||
|             elif key in mongo_query and isinstance(mongo_query[key], dict): |  | ||||||
|                 mongo_query[key].update(value) |  | ||||||
|  |  | ||||||
|         return mongo_query |         return mongo_query | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user