Hi,

I encountered the bug when using SQLObject on a PostgreSQL database with
multiple schemas.

I have coded a workaround that will allow my project to proceed, however
upon checking existing trackers, I found out the following tracker that
addresses the same problem as my patch (attached to this email) does but
it hasn't been applied since 2005 !!!

[ 1346066 ] working with schemas
Submitted By: Felipe Hoffa - fhoffa
Date Submitted: 2005-11-02 09:17

Anyways, his solution would work even when there are tables with similar
names across schemas, my patch does not.  To make a more comprehensive
fix, we need to combine his solution with mine.

Please act upon this as this is an inhibitor to using SQLObjects and
Turbogears in a large scale PostgreSQL installations.

If you guys don't have the time to apply the patch to svn, I can do it
with proper credential (temporary if necessary).

Thanks,
Will
Index: pgconnection.py
===================================================================
--- pgconnection.py	(revision 2851)
+++ pgconnection.py	(working copy)
@@ -168,9 +168,15 @@
     def joinSQLType(self, join):
         return 'INT NOT NULL'
 
+    def tableNameOnly(self, table_name):
+        tablenameonly = table_name
+        if table_name.find('.') > -1:
+            tablenameonly = table_name.split('.')[1]
+        return tablenameonly
+
     def tableExists(self, tableName):
         result = self.queryOne("SELECT COUNT(relname) FROM pg_class WHERE relname = %s"
-                               % self.sqlrepr(tableName))
+                               % self.sqlrepr(self.tableNameOnly(tableName)))
         return result[0]
 
     def addColumn(self, tableName, column):
@@ -219,7 +225,7 @@
                 field, reftable = match.groups()
                 keymap[field] = reftable.capitalize()
 
-        primaryData = self.queryAll(primaryKeyQuery % self.sqlrepr(tableName))
+        primaryData = self.queryAll(primaryKeyQuery % self.sqlrepr(self.tableNameOnly(tableName)))
         primaryRE = re.compile(r'CREATE .*? USING .* \((.+?)\)')
         primaryKey = None
         for isPrimary, indexDef in primaryData:
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to