Commit 3a3c4827 authored by Dries's avatar Dries
Browse files

- Patch #333499 by chx: fix handling of NULL default values in MySQL schema...

- Patch #333499 by chx: fix handling of NULL default values in MySQL schema API.  This fixes most but not all tests.
parent a56f3a87
...@@ -92,10 +92,14 @@ protected function createFieldSql($name, $spec) { ...@@ -92,10 +92,14 @@ protected function createFieldSql($name, $spec) {
$sql .= ' auto_increment'; $sql .= ' auto_increment';
} }
if (isset($spec['default'])) { // $spec['default'] can be NULL, so we explicitely check for the key here.
if (array_key_exists('default', $spec)) {
if (is_string($spec['default'])) { if (is_string($spec['default'])) {
$spec['default'] = "'" . $spec['default'] . "'"; $spec['default'] = "'" . $spec['default'] . "'";
} }
elseif (is_null($spec['default'])) {
$spec['default'] = 'NULL';
}
$sql .= ' DEFAULT ' . $spec['default']; $sql .= ' DEFAULT ' . $spec['default'];
} }
...@@ -259,7 +263,7 @@ public function dropField(&$ret, $table, $field) { ...@@ -259,7 +263,7 @@ public function dropField(&$ret, $table, $field) {
} }
public function fieldSetDefault(&$ret, $table, $field, $default) { public function fieldSetDefault(&$ret, $table, $field, $default) {
if ($default == NULL) { if (is_null($default)) {
$default = 'NULL'; $default = 'NULL';
} }
else { else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment