@@ -930,22 +930,22 @@ public void InsertLargeBlobSync(string column, int size)
930
930
}
931
931
932
932
[ 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 )
942
942
{
943
943
var csb = CreateConnectionStringBuilder ( ) ;
944
944
csb . AllowZeroDateTime = allowZeroDateTime ;
945
945
using ( var connection = new MySqlConnection ( csb . ConnectionString ) )
946
946
{
947
947
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 ) )
949
949
{
950
950
cmd . Prepare ( ) ;
951
951
using ( var reader = cmd . ExecuteReader ( ) )
@@ -957,6 +957,13 @@ public void AllowZeroDateTime(bool allowZeroDateTime, string columnName, Type ex
957
957
var dt = reader . GetSchemaTable ( ) ;
958
958
Assert . Equal ( expectedType , dt . Rows [ 0 ] [ "DataType" ] ) ;
959
959
#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
+ }
960
967
}
961
968
}
962
969
}
0 commit comments