changeset 437:6ba7087f1a34

allow qualified or unqualified object names in gerald
author catherine@dellzilla
date Fri, 29 Jan 2010 15:20:59 -0500
parents f441f2eb52e0
children 39a664a87c51
files sqlpython/connections.py sqlpython/sqlpyPlus.py
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/connections.py	Thu Jan 28 17:05:50 2010 -0500
+++ b/sqlpython/connections.py	Fri Jan 29 15:20:59 2010 -0500
@@ -13,11 +13,14 @@
         self.dbobj = dbobj
         self.type = str(type(self.dbobj)).split('.')[-1].lower().strip("'>")
         self.path = '%s/%s' % (self.type, self.fullname)
-        (self.owner, self.unqualified_name) = self.fullname.split('.')
+        if '.' in self.fullname:
+            (self.owner, self.unqualified_name) = self.fullname.split('.')
+            self.owner = self.owner.lower()        
+        else:
+            (self.owner, self.unqualified_name) = (None, self.fullname)        
         self.unqualified_path = '%s/%s' % (self.type, self.unqualified_name)
-        self.owner = self.owner.lower()
     def match_pattern(self, pattern, specific_owner=None):
-        right_owner = (not specific_owner) or (self.owner == specific_owner.lower())
+        right_owner = (not self.owner) or (not specific_owner) or (self.owner == specific_owner.lower())
         if not pattern:
             return right_owner        
         compiled = re.compile(pattern, re.IGNORECASE)            
--- a/sqlpython/sqlpyPlus.py	Thu Jan 28 17:05:50 2010 -0500
+++ b/sqlpython/sqlpyPlus.py	Fri Jan 29 15:20:59 2010 -0500
@@ -1593,10 +1593,9 @@
                     clauses = []
                     for col in descrip.dbobj.columns:
                         clauses.append(comparitor % (col, sql_pattern))
-                    sql = "SELECT * FROM %s WHERE 1=0\n%s;" % (descrip.dbobj, ' '.join(clauses))
-                    sql = self.parsed(sql, 
-                                          terminator=arg.parsed.terminator or ';',
-                                          suffix=arg.parsed.suffix)
+                    sql = "SELECT * FROM %s WHERE 1=0\n%s;" % (descrip.fullname, ' '.join(clauses))
+                    sql = self.parsed(sql, terminator=arg.parsed.terminator or ';',
+                                      suffix=arg.parsed.suffix)
                     self.do_select(sql)
                 elif hasattr(descrip.dbobj, 'source'):
                     for (line_num, line) in descrip.dbobj.source: