# HG changeset patch # User catherine@bothari # Date 1258678721 18000 # Node ID 8d9e0c5c37a53bd60e38fa4990cd4bd5450faee9 # Parent 25ac6fd9b0a0402953cc1364d394e1ef19ed5bc7 double numeric ampersand ok diff -r 25ac6fd9b0a0 -r 8d9e0c5c37a5 sqlpython/sqlpyPlus.py --- 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()