@@ -930,22 +930,22 @@ public void InsertLargeBlobSync(string column, int size)
930930 }
931931
932932 [ Theory ]
933- [ InlineData ( false , "Date" , typeof ( DateTime ) ) ]
934- [ InlineData ( true , "Date" , typeof ( MySqlDateTime ) ) ]
935- [ InlineData ( false , "DateTime" , typeof ( DateTime ) ) ]
936- [ InlineData ( true , "DateTime" , typeof ( MySqlDateTime ) ) ]
937- [ InlineData ( false , "TimeStamp" , typeof ( DateTime ) ) ]
938- [ InlineData ( true , "TimeStamp" , typeof ( MySqlDateTime ) ) ]
939- [ InlineData ( false , "Time" , typeof ( TimeSpan ) ) ]
940- [ InlineData ( true , "Time" , typeof ( TimeSpan ) ) ]
941- public void AllowZeroDateTime ( bool allowZeroDateTime , string columnName , Type expectedType )
933+ [ InlineData ( false , "Date" , typeof ( DateTime ) , "1000 01 01" ) ]
934+ [ InlineData ( true , "Date" , typeof ( MySqlDateTime ) , "1000 01 01" ) ]
935+ [ InlineData ( false , "DateTime" , typeof ( DateTime ) , "1000 01 01" ) ]
936+ [ InlineData ( true , "DateTime" , typeof ( MySqlDateTime ) , "1000 01 01" ) ]
937+ [ InlineData ( false , "TimeStamp" , typeof ( DateTime ) , "1970 01 01 0 0 1" ) ]
938+ [ InlineData ( true , "TimeStamp" , typeof ( MySqlDateTime ) , "1970 01 01 0 0 1" ) ]
939+ [ InlineData ( false , "Time" , typeof ( TimeSpan ) , null ) ]
940+ [ InlineData ( true , "Time" , typeof ( TimeSpan ) , null ) ]
941+ public void AllowZeroDateTime ( bool allowZeroDateTime , string columnName , Type expectedType , string expectedDateTime )
942942 {
943943 var csb = CreateConnectionStringBuilder ( ) ;
944944 csb . AllowZeroDateTime = allowZeroDateTime ;
945945 using ( var connection = new MySqlConnection ( csb . ConnectionString ) )
946946 {
947947 connection . Open ( ) ;
948- using ( var cmd = new MySqlCommand ( $ "SELECT `{ columnName } ` FROM datatypes_times WHERE `{ columnName } ` IS NOT NULL", connection ) )
948+ using ( var cmd = new MySqlCommand ( $ "SELECT `{ columnName } ` FROM datatypes_times WHERE `{ columnName } ` IS NOT NULL ORDER BY rowid ", connection ) )
949949 {
950950 cmd . Prepare ( ) ;
951951 using ( var reader = cmd . ExecuteReader ( ) )
@@ -957,6 +957,13 @@ public void AllowZeroDateTime(bool allowZeroDateTime, string columnName, Type ex
957957 var dt = reader . GetSchemaTable ( ) ;
958958 Assert . Equal ( expectedType , dt . Rows [ 0 ] [ "DataType" ] ) ;
959959#endif
960+
961+ if ( expectedDateTime != null )
962+ {
963+ var expected = ( DateTime ) ConvertToDateTime ( new object [ ] { expectedDateTime } , DateTimeKind . Unspecified ) [ 0 ] ;
964+ Assert . Equal ( expected , reader . GetDateTime ( 0 ) ) ;
965+ Assert . Equal ( new MySqlDateTime ( expected ) , reader . GetMySqlDateTime ( 0 ) ) ;
966+ }
960967 }
961968 }
962969 }
0 commit comments