[BUGFIX] SQL parser does not support NULL as default value
authorXavier Perseguers <xavier@typo3.org>
Mon, 6 Feb 2012 13:04:27 +0000 (14:04 +0100)
committerXavier Perseguers <xavier@typo3.org>
Tue, 7 Feb 2012 06:51:40 +0000 (07:51 +0100)
When preparing a database schema with proper referential integrity,
one typically has to choose NULL as default value for foreign keys.
However, database analyzer does not support NULL as default value and
shows an empty string ('') instead.

Change-Id: If4271e1edd078b9a19fbb82c04e265f181e07d9d
Fixes: #33704
Releases: 4.7, 4.6
Reviewed-on: http://review.typo3.org/8861
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
t3lib/class.t3lib_install_sql.php

index 1b961cf..a55e811 100644 (file)
@@ -568,7 +568,11 @@ class t3lib_install_Sql {
                if (!strstr($row['Type'], 'blob') && !strstr($row['Type'], 'text')) {
                                // Add a default value if the field is not auto-incremented (these fields never have a default definition)
                        if (!stristr($row['Extra'], 'auto_increment')) {
-                               $field[] = 'default \'' . addslashes($row['Default']) . '\'';
+                               if ($row['Default'] === NULL) {
+                                       $field[] = 'default NULL';
+                               } else {
+                                       $field[] = 'default \'' . addslashes($row['Default']) . '\'';
+                               }
                        }
                }
                if ($row['Extra']) {