@@ -153,7 +153,7 @@ class Forge
153153 *
154154 * @internal Used for marking nullable fields. Not covered by BC promise.
155155 */
156- protected $ null = '' ;
156+ protected $ null = 'NULL ' ;
157157
158158 /**
159159 * DEFAULT value representation in CREATE/ALTER TABLE statements
@@ -562,7 +562,7 @@ public function createTable(string $table, bool $ifNotExists = false, array $att
562562 }
563563
564564 /**
565- * @return string
565+ * @return string SQL string
566566 *
567567 * @deprecated $ifNotExists is no longer used, and will be removed.
568568 */
@@ -897,13 +897,19 @@ protected function _processFields(bool $createTable = false): array
897897 $ this ->_attributeDefault ($ attributes , $ field );
898898
899899 if (isset ($ attributes ['NULL ' ])) {
900+ $ nullString = ' ' . $ this ->null ;
901+
900902 if ($ attributes ['NULL ' ] === true ) {
901- $ field ['null ' ] = empty ($ this ->null ) ? '' : ' ' . $ this ->null ;
903+ $ field ['null ' ] = empty ($ this ->null ) ? '' : $ nullString ;
904+ } elseif ($ attributes ['NULL ' ] === $ nullString ) {
905+ $ field ['null ' ] = $ nullString ;
906+ } elseif ($ attributes ['NULL ' ] === '' ) {
907+ $ field ['null ' ] = '' ;
902908 } else {
903- $ field ['null ' ] = ' NOT NULL ' ;
909+ $ field ['null ' ] = ' NOT ' . $ this -> null ;
904910 }
905911 } elseif ($ createTable === true ) {
906- $ field ['null ' ] = ' NOT NULL ' ;
912+ $ field ['null ' ] = ' NOT ' . $ this -> null ;
907913 }
908914
909915 $ this ->_attributeAutoIncrement ($ attributes , $ field );
0 commit comments