@@ -4298,6 +4298,68 @@ public function testNonStrictSqlModeNotNullWithDefault(): void {
4298
4298
$ this ->assertSame ( '' , $ result [0 ]->value );
4299
4299
}
4300
4300
4301
+ public function testNoStrictSqlModeWithNoListedColumns (): void {
4302
+ $ this ->assertQuery ( "SET SESSION sql_mode = '' " );
4303
+
4304
+ // From VALUES() statement:
4305
+ $ this ->assertQuery ( 'CREATE TABLE t1 (id INT, name TEXT NOT NULL, size INT DEFAULT 1, color TEXT) ' );
4306
+ $ this ->assertQuery ( "INSERT INTO t1 VALUES (1, 'A', 10, 'red') " );
4307
+ $ this ->assertQuery ( "INSERT INTO t1 VALUES (1, 'B', NULL, NULL) " );
4308
+ $ result = $ this ->assertQuery ( 'SELECT * FROM t1 ' );
4309
+ $ this ->assertCount ( 2 , $ result );
4310
+ $ this ->assertSame ( 'A ' , $ result [0 ]->name );
4311
+ $ this ->assertSame ( '10 ' , $ result [0 ]->size );
4312
+ $ this ->assertSame ( 'red ' , $ result [0 ]->color );
4313
+ $ this ->assertSame ( 'B ' , $ result [1 ]->name );
4314
+ $ this ->assertNull ( $ result [1 ]->size );
4315
+ $ this ->assertNull ( $ result [1 ]->color );
4316
+
4317
+ // From SELECT statement:
4318
+ $ this ->assertQuery ( 'CREATE TABLE t2 (id INT, name TEXT NOT NULL, size INT DEFAULT 1, color TEXT) ' );
4319
+ $ this ->assertQuery ( 'INSERT INTO t2 SELECT * FROM t1 ' );
4320
+ $ result = $ this ->assertQuery ( 'SELECT * FROM t2 ' );
4321
+ $ this ->assertCount ( 2 , $ result );
4322
+ $ this ->assertSame ( 'A ' , $ result [0 ]->name );
4323
+ $ this ->assertSame ( '10 ' , $ result [0 ]->size );
4324
+ $ this ->assertSame ( 'red ' , $ result [0 ]->color );
4325
+ $ this ->assertSame ( 'B ' , $ result [1 ]->name );
4326
+ $ this ->assertNull ( $ result [1 ]->size );
4327
+ $ this ->assertNull ( $ result [1 ]->color );
4328
+ }
4329
+
4330
+ public function testNoStrictSqlModeWithReorderedColumns (): void {
4331
+ $ this ->assertQuery ( "SET SESSION sql_mode = '' " );
4332
+
4333
+ // From VALUES() statement:
4334
+ $ this ->assertQuery ( 'CREATE TABLE t1 (id INT, name TEXT NOT NULL, size INT DEFAULT 1, color TEXT) ' );
4335
+ $ this ->assertQuery ( "INSERT INTO t1 (name, color, id, size) VALUES ('A', 'red', 1, 10) " );
4336
+ $ this ->assertQuery ( "INSERT INTO t1 (name, id) VALUES ('A', 1) " );
4337
+ $ result = $ this ->assertQuery ( 'SELECT * FROM t1 ' );
4338
+ $ this ->assertCount ( 2 , $ result );
4339
+ $ this ->assertSame ( '1 ' , $ result [0 ]->id );
4340
+ $ this ->assertSame ( 'A ' , $ result [0 ]->name );
4341
+ $ this ->assertSame ( '10 ' , $ result [0 ]->size );
4342
+ $ this ->assertSame ( 'red ' , $ result [0 ]->color );
4343
+ $ this ->assertSame ( '1 ' , $ result [1 ]->id );
4344
+ $ this ->assertSame ( 'A ' , $ result [1 ]->name );
4345
+ $ this ->assertSame ( '1 ' , $ result [1 ]->size );
4346
+ $ this ->assertNull ( $ result [1 ]->color );
4347
+
4348
+ // From SELECT statement:
4349
+ $ this ->assertQuery ( 'CREATE TABLE t2 (id INT, name TEXT NOT NULL, size INT DEFAULT 1, color TEXT) ' );
4350
+ $ this ->assertQuery ( 'INSERT INTO t2 (name, color, id, size) SELECT name, color, id, size FROM t1 ' );
4351
+ $ result = $ this ->assertQuery ( 'SELECT * FROM t2 ' );
4352
+ $ this ->assertCount ( 2 , $ result );
4353
+ $ this ->assertSame ( '1 ' , $ result [0 ]->id );
4354
+ $ this ->assertSame ( 'A ' , $ result [0 ]->name );
4355
+ $ this ->assertSame ( '10 ' , $ result [0 ]->size );
4356
+ $ this ->assertSame ( 'red ' , $ result [0 ]->color );
4357
+ $ this ->assertSame ( '1 ' , $ result [1 ]->id );
4358
+ $ this ->assertSame ( 'A ' , $ result [1 ]->name );
4359
+ $ this ->assertSame ( '1 ' , $ result [1 ]->size );
4360
+ $ this ->assertNull ( $ result [1 ]->color );
4361
+ }
4362
+
4301
4363
public function testSessionSqlModes (): void {
4302
4364
// Syntax: "sql_mode" ("@@sql_mode" for SELECT)
4303
4365
$ this ->assertQuery ( 'SET sql_mode = "ERROR_FOR_DIVISION_BY_ZERO" ' );
0 commit comments