commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r6807 - in trunk/gnue-common/src/datasources: . drivers/DBSIG2


From: johannes
Subject: r6807 - in trunk/gnue-common/src/datasources: . drivers/DBSIG2
Date: Tue, 14 Dec 2004 14:24:55 -0600 (CST)

Author: johannes
Date: 2004-12-14 14:24:54 -0600 (Tue, 14 Dec 2004)
New Revision: 6807

Modified:
   trunk/gnue-common/src/datasources/GConditions.py
   trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py
Log:
Added operations <upper> and <lower> to GConditions, which allow 
case-insensitive conditions 


Modified: trunk/gnue-common/src/datasources/GConditions.py
===================================================================
--- trunk/gnue-common/src/datasources/GConditions.py    2004-12-14 19:44:26 UTC 
(rev 6806)
+++ trunk/gnue-common/src/datasources/GConditions.py    2004-12-14 20:24:54 UTC 
(rev 6807)
@@ -772,7 +772,38 @@
     self._needChildren (self._maxChildren)
     return self._children [0].evaluate (lookup) is not None
 
+# -----------------------------------------------------------------------------
+# upper  
+# -----------------------------------------------------------------------------
 
+class GCupper (GUnaryConditionElement):
+  def __init__ (self, parent = None):
+    GUnaryConditionElement.__init__ (self, parent, 'GCupper')
+
+  # ---------------------------------------------------------------------------
+  # evaluate
+  # ---------------------------------------------------------------------------
+
+  def evaluate (self, lookup):
+    self._needChildren (self._maxChildren)
+    return string.upper (self._children [0].evaluate (lookup))
+
+# -----------------------------------------------------------------------------
+# lower  
+# -----------------------------------------------------------------------------
+
+class GClower (GUnaryConditionElement):
+  def __init__ (self, parent = None):
+    GUnaryConditionElement.__init__ (self, parent, 'GClower')
+
+  # ---------------------------------------------------------------------------
+  # evaluate
+  # ---------------------------------------------------------------------------
+
+  def evaluate (self, lookup):
+    self._needChildren (self._maxChildren)
+    return string.lower (self._children [0].evaluate (lookup))
+
 # =============================================================================
 # Return a dictionary of all XML elements available
 # =============================================================================
@@ -794,7 +825,8 @@
                'Required': 1,
                'Typecast': GTypecast.name } },
          'ParentTags':  ('eq','ne','lt','le','gt','ge','add','sub','mul',
-                         'div','like','notlike','between','notbetween') },
+                         'div','like','notlike','between','notbetween',
+                         'upper', 'lower', 'null', 'notnull') },
       'cparam':       {
          'BaseClass': GCParam,
          'Attributes': {
@@ -878,6 +910,15 @@
       'notnull':      {
          'BaseClass': GCnotnull,
          'ParentTags': ('condition','and','or','not') },
+      'upper':       {
+         'BaseClass': GCupper,
+         'ParentTags':  ('eq','ne','lt','le','gt','ge',
+                         'like','notlike','between','notbetween') },
+      'lower':       {
+         'BaseClass': GClower,
+         'ParentTags':  ('eq','ne','lt','le','gt','ge',
+                         'like','notlike','between','notbetween') },
+
       }
 
   for alteration in updates.keys():
@@ -1169,7 +1210,9 @@
   'like':            (2,   2, GClike ),
   'notlike':         (2,   2, GCnotlike ),
   'between':         (3,   3, GCbetween ),
-  'null':            (1,   1, GCnull)
+  'null':            (1,   1, GCnull),
+  'upper':           (1,   1, GCupper),
+  'lower':           (1,   1, GClower),
   }
 
 # creates an GCondition Tree out of an list of tokens in a prefix
@@ -1414,6 +1457,14 @@
   lookup = {'foo': 'bar', 'bar': 5.6}
   _check_construction (prefix, lookup)
 
+  prefix = ['eq', ['upper', ['field', 'nfoo']], ['upper', ['const', 'baR']]]
+  lookup = {'nfoo': 'bAr'}
+  _check_construction (prefix, lookup)
+
+  prefix = ['eq', ['lower', ['field', 'nfoo']], ['const', 'bar']]
+  lookup = {'nfoo': 'BaR'}
+  _check_construction (prefix, lookup)
+
   print "end of construction test sequence"
   raw_input ()
 
@@ -1481,5 +1532,6 @@
   cond1 = buildTreeFromList (['and'])
   cond2 = buildTreeFromList (prefix)
   _check_combineConditions (cond1, cond2)
+
   
   print "\n\nImpossible condition:", GCimpossible.prefixNotation ()

Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py      
2004-12-14 19:44:26 UTC (rev 6806)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py      
2004-12-14 20:24:54 UTC (rev 6807)
@@ -96,7 +96,9 @@
        # These two are hacks... these are not really valid tags
        # Used when the 2nd value of EQ or NE is NULL.
        '__iseq':          (2,   2, '(%s IS %s)',             None      ),
-       '__isne':          (2,   2, '(%s IS NOT %s)',         None      )}
+       '__isne':          (2,   2, '(%s IS NOT %s)',         None      ),
+       'upper':           (1,   1, 'UPPER(%s)',              None      ),
+       'lower':           (1,   1, 'LOWER(%s)',              None      )}
 
 
   def __init__(self, *args, **params):





reply via email to

[Prev in Thread] Current Thread [Next in Thread]