@@ -827,6 +827,41 @@ public function testAddColumn()
827
827
$ this ->assertSame ('username ' , $ fieldNames [1 ]);
828
828
}
829
829
830
+ public function testAddColumnNull ()
831
+ {
832
+ $ this ->forge ->dropTable ('forge_test_table ' , true );
833
+
834
+ $ this ->forge ->addField ([
835
+ 'col1 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 ],
836
+ 'col2 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 , 'null ' => true ],
837
+ 'col3 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 , 'null ' => false ],
838
+ ]);
839
+ $ this ->forge ->createTable ('forge_test_table ' );
840
+
841
+ $ this ->forge ->addColumn ('forge_test_table ' , [
842
+ 'col4 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 ],
843
+ 'col5 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 , 'null ' => true ],
844
+ 'col6 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 , 'null ' => false ],
845
+ ]);
846
+
847
+ $ this ->db ->resetDataCache ();
848
+
849
+ $ col1 = $ this ->getMetaData ('col1 ' , 'forge_test_table ' );
850
+ $ this ->assertFalse ($ col1 ->nullable );
851
+ $ col2 = $ this ->getMetaData ('col2 ' , 'forge_test_table ' );
852
+ $ this ->assertTrue ($ col2 ->nullable );
853
+ $ col3 = $ this ->getMetaData ('col3 ' , 'forge_test_table ' );
854
+ $ this ->assertFalse ($ col3 ->nullable );
855
+ $ col4 = $ this ->getMetaData ('col4 ' , 'forge_test_table ' );
856
+ $ this ->assertTrue ($ col4 ->nullable );
857
+ $ col5 = $ this ->getMetaData ('col5 ' , 'forge_test_table ' );
858
+ $ this ->assertTrue ($ col5 ->nullable );
859
+ $ col6 = $ this ->getMetaData ('col6 ' , 'forge_test_table ' );
860
+ $ this ->assertFalse ($ col6 ->nullable );
861
+
862
+ $ this ->forge ->dropTable ('forge_test_table ' , true );
863
+ }
864
+
830
865
public function testAddFields ()
831
866
{
832
867
$ tableName = 'forge_test_fields ' ;
0 commit comments