Permalink
Browse files

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
  • Loading branch information...
1 parent ee8d12c commit 90445e91198c668bc4e20883b7a7592143c10af7 @renan renan committed Jul 30, 2009
@@ -664,7 +664,11 @@ function insertMulti($table, $fields, $values) {
* @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
@@ -400,7 +400,7 @@ function testBuildColumn() {
$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 @@ function testBuildColumn() {
$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');

0 comments on commit 90445e9

Please sign in to comment.