When ALLOW_INVALID_DATES is enabled on the MySQL Server, "invalid" dates such as 2018-02-31 may be stored in a DATE column.
Calling MySqlDataReader.GetValue for a column containing an invalid date will throw the following exception:
ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.
at System.DateTime.DateToTicks(Int32 year, Int32 month, Int32 day)
at System.DateTime..ctor(Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond, DateTimeKind kind)
at MySqlConnector.Core.Row.ParseDateTime(ReadOnlySpan`1 value)
at MySqlConnector.Core.Row.GetValue(Int32 ordinal)
at MySql.Data.MySqlClient.MySqlDataReader.GetValue(Int32 ordinal)
In Connector/NET, if you enable AllowZeroDateTime=true in the connection string, all DATE columns are returned as MySqlDateTime objects, which can represent this unrepresentable DateTime. In MySqlConnector, the DateTime constructor is always used (even with AllowZeroDateTime=true) which throws this exception.
This is possibly the cause of #527.
When
ALLOW_INVALID_DATESis enabled on the MySQL Server, "invalid" dates such as2018-02-31may be stored in aDATEcolumn.Calling
MySqlDataReader.GetValuefor a column containing an invalid date will throw the following exception:In Connector/NET, if you enable
AllowZeroDateTime=truein the connection string, allDATEcolumns are returned asMySqlDateTimeobjects, which can represent this unrepresentableDateTime. In MySqlConnector, theDateTimeconstructor is always used (even withAllowZeroDateTime=true) which throws this exception.This is possibly the cause of #527.