@@ -4429,6 +4429,32 @@ public function testNonStrictModeWithOnDuplicateKeyUpdate(): void {
44294429 $ this ->assertSame ( 'red ' , $ result [0 ]->color );
44304430 }
44314431
4432+ public function testNonStrictModeWithReplaceStatement (): void {
4433+ $ this ->assertQuery ( "SET SESSION sql_mode = '' " );
4434+
4435+ // From VALUES() statement:
4436+ $ this ->assertQuery ( 'CREATE TABLE t1 (id INT PRIMARY KEY, name TEXT NOT NULL, size INT DEFAULT 123, color TEXT) ' );
4437+ $ this ->assertQuery ( "REPLACE INTO t1 VALUES (1, 'A', 10, 'red') " );
4438+ $ this ->assertQuery ( "REPLACE INTO t1 (color, id) VALUES ('blue', 1) " );
4439+ $ result = $ this ->assertQuery ( 'SELECT * FROM t1 ' );
4440+ $ this ->assertCount ( 1 , $ result );
4441+ $ this ->assertSame ( '1 ' , $ result [0 ]->id );
4442+ $ this ->assertSame ( '' , $ result [0 ]->name ); // implicit default
4443+ $ this ->assertSame ( '123 ' , $ result [0 ]->size );
4444+ $ this ->assertSame ( 'blue ' , $ result [0 ]->color );
4445+
4446+ // From SELECT statement:
4447+ $ this ->assertQuery ( 'CREATE TABLE t2 (id INT PRIMARY KEY, name TEXT NOT NULL, size INT DEFAULT 999, color TEXT) ' );
4448+ $ this ->assertQuery ( "REPLACE INTO t2 VALUES (1, 'A', 10, 'red') " );
4449+ $ this ->assertQuery ( 'REPLACE INTO t2 (color, id, size) SELECT color, id, size FROM t1 ' );
4450+ $ result = $ this ->assertQuery ( 'SELECT * FROM t2 ' );
4451+ $ this ->assertCount ( 1 , $ result );
4452+ $ this ->assertSame ( '1 ' , $ result [0 ]->id );
4453+ $ this ->assertSame ( '' , $ result [0 ]->name ); // implicit default
4454+ $ this ->assertSame ( '123 ' , $ result [0 ]->size );
4455+ $ this ->assertSame ( 'blue ' , $ result [0 ]->color );
4456+ }
4457+
44324458 public function testSessionSqlModes (): void {
44334459 // Syntax: "sql_mode" ("@@sql_mode" for SELECT)
44344460 $ this ->assertQuery ( 'SET sql_mode = "ERROR_FOR_DIVISION_BY_ZERO" ' );
0 commit comments