@@ -10239,6 +10239,34 @@ public function testCastValuesOnInsert(): void {
1023910239 $ this ->assertSame ( '2025-10-23 18:30:00 ' , $ result [2 ]->value );
1024010240 $ this ->assertSame ( '2025-10-23 18:30:00 ' , $ result [3 ]->value );
1024110241 $ this ->assertQuery ( 'DROP TABLE t ' );
10242+
10243+ // YEAR
10244+ $ this ->assertQuery ( 'CREATE TABLE t (value YEAR) ' );
10245+ $ this ->assertQuery ( 'INSERT INTO t VALUES (NULL) ' );
10246+ $ this ->assertQuery ( 'INSERT INTO t VALUES (FALSE) ' );
10247+ $ this ->assertQuery ( 'INSERT INTO t VALUES (TRUE) ' );
10248+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025') " );
10249+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23') " );
10250+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23 18:30:00') " );
10251+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23 18:30:00.123456') " );
10252+ $ this ->assertQuery ( 'INSERT INTO t VALUES (1) ' );
10253+ $ this ->assertQuery ( 'INSERT INTO t VALUES (50) ' );
10254+ $ this ->assertQuery ( 'INSERT INTO t VALUES (70) ' );
10255+ $ this ->assertQuery ( 'INSERT INTO t VALUES (99) ' );
10256+
10257+ $ result = $ this ->assertQuery ( 'SELECT * FROM t ' );
10258+ $ this ->assertSame ( null , $ result [0 ]->value );
10259+ $ this ->assertSame ( '0000 ' , $ result [1 ]->value );
10260+ $ this ->assertSame ( '2001 ' , $ result [2 ]->value );
10261+ $ this ->assertSame ( '2025 ' , $ result [3 ]->value );
10262+ $ this ->assertSame ( '2025 ' , $ result [4 ]->value );
10263+ $ this ->assertSame ( '2025 ' , $ result [5 ]->value );
10264+ $ this ->assertSame ( '2025 ' , $ result [6 ]->value );
10265+ $ this ->assertSame ( '2001 ' , $ result [7 ]->value );
10266+ $ this ->assertSame ( '2050 ' , $ result [8 ]->value );
10267+ $ this ->assertSame ( '1970 ' , $ result [9 ]->value );
10268+ $ this ->assertSame ( '1999 ' , $ result [10 ]->value );
10269+ $ this ->assertQuery ( 'DROP TABLE t ' );
1024210270 }
1024310271
1024410272 public function testCastValuesOnInsertInNonStrictMode (): void {
@@ -10425,5 +10453,33 @@ public function testCastValuesOnInsertInNonStrictMode(): void {
1042510453 $ this ->assertSame ( '2025-10-23 18:30:00 ' , $ result [5 ]->value );
1042610454 $ this ->assertSame ( '2025-10-23 18:30:00 ' , $ result [6 ]->value );
1042710455 $ this ->assertQuery ( 'DROP TABLE t ' );
10456+
10457+ // YEAR
10458+ $ this ->assertQuery ( 'CREATE TABLE t (value YEAR) ' );
10459+ $ this ->assertQuery ( 'INSERT INTO t VALUES (NULL) ' );
10460+ $ this ->assertQuery ( 'INSERT INTO t VALUES (FALSE) ' );
10461+ $ this ->assertQuery ( 'INSERT INTO t VALUES (TRUE) ' );
10462+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025') " );
10463+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23') " );
10464+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23 18:30:00') " );
10465+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23 18:30:00.123456') " );
10466+ $ this ->assertQuery ( 'INSERT INTO t VALUES (1) ' );
10467+ $ this ->assertQuery ( 'INSERT INTO t VALUES (50) ' );
10468+ $ this ->assertQuery ( 'INSERT INTO t VALUES (70) ' );
10469+ $ this ->assertQuery ( 'INSERT INTO t VALUES (99) ' );
10470+
10471+ $ result = $ this ->assertQuery ( 'SELECT * FROM t ' );
10472+ $ this ->assertSame ( null , $ result [0 ]->value );
10473+ $ this ->assertSame ( '0000 ' , $ result [1 ]->value );
10474+ $ this ->assertSame ( '2001 ' , $ result [2 ]->value );
10475+ $ this ->assertSame ( '2025 ' , $ result [3 ]->value );
10476+ $ this ->assertSame ( '2025 ' , $ result [4 ]->value );
10477+ $ this ->assertSame ( '2025 ' , $ result [5 ]->value );
10478+ $ this ->assertSame ( '2025 ' , $ result [6 ]->value );
10479+ $ this ->assertSame ( '2001 ' , $ result [7 ]->value );
10480+ $ this ->assertSame ( '2050 ' , $ result [8 ]->value );
10481+ $ this ->assertSame ( '1970 ' , $ result [9 ]->value );
10482+ $ this ->assertSame ( '1999 ' , $ result [10 ]->value );
10483+ $ this ->assertQuery ( 'DROP TABLE t ' );
1042810484 }
1042910485}
0 commit comments