From 6bc219c6350fb5c45b7be6839f2a786c53afef61 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sat, 9 Apr 2016 11:11:25 +0200 Subject: [PATCH] Avoid proliferation of parenthesis The str() function of the parse tree now emits expressions with much less parenthesis. This should allow optimized queries to be more readable. --- relational/parser.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/relational/parser.py b/relational/parser.py index d9a8f18..e351d8c 100644 --- a/relational/parser.py +++ b/relational/parser.py @@ -277,11 +277,8 @@ class Node (object): elif (self.kind == UNARY): return self.name + " " + self.prop + " (" + self.child.__str__() + ")" elif (self.kind == BINARY): - if self.left.kind == RELATION: - le = self.left.__str__() - else: - le = "(" + self.left.__str__() + ")" - if self.right.kind == RELATION: + le = self.left.__str__() + if self.right.kind != BINARY: re = self.right.__str__() else: re = "(" + self.right.__str__() + ")"