Merge pull request #1843 from terencehonles/add-__repr__-to-Q-and-QCombination

add __repr__ to Q and QCombination
This commit is contained in:
erdenezul
2018-10-25 10:14:05 +08:00
committed by GitHub
2 changed files with 19 additions and 0 deletions

View File

@@ -131,6 +131,10 @@ class QCombination(QNode):
else:
self.children.append(node)
def __repr__(self):
op = ' & ' if self.operation is self.AND else ' | '
return '(%s)' % op.join([repr(node) for node in self.children])
def accept(self, visitor):
for i in range(len(self.children)):
if isinstance(self.children[i], QNode):
@@ -151,6 +155,9 @@ class Q(QNode):
def __init__(self, **query):
self.query = query
def __repr__(self):
return 'Q(**%s)' % repr(self.query)
def accept(self, visitor):
return visitor.visit_query(self)