File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,10 @@ private static function getDefinitionColumn(Query\MysqlColumnType $stmt) : Colum
147147 case DataType::BIT :
148148 case DataType::MEDIUMINT :
149149 case DataType::BIGINT :
150+ if ($ stmt ->null === null ) {
151+ $ stmt ->null = true ;
152+ }
153+
150154 return self ::getIntegerDefinitionColumn ($ stmt );
151155
152156 case DataType::FLOAT :
Original file line number Diff line number Diff line change @@ -983,6 +983,30 @@ public function testDropTable(string $table): void
983983 );
984984 }
985985
986+ public function testSelectNullableFields ()
987+ {
988+ $ pdo = self ::getConnectionToFullDB (false );
989+
990+ $ query = $ pdo ->prepare ("SELECT nullable_field, nullable_field_default_0 FROM `video_game_characters` WHERE `id` = 1 " );
991+ $ query ->execute ();
992+
993+ $ this ->assertSame (
994+ ['nullable_field ' => null , 'nullable_field_default_0 ' => 0 ],
995+ $ query ->fetch (\PDO ::FETCH_ASSOC )
996+ );
997+
998+ $ query = $ pdo ->prepare ("UPDATE `video_game_characters` SET `nullable_field_default_0` = NULL, `nullable_field` = NULL WHERE `id` = 1 " );
999+ $ query ->execute ();
1000+
1001+ $ query = $ pdo ->prepare ("SELECT nullable_field, nullable_field_default_0 FROM `video_game_characters` WHERE `id` = 1 " );
1002+ $ query ->execute ();
1003+
1004+ $ this ->assertSame (
1005+ ['nullable_field ' => null , 'nullable_field_default_0 ' => null ],
1006+ $ query ->fetch (\PDO ::FETCH_ASSOC )
1007+ );
1008+ }
1009+
9861010 private static function getPdo (string $ connection_string , bool $ strict_mode = false ) : \PDO
9871011 {
9881012 $ options = $ strict_mode ? [\PDO ::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="STRICT_ALL_TABLES" ' ] : [];
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ CREATE TABLE `video_game_characters` (
1010 ` powerups` tinyint (3 ) UNSIGNED NOT NULL DEFAULT ' 0' ,
1111 ` skills` varchar (1000 ) NOT NULL DEFAULT ' ' ,
1212 ` nullable_field` tinyint (3 ) DEFAULT NULL ,
13+ ` nullable_field_default_0` tinyint (3 ) DEFAULT ' 0' ,
1314 ` some_float` float DEFAULT ' 0.00' ,
1415 ` total_games` int (11 ) UNSIGNED NOT NULL DEFAULT ' 0' ,
1516 ` lives` int (11 ) UNSIGNED NOT NULL DEFAULT ' 0' ,
You can’t perform that action at this time.
0 commit comments