# HG changeset patch # User catherine@Elli.myhome.westell.com # Date 1219925247 14400 # Node ID 2e69a257b6ab1332877f0de8c2479152e60d5bdf # Parent 4c59f4a8b680be488d9ec61442f0cda04fd8ea4b now catching multi table names in from clause diff -r 4c59f4a8b680 -r 2e69a257b6ab sqlpyPlus.py --- a/sqlpyPlus.py Thu Aug 28 07:53:44 2008 -0400 +++ b/sqlpyPlus.py Thu Aug 28 08:07:27 2008 -0400 @@ -510,12 +510,6 @@ self.curs.execute(sql) return [r[0] for r in self.curs.fetchall()] - tableNameRegex = re.compile( - r'(from|update)\s+(([a-zA-Z0-9_#$]+)\.)?([a-zA-Z0-9_#$]+)\s+', - re.IGNORECASE | re.DOTALL | re.MULTILINE) - tableNameRegex = re.compile( - r'(from|update)(.*)(where|set)', - re.IGNORECASE | re.DOTALL | re.MULTILINE) columnNameRegex = re.compile( r'select\s+(.*)from', re.IGNORECASE | re.DOTALL | re.MULTILINE) @@ -546,16 +540,11 @@ SELECT DISTINCT owner FROM all_tables WHERE owner LIKE '%%%s'""" completions = self.select_list(stmt % (text, text)) if segment in ('where', 'group by', 'order by', 'having', 'set'): - try: - owner, tableName = self.tableNameRegex.search(line).groups()[2:4] - except AttributeError: - return [] - if owner: - stmt = "SELECT column_name FROM all_tab_columns WHERE owner = '%s' AND table_name = '%s'" \ - % (owner.upper(), tableName.upper()) - else: - stmt = "SELECT column_name FROM all_tab_columns WHERE table_name = '%s'" \ - % (tableName.upper()) + tableNames = completion.tableNamesFromFromClause(line) + if tableNames: + stmt = """SELECT column_name FROM all_tab_columns + WHERE table_name IN (%s)""" % \ + (','.join("'%s'" % (t) for t in tableNames)) stmt = "%s AND column_name LIKE '%s%%'" % (stmt, text) completions = self.select_list(stmt)