Skip to content

Commit

Permalink
Fix null default values not being returned by defaultValues()
Browse files Browse the repository at this point in the history
Refs #5454
  • Loading branch information
markstory committed Dec 20, 2014
1 parent b9af093 commit 28cae9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Database/Schema/Table.php
Expand Up @@ -342,7 +342,7 @@ public function columnType($name, $type = null) {
public function defaultValues() {
$defaults = [];
foreach ($this->_columns as $name => $data) {
if (isset($data['default'])) {
if (array_key_exists('default', $data)) {
$defaults[$name] = $data['default'];
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase/Database/Schema/TableTest.php
Expand Up @@ -164,11 +164,13 @@ public function testDefaultValues() {
'default' => 'A title'
])->addColumn('body', [
'type' => 'text',
'default' => null,
]);
$result = $table->defaultValues();
$expected = [
'id' => 0,
'title' => 'A title'
'title' => 'A title',
'body' => null
];
$this->assertEquals($expected, $result);
}
Expand Down

0 comments on commit 28cae9d

Please sign in to comment.