Adding schema scoping to table description queries in DboPostgres, fixes #5006

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7409 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-08-01 06:33:01 +00:00
parent 793295036f
commit 8284872b82
2 changed files with 29 additions and 1 deletions

View file

@ -193,7 +193,14 @@ class DboPostgres extends DboSource {
$this->_sequenceMap[$table] = array();
if ($fields === null) {
$cols = $this->fetchAll("SELECT DISTINCT column_name AS name, data_type AS type, is_nullable AS null, column_default AS default, ordinal_position AS position, character_maximum_length AS char_length, character_octet_length AS oct_length FROM information_schema.columns WHERE table_name =" . $this->value($table) . " ORDER BY position", false);
$cols = $this->fetchAll(
"SELECT DISTINCT column_name AS name, data_type AS type, is_nullable AS null,
column_default AS default, ordinal_position AS position, character_maximum_length AS char_length,
character_octet_length AS oct_length FROM information_schema.columns
WHERE table_name = " . $this->value($table) . " AND table_schema = " .
$this->value($this->config['schema'])." ORDER BY position",
false
);
foreach ($cols as $column) {
$colKey = array_keys($column);

View file

@ -327,6 +327,27 @@ class DboPostgresTest extends CakeTestCase {
$this->assertEqual($db1->lastInsertId($table), 1);
$this->assertEqual($db2->lastInsertId($table), 2);
}
/**
* Tests that table lists and descriptions are scoped to the proper Postgres schema
*
* @access public
* @return void
*/
function testSchemaScoping() {
$db1 =& ConnectionManager::getDataSource('test_suite');
$db1->cacheSources = false;
$db1->reconnect(array('persistent' => false));
$db1->query('CREATE SCHEMA _scope_test');
$db2 =& ConnectionManager::create(
'test_suite_2',
array_merge($db1->config, array('driver' => 'postgres', 'schema' => '_scope_test'))
);
$db2->cacheSources = false;
$db2->query('DROP SCHEMA _scope_test');
}
}
?>