This commit is contained in:
		| @@ -26,6 +26,7 @@ class QNodeVisitor(object): | ||||
| class DuplicateQueryConditionsError(InvalidQueryError): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class SimplificationVisitor(QNodeVisitor): | ||||
|     """Simplifies query trees by combinging unnecessary 'and' connection nodes | ||||
|     into a single Q-object. | ||||
| @@ -39,6 +40,7 @@ class SimplificationVisitor(QNodeVisitor): | ||||
|                 try: | ||||
|                     return Q(**self._query_conjunction(queries)) | ||||
|                 except DuplicateQueryConditionsError: | ||||
|                     # Cannot be simplified | ||||
|                     pass | ||||
|         return combination | ||||
|  | ||||
| @@ -127,8 +129,7 @@ class QCombination(QNode): | ||||
|             # If the child is a combination of the same type, we can merge its | ||||
|             # children directly into this combinations children | ||||
|             if isinstance(node, QCombination) and node.operation == operation: | ||||
|                 # self.children += node.children | ||||
|                 self.children.append(node) | ||||
|                 self.children += node.children | ||||
|             else: | ||||
|                 self.children.append(node) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user