]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14679, MDL-17491 empty defaults: when passing empty ('') default to char/clob...
authorstronk7 <stronk7>
Tue, 22 Sep 2009 17:26:40 +0000 (17:26 +0000)
committerstronk7 <stronk7>
Tue, 22 Sep 2009 17:26:40 +0000 (17:26 +0000)
apply correct $default_for_char, so each DB will get its correct empty value

lib/ddl/sql_generator.php

index 5b13f5fbcbd0df6beb0ce5e89e630071622c2ba5..d5ca19eeac65ee2fc321cd4736b3f4a1ff4da9a4 100644 (file)
@@ -520,7 +520,11 @@ abstract class sql_generator {
         if ($xmldb_field->getDefault() !== NULL) {
             if ($xmldb_field->getType() == XMLDB_TYPE_CHAR ||
                 $xmldb_field->getType() == XMLDB_TYPE_TEXT) {
-                    $default = "'" . $this->addslashes($xmldb_field->getDefault()) . "'";
+                    if ($xmldb_field->getDefault() === '') { // If passing empty default, use the $default_for_char one instead
+                        $default = "'" . $this->default_for_char . "'";
+                    } else {
+                        $default = "'" . $this->addslashes($xmldb_field->getDefault()) . "'";
+                    }
             } else {
                 $default = $xmldb_field->getDefault();
             }