File tree 3 files changed +29
-0
lines changed
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
147
147
case DataType::BIT :
148
148
case DataType::MEDIUMINT :
149
149
case DataType::BIGINT :
150
+ if ($ stmt ->null === null ) {
151
+ $ stmt ->null = true ;
152
+ }
153
+
150
154
return self ::getIntegerDefinitionColumn ($ stmt );
151
155
152
156
case DataType::FLOAT :
Original file line number Diff line number Diff line change @@ -983,6 +983,30 @@ public function testDropTable(string $table): void
983
983
);
984
984
}
985
985
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
+
986
1010
private static function getPdo (string $ connection_string , bool $ strict_mode = false ) : \PDO
987
1011
{
988
1012
$ 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` (
10
10
` powerups` tinyint (3 ) UNSIGNED NOT NULL DEFAULT ' 0' ,
11
11
` skills` varchar (1000 ) NOT NULL DEFAULT ' ' ,
12
12
` nullable_field` tinyint (3 ) DEFAULT NULL ,
13
+ ` nullable_field_default_0` tinyint (3 ) DEFAULT ' 0' ,
13
14
` some_float` float DEFAULT ' 0.00' ,
14
15
` total_games` int (11 ) UNSIGNED NOT NULL DEFAULT ' 0' ,
15
16
` lives` int (11 ) UNSIGNED NOT NULL DEFAULT ' 0' ,
You can’t perform that action at this time.
0 commit comments