Fixing "DEFAULT NULL" sentence, which for some reason does not work. It needs to be only "NULL", and "DEFAULT NULL NULL" works too.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8263 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
renan.saddam 2009-07-30 00:00:19 +00:00
parent ee8d12c939
commit 90445e9119
2 changed files with 7 additions and 3 deletions

View file

@ -664,7 +664,11 @@ class DboMssql extends DboSource {
* @return string
*/
function buildColumn($column) {
return preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
$column = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
if (strpos($column, 'DEFAULT NULL') !== null) {
$column = str_replace('DEFAULT NULL', 'NULL', $column);
}
return $column;
}
/**
* Format indexes for create table

View file

@ -400,7 +400,7 @@ class DboMssqlTest extends CakeTestCase {
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
$result = $this->db->buildColumn($column);
$expected = '[client_id] int DEFAULT NULL';
$expected = '[client_id] int NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
@ -420,7 +420,7 @@ class DboMssqlTest extends CakeTestCase {
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT NULL';
$expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');