mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixed default values being declared for integer column types when default = ''. Closes #5244
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7464 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
074ede4639
commit
9cb854b48e
2 changed files with 16 additions and 0 deletions
|
@ -2324,6 +2324,11 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$out .= '(' . $length . ')';
|
||||
}
|
||||
|
||||
if (($column['type'] == 'integer' || $column['type'] == 'float' ) && isset($column['default']) && $column['default'] === '') {
|
||||
$column['default'] = null;
|
||||
}
|
||||
|
||||
if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') {
|
||||
$out .= ' ' . $this->columns['primary_key']['name'];
|
||||
} elseif (isset($column['key']) && $column['key'] == 'primary') {
|
||||
|
|
|
@ -3313,6 +3313,17 @@ class DboSourceTest extends CakeTestCase {
|
|||
$result = $this->testDb->buildColumn($data);
|
||||
$expected = '`testName` DEFAULT NULL';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$data = array(
|
||||
'name' => 'int_field',
|
||||
'type' => 'integer',
|
||||
'default' => '',
|
||||
'null' => false,
|
||||
);
|
||||
$this->testDb->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), );
|
||||
$result = $this->testDb->buildColumn($data);
|
||||
$expected = '`int_field` int(11) NOT NULL';
|
||||
$this->assertTrue($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testIntrospectType method
|
||||
|
|
Loading…
Reference in a new issue