Skip to content

Commit

Permalink
Merge pull request #5384 from okinaka/fix-mysql-describe
Browse files Browse the repository at this point in the history
2.5: Fixing Mysql::describe() for timestamp.
  • Loading branch information
markstory committed Dec 22, 2014
2 parents 92ae5f6 + 8c008ad commit 484b114
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -352,7 +352,7 @@ public function describe($model) {
$fields[$column->Field]['unsigned'] = $this->_unsigned($column->Type);
}
if ($fields[$column->Field]['type'] === 'timestamp' && strtoupper($column->Default) === 'CURRENT_TIMESTAMP') {
$fields[$column->Field]['default'] = '';
$fields[$column->Field]['default'] = null;
}
if (!empty($column->Key) && isset($this->index[$column->Key])) {
$fields[$column->Field]['key'] = $this->index[$column->Key];
Expand Down
10 changes: 9 additions & 1 deletion lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -906,8 +906,16 @@ public function testDescribeHandleCurrentTimestamp() {
'alias' => 'TimestampDefaultValue'
));
$result = $this->Dbo->describe($model);
$this->assertEquals('', $result['limit_date']['default']);
$this->Dbo->execute('DROP TABLE ' . $name);

$this->assertNull($result['limit_date']['default']);

$schema = new CakeSchema(array(
'connection' => 'test',
'testdescribes' => $result
));
$result = $this->Dbo->createSchema($schema);
$this->assertContains('`limit_date` timestamp NOT NULL,', $result);
}

/**
Expand Down

0 comments on commit 484b114

Please sign in to comment.