Skip to content
Browse files

Adding support for CURRENT_TIMESTAMP to all dbo's.

  • Loading branch information...
1 parent 5fcbc33 commit f6d12dbde6935b4826c94f4c03776d08e153dcb7 @markstory markstory committed
Showing with 6 additions and 1 deletion.
  1. +6 −1 cake/libs/model/datasources/dbo_source.php
View
7 cake/libs/model/datasources/dbo_source.php
@@ -2634,11 +2634,16 @@ function buildColumn($column) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
} elseif (isset($column['default'])) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type);
- } elseif (isset($column['null']) && $column['null'] == true) {
+ } elseif ($type !== 'timestamp' && !empty($column['null'])) {
$out .= ' DEFAULT NULL';
+ } elseif ($type === 'timestamp' && !empty($column['null'])) {
+ $out .= ' NULL';
} elseif (isset($column['null']) && $column['null'] == false) {
$out .= ' NOT NULL';
}
+ if ($type == 'timestamp' && isset($column['default']) && strtolower($column['default']) == 'current_timestamp') {
+ $out = str_replace(array("'CURRENT_TIMESTAMP'", "'current_timestamp'"), 'CURRENT_TIMESTAMP', $out);
+ }
$out = $this->_buildFieldParameters($out, $column, 'afterDefault');
return $out;
}

0 comments on commit f6d12db

Please sign in to comment.
Something went wrong with that request. Please try again.