@@ -153,7 +153,7 @@ class Forge
153
153
*
154
154
* @internal Used for marking nullable fields. Not covered by BC promise.
155
155
*/
156
- protected $ null = '' ;
156
+ protected $ null = 'NULL ' ;
157
157
158
158
/**
159
159
* DEFAULT value representation in CREATE/ALTER TABLE statements
@@ -562,7 +562,7 @@ public function createTable(string $table, bool $ifNotExists = false, array $att
562
562
}
563
563
564
564
/**
565
- * @return string
565
+ * @return string SQL string
566
566
*
567
567
* @deprecated $ifNotExists is no longer used, and will be removed.
568
568
*/
@@ -897,13 +897,19 @@ protected function _processFields(bool $createTable = false): array
897
897
$ this ->_attributeDefault ($ attributes , $ field );
898
898
899
899
if (isset ($ attributes ['NULL ' ])) {
900
+ $ nullString = ' ' . $ this ->null ;
901
+
900
902
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 ' ] = '' ;
902
908
} else {
903
- $ field ['null ' ] = ' NOT NULL ' ;
909
+ $ field ['null ' ] = ' NOT ' . $ this -> null ;
904
910
}
905
911
} elseif ($ createTable === true ) {
906
- $ field ['null ' ] = ' NOT NULL ' ;
912
+ $ field ['null ' ] = ' NOT ' . $ this -> null ;
907
913
}
908
914
909
915
$ this ->_attributeAutoIncrement ($ attributes , $ field );
0 commit comments