-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Report
YDB dotnet SDK version:
0.16.2
Current behavior:
When LINQ to DB sends a query that contains a DateOnly value mapped to DataType.Date, the YDB ADO-provider throws an InvalidOperationException inside YdbParameter.get_YdbValue()
Expected behavior:
DateOnly should be transparently converted to a valid YDB Date value (e.g., DateTime at 00:00:00) and the query should execute without errors.
Steps to reproduce:
- Add scalar-type mapping:
AddScalarType(typeof(DateOnly), DataType.Date);
- Execute a simple LINQ query (or raw command) with a parameter:
var x = new DateOnly(2020, 2, 29);
var rows = db.GetTable<MyEntity>()
.Where(t => t.StartDate == x) // StartDate mapped to YDB Date
.ToArray(); // boom 💥
- Provider builds the command
DECLARE @$value -- Date
SET @$value = Date("2020-02-29")
…
- As soon as the command executes, exception above is thrown.
Stack trace:
DataConnection: Error
Exception: System.InvalidOperationException
Message : Writing value of 'System.DateOnly' is not supported for parameters having DbType 'Date'
at Ydb.Sdk.Ado.YdbParameter.ThrowInvalidOperation()
at Ydb.Sdk.Ado.YdbParameter.get_YdbValue()
at Ydb.Sdk.Ado.YdbParameterCollection.<>c.<get_YdbParameters>b__3_1(YdbParameter p)
at System.Linq.Enumerable.SpanToDictionary[TSource,TKey,TElement](ReadOnlySpan`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
at Ydb.Sdk.Ado.YdbParameterCollection.get_YdbParameters()
at Ydb.Sdk.Ado.YdbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
at Ydb.Sdk.Ado.YdbCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
at Ydb.Sdk.Ado.YdbCommand.ExecuteDbDataReader(CommandBehavior behavior)
at LinqToDB.Data.DataConnection.ExecuteReader(CommandBehavior commandBehavior) in linq2db\Source\LinqToDB\Data\DataConnection.cs:line 1386
at LinqToDB.Data.DataConnection.ExecuteDataReader(CommandBehavior commandBehavior) in linq2db\Source\LinqToDB\Data\DataConnection.cs:line 1430
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working