Support for multiple schemas with postgresql (with patch)

thread: 2 messages  |  last: about 3 years ago  |  started: tuesday, january 2, 2007, 3:47 am pst


#1  |  disaster (Bassano, Italy) Italy
Tuesday, January 2, 2007, 3:47 AM PST

Postgresql let you have multiple schemas on the same database,
qcodo supports only tables from the main (public) schema.
with this patch qcodo can see and code-gen classes for every table on any schema. (you still need to set the search_path in postgresql.conf to include all your schemas)

--- htdocs/includes/qcodo/_core/database/QPostgreSqlDatabase.class.php    2006-09-25 22:53:50.000000000 +0200
+++ svn/htdocs/quasar/includes/qcodo/_core/database/QPostgreSqlDatabase.class.php    2007-01-02 11:45:18.000000000 +0100
@@ -160,7 +160,7 @@
         }
 
         public function GetTables() {
-            $objResult = $this->Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = current_schema() ORDER BY TABLE_NAME ASC");
+            $objResult = $this->Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ANY(current_schemas(false)) ORDER BY TABLE_NAME ASC");
             $strToReturn = array();
             while ($strRowArray = $objResult->FetchRow())
                 array_push($strToReturn, $strRowArray[0]);
@@ -182,7 +182,7 @@
                 FROM 
                     INFORMATION_SCHEMA.COLUMNS 
                 WHERE 
-                    table_schema = current_schema() 
+                    table_schema = ANY(current_schemas(false)) 
                 AND 
                     table_name = %s 
                 ORDER BY ordinal_position        
@@ -316,14 +316,14 @@
                         WHERE
                             relname=%s
                         AND 
-                            relnamespace = 
+                            relnamespace = ANY
                             (
                                 SELECT 
                                     oid 
                                 FROM 
                                     pg_catalog.pg_namespace
                                 WHERE 
-                                    nspname=current_schema()
+                                    nspname=ANY(current_schemas(false))
                             )
                     )
                 AND 
@@ -513,7 +513,7 @@
                 WHERE 
                     tc.table_name = %s 
                 AND 
-                    tc.table_schema = current_schema() 
+                    tc.table_schema = ANY(current_schemas(false)) 
                 AND 
                     tc.constraint_type = \'PRIMARY KEY\' 
                 AND 
@@ -542,7 +542,7 @@
                 WHERE 
                     tc.table_name = %s 
                 AND 
-                    tc.table_schema = current_schema() 
+                    tc.table_schema = ANY(current_schemas(false)) 
                 AND 
                     tc.constraint_type = \'UNIQUE\' 
                 AND 
.bc
#2  |  marcosdsanchez (Buenos Aires, Argentina) Argentina
Tuesday, January 6, 2009, 6:51 AM PST

Thanks disaster for the patch,

I've included it (with other patches) in

<http://trac.qcu.be/projects/qcubed/attachment/ticket/126/QPostgreSqlDatabase.class.php.patch>

Hopefully it will get included in a Qcubed release.

Thanks,

Marcos



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.