@@ -1277,7 +1277,7 @@ public function testModifyColumnRename()
12771277 $ this ->forge ->dropTable ('forge_test_three ' , true );
12781278 }
12791279
1280- public function testModifyColumnNull ()
1280+ public function testModifyColumnNullTrue ()
12811281 {
12821282 if ($ this ->db ->DBDriver === 'SQLSRV ' ) {
12831283 $ this ->markTestSkipped ('SQLSRV does not support getFieldData() nullable. ' );
@@ -1310,6 +1310,39 @@ public function testModifyColumnNull()
13101310 $ this ->forge ->dropTable ('forge_test_modify ' , true );
13111311 }
13121312
1313+ public function testModifyColumnNullFalse ()
1314+ {
1315+ if ($ this ->db ->DBDriver === 'SQLSRV ' ) {
1316+ $ this ->markTestSkipped ('SQLSRV does not support getFieldData() nullable. ' );
1317+ }
1318+
1319+ $ this ->forge ->dropTable ('forge_test_modify ' , true );
1320+
1321+ $ this ->forge ->addField ([
1322+ 'col1 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 , 'null ' => false ],
1323+ 'col2 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 , 'null ' => false ],
1324+ 'col3 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 255 , 'null ' => false ],
1325+ ]);
1326+ $ this ->forge ->createTable ('forge_test_modify ' );
1327+
1328+ $ this ->forge ->modifyColumn ('forge_test_modify ' , [
1329+ 'col1 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 1 ],
1330+ 'col2 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 1 , 'null ' => true ],
1331+ 'col3 ' => ['type ' => 'VARCHAR ' , 'constraint ' => 1 , 'null ' => false ],
1332+ ]);
1333+
1334+ $ this ->db ->resetDataCache ();
1335+
1336+ $ col1 = $ this ->getMetaData ('col1 ' , 'forge_test_modify ' );
1337+ $ this ->assertTrue ($ col1 ->nullable ); // Nullable if not specified.
1338+ $ col2 = $ this ->getMetaData ('col2 ' , 'forge_test_modify ' );
1339+ $ this ->assertTrue ($ col2 ->nullable );
1340+ $ col3 = $ this ->getMetaData ('col3 ' , 'forge_test_modify ' );
1341+ $ this ->assertFalse ($ col3 ->nullable );
1342+
1343+ $ this ->forge ->dropTable ('forge_test_modify ' , true );
1344+ }
1345+
13131346 private function getMetaData (string $ column , string $ table ): stdClass
13141347 {
13151348 $ fields = $ this ->db ->getFieldData ($ table );
0 commit comments