From 90445e91198c668bc4e20883b7a7592143c10af7 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Thu, 30 Jul 2009 00:00:19 +0000 Subject: [PATCH] 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 --- cake/libs/model/datasources/dbo/dbo_mssql.php | 6 +++++- .../cases/libs/model/datasources/dbo/dbo_mssql.test.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index 4e5fb73ce..6bed2e36f 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -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 diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php index bd6060b8a..ba3f6df3b 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php @@ -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');