Date/Date32/DateTime/DateTime64 min value read as 0001-01-01
CREATE TABLE IF NOT EXISTS TypeTable
(
Id Int32 NOT NULL,
Column Date32 NOT NULL,
)
ENGINE = Memory()
INSERT INTO TypeTable
(
Id,
Column
)
VALUES
(toInt32(1),toDate32('1925-01-01'))
Data reader's GetValue/GetDate method returns default value 0001-01-01 instead of actual value from table.
Works fine for max-value (2283-11-11) or 1925-01-02.
Actually, same issue for Date and 1970-01-01 value
DateTime affected too. Not tested DateTime64 yet, but probably also affected.
DateTime64 also returns 0001-01-01 for 1970-01-01
Values prior to this date result in exception #62
I don't get DateTime.MinValue value while fetching DateTime64 fields with value less than 1970-01-01, but I get exception:
Octonica.ClickHouseClient.Exceptions.ClickHouseHandledException
The value must be in range [1970-01-01T00:00:00.0000000+00:00, 9999-12-31T23:59:59.9999999+00:00].
CREATE TABLE IF NOT EXISTS TypeTable
(
Id Int32,
Column DateTime64
)
ENGINE = Memory();
INSERT INTO TypeTable (Id, Column) VALUES (1, toDateTime64('1925-01-01', 3));
Fetching code:
public class TypeTable
{
int Id { get; set; }
DateTimeOffset Column { get; set; }
}
var result = await _connection.QueryFirstOrDefaultAsync<TypeTable>("SELECT * FROM TypeTable");
Also there is a problem with filtering by DateTime64 values:
var result = await _connection.QueryFirstOrDefaultAsync<TypeTable>(
new CommandDefinition(
"SELECT * FROM TypeTable WHERE Column > {DateTimeFilter:DateTime64}",
new Dictionary<string, object>
{
{ "DateTimeFilter", new DateTimeOffset(1930, 1, 1, 1, 1, 1, TimeSpan.Zero) }
}
)
);
Exception:
Octonica.ClickHouseClient.Exceptions.ClickHouseHandledException
The value must be in range [1970-01-01 00:00:00, 2105-12-31 23:59:59].