# HG changeset patch # User catherine@Elli.myhome.westell.com # Date 1219890104 14400 # Node ID 25cbb45b190d98b5c8ed618f709df0f20893fb2a # Parent 2baecb3d5356c7ba6fe27b5af3e60076b4e557a8 column completion working diff -r 2baecb3d5356 -r 25cbb45b190d sqlpyPlus.py --- a/sqlpyPlus.py Wed Aug 27 21:49:26 2008 -0400 +++ b/sqlpyPlus.py Wed Aug 27 22:21:44 2008 -0400 @@ -526,7 +526,15 @@ if not completions: stmt = "SELECT column_name FROM all_tab_columns WHERE column_name LIKE '%s%%'" completions = self.select_list(stmt % (text)) - elif segment in ('from', 'update'): + if segment == 'from': + columnNames = self.columnNameRegex.search(line) + if columnNames: + columnNames = columnNames.group(1) + columnNames = [c.strip().upper() for c in columnNames.split(',')] + stmt1 = "SELECT table_name FROM all_tab_columns WHERE column_name = '%s' AND table_name LIKE '%s%%'" + for columnName in columnNames: + completions.extend(self.select_list(stmt1 % (columnName, text))) + if segment in ('from', 'update') and (not completions): stmt = "SELECT table_name FROM user_tables WHERE table_name LIKE '%s%%'" completions = self.select_list(stmt % (text)) if not completions: @@ -534,7 +542,7 @@ UNION SELECT DISTINCT owner FROM all_tables WHERE owner LIKE '%%%s'""" completions = self.select_list(stmt % (text, text)) - elif segment in ('where', 'group by', 'order by'): + if segment in ('where', 'group by', 'order by'): try: owner, tableName = self.tableNameRegex.search(line).groups()[2:4] except AttributeError: @@ -545,6 +553,7 @@ else: stmt = "SELECT column_name FROM all_tab_columns WHERE table_name = '%s'" \ % (tableName.upper()) + stmt = "%s AND column_name LIKE '%s%%'" % (stmt, text) completions = self.select_list(stmt) return completions