@@ -10239,6 +10239,37 @@ 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+ $ this ->assertQueryError ( 'INSERT INTO t VALUES (-1) ' , "Out of range value: '-1' " );
10257+ $ this ->assertQueryError ( 'INSERT INTO t VALUES (1900) ' , "Out of range value: '1900' " );
10258+ $ this ->assertQueryError ( 'INSERT INTO t VALUES (2156) ' , "Out of range value: '2156' " );
10259+
10260+ $ result = $ this ->assertQuery ( 'SELECT * FROM t ' );
10261+ $ this ->assertSame ( null , $ result [0 ]->value );
10262+ $ this ->assertSame ( '0000 ' , $ result [1 ]->value );
10263+ $ this ->assertSame ( '2001 ' , $ result [2 ]->value );
10264+ $ this ->assertSame ( '2025 ' , $ result [3 ]->value );
10265+ $ this ->assertSame ( '2025 ' , $ result [4 ]->value );
10266+ $ this ->assertSame ( '2025 ' , $ result [5 ]->value );
10267+ $ this ->assertSame ( '2025 ' , $ result [6 ]->value );
10268+ $ this ->assertSame ( '2001 ' , $ result [7 ]->value );
10269+ $ this ->assertSame ( '2050 ' , $ result [8 ]->value );
10270+ $ this ->assertSame ( '1970 ' , $ result [9 ]->value );
10271+ $ this ->assertSame ( '1999 ' , $ result [10 ]->value );
10272+ $ this ->assertQuery ( 'DROP TABLE t ' );
1024210273 }
1024310274
1024410275 public function testCastValuesOnInsertInNonStrictMode (): void {
@@ -10425,5 +10456,39 @@ public function testCastValuesOnInsertInNonStrictMode(): void {
1042510456 $ this ->assertSame ( '2025-10-23 18:30:00 ' , $ result [5 ]->value );
1042610457 $ this ->assertSame ( '2025-10-23 18:30:00 ' , $ result [6 ]->value );
1042710458 $ this ->assertQuery ( 'DROP TABLE t ' );
10459+
10460+ // YEAR
10461+ $ this ->assertQuery ( 'CREATE TABLE t (value YEAR) ' );
10462+ $ this ->assertQuery ( 'INSERT INTO t VALUES (NULL) ' );
10463+ $ this ->assertQuery ( 'INSERT INTO t VALUES (FALSE) ' );
10464+ $ this ->assertQuery ( 'INSERT INTO t VALUES (TRUE) ' );
10465+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025') " );
10466+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23') " );
10467+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23 18:30:00') " );
10468+ $ this ->assertQuery ( "INSERT INTO t VALUES ('2025-10-23 18:30:00.123456') " );
10469+ $ this ->assertQuery ( 'INSERT INTO t VALUES (1) ' );
10470+ $ this ->assertQuery ( 'INSERT INTO t VALUES (50) ' );
10471+ $ this ->assertQuery ( 'INSERT INTO t VALUES (70) ' );
10472+ $ this ->assertQuery ( 'INSERT INTO t VALUES (99) ' );
10473+ $ this ->assertQuery ( 'INSERT INTO t VALUES (-1) ' );
10474+ $ this ->assertQuery ( 'INSERT INTO t VALUES (1900) ' );
10475+ $ this ->assertQuery ( 'INSERT INTO t VALUES (2156) ' );
10476+
10477+ $ result = $ this ->assertQuery ( 'SELECT * FROM t ' );
10478+ $ this ->assertSame ( null , $ result [0 ]->value );
10479+ $ this ->assertSame ( '0000 ' , $ result [1 ]->value );
10480+ $ this ->assertSame ( '2001 ' , $ result [2 ]->value );
10481+ $ this ->assertSame ( '2025 ' , $ result [3 ]->value );
10482+ $ this ->assertSame ( '2025 ' , $ result [4 ]->value );
10483+ $ this ->assertSame ( '2025 ' , $ result [5 ]->value );
10484+ $ this ->assertSame ( '2025 ' , $ result [6 ]->value );
10485+ $ this ->assertSame ( '2001 ' , $ result [7 ]->value );
10486+ $ this ->assertSame ( '2050 ' , $ result [8 ]->value );
10487+ $ this ->assertSame ( '1970 ' , $ result [9 ]->value );
10488+ $ this ->assertSame ( '1999 ' , $ result [10 ]->value );
10489+ $ this ->assertSame ( '0000 ' , $ result [11 ]->value );
10490+ $ this ->assertSame ( '0000 ' , $ result [12 ]->value );
10491+ $ this ->assertSame ( '0000 ' , $ result [13 ]->value );
10492+ $ this ->assertQuery ( 'DROP TABLE t ' );
1042810493 }
1042910494}
0 commit comments