- Patch #333499 by chx: fix handling of NULL default values in MySQL schema API. This fixes most but not all tests.

merge-requests/26/head
Dries Buytaert 2008-11-13 20:52:13 +00:00
parent a56f3a8773
commit 3a3c482776
1 changed files with 6 additions and 2 deletions

View File

@ -92,10 +92,14 @@ class DatabaseSchema_mysql extends DatabaseSchema {
$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'])) {
$spec['default'] = "'" . $spec['default'] . "'";
}
elseif (is_null($spec['default'])) {
$spec['default'] = 'NULL';
}
$sql .= ' DEFAULT ' . $spec['default'];
}
@ -259,7 +263,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
}
public function fieldSetDefault(&$ret, $table, $field, $default) {
if ($default == NULL) {
if (is_null($default)) {
$default = 'NULL';
}
else {