Removing column length from unsupporting columns in DboPostgres::buildColumn(), fixes #4804

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7411 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-08-01 13:10:37 +00:00
parent 570145d568
commit 185a832e22
2 changed files with 21 additions and 2 deletions

View file

@ -614,6 +614,10 @@ class DboPostgres extends DboSource {
* @return string
*/
function buildColumn($column) {
$col = $this->columns[$column['type']];
if (!isset($col['length']) && !isset($col['limit'])) {
unset($column['length']);
}
$out = preg_replace('/integer\([0-9]+\)/', 'integer', parent::buildColumn($column));
$out = str_replace('integer serial', 'serial', $out);

View file

@ -327,13 +327,12 @@ 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;
@ -348,6 +347,22 @@ class DboPostgresTest extends CakeTestCase {
$db2->query('DROP SCHEMA _scope_test');
}
/**
* Tests that column types without default lengths in $columns do not have length values applied when
* generating schemas
*
* @access public
* @return void
*/
function testColumnUseLength() {
$result = array('name' => 'foo', 'type' => 'string', 'length' => 100, 'default' => 'FOO');
$expected = '"foo" varchar(100) DEFAULT \'FOO\'';
$this->assertEqual($this->db->buildColumn($result), $expected);
$result = array('name' => 'foo', 'type' => 'text', 'length' => 100, 'default' => 'FOO');
$expected = '"foo" text DEFAULT \'FOO\'';
$this->assertEqual($this->db->buildColumn($result), $expected);
}
}
?>