From 1a62c147fee83c85ce69b90b0f4a550944a034de Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Wed, 12 Sep 2018 16:45:01 +0200 Subject: [PATCH] Improve handling of CURRENT_TIMESTAMP default value Resolves https://github.com/cakephp/cakephp/issues/12553. --- lib/Cake/Model/Datasource/DboSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 8930ed3dd..1af4f9eee 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -3539,7 +3539,7 @@ class DboSource extends DataSource { } elseif (isset($column['null']) && $column['null'] === false) { $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); } return $this->_buildFieldParameters($out, $column, 'afterDefault');