Ticket #126: postgres_schema_support.patch
| File postgres_schema_support.patch, 4.9 kB (added by bithead, 13 months ago) |
|---|
-
database/QPostgreSqlDatabase.class.php
158 158 $strUsername = $this->Username; 159 159 $strPassword = $this->Password; 160 160 $strPort = $this->Port; 161 $strSchema = $this->Schema; 161 162 162 163 // Connect to the Database Server 163 164 $this->objPgSql = pg_connect(sprintf('host=%s dbname=%s user=%s password=%s port=%s',$strServer, $strName, $strUsername, $strPassword, $strPort)); … … 165 166 if (!$this->objPgSql) 166 167 throw new QPostgreSqlDatabaseException("Unable to connect to Database", -1, null); 167 168 169 //Set to schema, if different from "public" 170 if ($strSchema) $this->Query("SET search_path TO " . $this->Schema . ";"); 171 168 172 // Update Connected Flag 169 173 $this->blnConnectedFlag = true; 170 174 } … … 216 220 } 217 221 218 222 public function GetTables() { 219 $objResult = $this->Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = current_schema() ORDER BY TABLE_NAME ASC");223 $objResult = $this->Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ANY(current_schemas(false)) ORDER BY TABLE_NAME ASC"); 220 224 $strToReturn = array(); 221 225 while ($strRowArray = $objResult->FetchRow()) 222 226 array_push($strToReturn, $strRowArray[0]); … … 238 242 FROM 239 243 INFORMATION_SCHEMA.COLUMNS 240 244 WHERE 241 table_schema = current_schema()245 table_schema = ANY(current_schemas(false)) 242 246 AND 243 247 table_name = %s 244 248 ORDER BY ordinal_position … … 378 382 oid 379 383 FROM 380 384 pg_catalog.pg_namespace 381 WHERE 382 nspname=current_schema()385 WHERE 386 nspname=ANY(current_schemas(false)) 383 387 ) 384 388 ) 385 389 AND … … 399 403 // Index 1: the list of columns that are the foreign key 400 404 // Index 2: the table which this FK references 401 405 // Index 3: the list of columns which this FK references 402 $strTokenArray = split('FOREIGN KEY ', $objRow->GetColumn('consrc'));403 $strTokenArray[1] = split(' REFERENCES ', $strTokenArray[1]);406 $strTokenArray = explode('FOREIGN KEY ', $objRow->GetColumn('consrc')); 407 $strTokenArray[1] = explode(' REFERENCES ', $strTokenArray[1]); 404 408 $strTokenArray[2] = $strTokenArray[1][1]; 405 409 $strTokenArray[1] = $strTokenArray[1][0]; 406 410 $strTokenArray[2] = explode("(", $strTokenArray[2]); … … 569 573 WHERE 570 574 tc.table_name = %s 571 575 AND 572 tc.table_schema = current_schema()576 tc.table_schema = ANY(current_schemas(false)) 573 577 AND 574 578 tc.constraint_type = \'PRIMARY KEY\' 575 579 AND … … 598 602 WHERE 599 603 tc.table_name = %s 600 604 AND 601 tc.table_schema = current_schema()605 tc.table_schema = ANY(current_schemas(false)) 602 606 AND 603 607 tc.constraint_type = \'UNIQUE\' 604 608 AND … … 646 650 break; 647 651 case 'character': 648 652 $this->strType = QDatabaseFieldType::Char; 649 break; 653 break; 654 case 'interval': 650 655 case 'character varying': 651 656 case 'double precision': 652 657 // NOTE: PHP does not offer full support of double-precision floats. … … 659 664 $this->strType = QDatabaseFieldType::Blob; 660 665 break; 661 666 case 'timestamp': 667 case 'timestamp with time zone': 662 668 case 'timestamp without time zone': 663 // System-generated Timestamp values need to be treated as plain text 664 $this->strType = QDatabaseFieldType::VarChar; 669 // System-generated Timestamp values need to be treated as plain text 670 $this->strType = QDatabaseFieldType::VarChar; 665 671 $this->blnTimestamp = true; 666 672 break; 667 673 case 'date': 668 674 $this->strType = QDatabaseFieldType::Date; 669 675 break; 670 676 case 'time': 671 case 'time without time zone': 677 case 'time with time zone': 678 case 'time without time zone': 672 679 $this->strType = QDatabaseFieldType::Time; 673 680 break; 674 681 default: -
framework/QApplicationBase.class.php
377 377 // Expected Keys to be Set 378 378 $strExpectedKeys = array( 379 379 'adapter', 'server', 'port', 'database', 380 'username', 'password', 'profiling' 380 'username', 'password', 'profiling', 'schema' 381 381 ); 382 382 383 383 // Lookup the Serialized Array from the DB_CONFIG constants and unserialize it -
framework/QDatabaseBase.class.php
73 73 case 'Database': 74 74 case 'Username': 75 75 case 'Password': 76 case 'Schema': 76 77 return $this->objConfigArray[strtolower($strName)]; 77 78 78 79 default:
