IS operator doesn't exists anymore: useless and cause ambiguité with 'is' relation stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Jun 2010 12:02:54 +0200
branchstable
changeset 551 db05b88729b2
parent 550 bf5d7daf7cc9
child 552 20eeb140d658
IS operator doesn't exists anymore: useless and cause ambiguité with 'is' relation
nodes.py
parser.g
parser.py
--- a/nodes.py	Wed Jun 09 12:00:44 2010 +0200
+++ b/nodes.py	Wed Jun 09 12:02:54 2010 +0200
@@ -466,6 +466,8 @@
         self.optional= value
 
 
+OPERATORS = frozenset(('=', '<', '<=', '>=', '>', 'ILIKE', 'LIKE'))
+
 class Comparison(HSMixin, Node):
     """handle comparisons:
 
@@ -477,10 +479,7 @@
         Node.__init__(self)
         if operator == '~=':
             operator = 'ILIKE'
-        elif operator == '=' and isinstance(value, Constant) and \
-                 value.type is None:
-            operator = 'IS'
-        assert operator in ('=', '<', '<=', '>=', '>', 'ILIKE', 'LIKE', 'IS'), operator
+        assert operator in OPERATORS, operator
         self.operator = operator.encode()
         if value is not None:
             self.append(value)
@@ -502,7 +501,7 @@
             return '%s %s %s' % (self.children[0].as_string(encoding, kwargs),
                                  self.operator.encode(),
                                  self.children[1].as_string(encoding, kwargs))
-        if self.operator in ('=', 'IS'):
+        if self.operator == '=':
             return self.children[0].as_string(encoding, kwargs)
         return '%s %s' % (self.operator.encode(),
                           self.children[0].as_string(encoding, kwargs))
--- a/parser.g	Wed Jun 09 12:00:44 2010 +0200
+++ b/parser.g	Wed Jun 09 12:02:54 2010 +0200
@@ -88,7 +88,7 @@
     token FALSE:       r'(?i)FALSE'
     token NULL:        r'(?i)NULL'
     token EXISTS:      r'(?i)EXISTS'
-    token CMP_OP:      r'(?i)<=|<|>=|>|~=|=|LIKE|ILIKE|IS'
+    token CMP_OP:      r'(?i)<=|<|>=|>|~=|=|LIKE|ILIKE'
     token ADD_OP:      r'\+|-'
     token MUL_OP:      r'\*|/'
     token FUNCTION:    r'[A-Za-z_]+\s*(?=\()'
--- a/parser.py	Wed Jun 09 12:00:44 2010 +0200
+++ b/parser.py	Wed Jun 09 12:02:54 2010 +0200
@@ -109,7 +109,7 @@
         ('FALSE', re.compile('(?i)FALSE')),
         ('NULL', re.compile('(?i)NULL')),
         ('EXISTS', re.compile('(?i)EXISTS')),
-        ('CMP_OP', re.compile('(?i)<=|<|>=|>|~=|=|LIKE|ILIKE|IS')),
+        ('CMP_OP', re.compile('(?i)<=|<|>=|>|~=|=|LIKE|ILIKE')),
         ('ADD_OP', re.compile('\\+|-')),
         ('MUL_OP', re.compile('\\*|/')),
         ('FUNCTION', re.compile('[A-Za-z_]+\\s*(?=\\()')),