changeset 419:8d9e0c5c37a5

double numeric ampersand ok
author catherine@bothari
date Thu, 19 Nov 2009 19:58:41 -0500
parents 25ac6fd9b0a0
children eb7cbbb00395
files sqlpython/sqlpyPlus.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Thu Nov 19 17:20:06 2009 -0500
+++ b/sqlpython/sqlpyPlus.py	Thu Nov 19 19:58:41 2009 -0500
@@ -567,13 +567,15 @@
         re.IGNORECASE | re.DOTALL | re.MULTILINE)        
     def completedefault(self, text, line, begidx, endidx):
         (username, schemas) = self.metadata()
-        segment = completion.whichSegment(line)
+        segment = completion.whichSegment(line)        
         text = text.upper()
         if segment in ('select', 'where', 'having', 'set', 'order by', 'group by'):
             completions = [c for c in schemas[username].column_names if c.startswith(text)] \
                           or [c for c in schemas.qual_column_names if c.startswith(text)]
                           # TODO: the latter not working
         elif segment in ('from', 'update', 'insert into'):
+            # print schemas[username].table_names
+            # TODO: from postgres, these table names are jrrt.fishies, etc.
             completions = [t for t in schemas[username].table_names if t.startswith(text)]
         elif segment == 'beginning':
             completions = [n for n in self.get_names() if n.startswith('do_')] + [
@@ -695,11 +697,14 @@
             subst = regexpr.search(raw) # do not FINDALL b/c we don't want to ask twice
         return raw
 
-    numericampre = re.compile('(&(\d+))')    
+    doublenumericampre = re.compile('(&&(\d+))')  
+    numericampre = re.compile('(&(\d+))')        
     doubleampre = re.compile('(&&([a-zA-Z\d_$#]+))', re.IGNORECASE)
     singleampre = re.compile( '(&([a-zA-Z\d_$#]+))', re.IGNORECASE)
     def preparse(self, raw, **kwargs):
         if self.scan:
+            raw = self.ampersand_substitution(raw, regexpr=self.doublenumericampre, isglobal=True)            
+        if self.scan:
             raw = self.ampersand_substitution(raw, regexpr=self.numericampre, isglobal=False)
         if self.scan:
             raw = self.ampersand_substitution(raw, regexpr=self.doubleampre, isglobal=True)
@@ -1514,6 +1519,7 @@
         
     def metadata(self):
         schemas = self.connections[self.connection_number]['schemas']
+        
         username = self.connections[self.connection_number]['user']
         if self.rdbms == 'oracle':
             username = username.upper()