Improve handling of CURRENT_TIMESTAMP default value

Resolves https://github.com/cakephp/cakephp/issues/12553.
This commit is contained in:
Val Bancer 2018-09-12 16:45:01 +02:00 committed by GitHub
parent 4aa0df8370
commit 1a62c147fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3539,7 +3539,7 @@ class DboSource extends DataSource {
} elseif (isset($column['null']) && $column['null'] === false) { } elseif (isset($column['null']) && $column['null'] === false) {
$out .= ' NOT NULL'; $out .= ' NOT NULL';
} }
if ($type === 'timestamp' && isset($column['default']) && strtolower($column['default']) === 'current_timestamp') { if (in_array($type, array('timestamp', 'datetime')) && isset($column['default']) && strtolower($column['default']) === 'current_timestamp') {
$out = str_replace(array("'CURRENT_TIMESTAMP'", "'current_timestamp'"), 'CURRENT_TIMESTAMP', $out); $out = str_replace(array("'CURRENT_TIMESTAMP'", "'current_timestamp'"), 'CURRENT_TIMESTAMP', $out);
} }
return $this->_buildFieldParameters($out, $column, 'afterDefault'); return $this->_buildFieldParameters($out, $column, 'afterDefault');