Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.0.0-beta1
Description
The following test fails:
[Test] public async Task TestPutGetNullable() { await Client.Sql.ExecuteAsync(null, "CREATE TABLE TestPutGetNullable (ID BIGINT PRIMARY KEY, VAL BIGINT)"); await Client.Sql.ExecuteAsync(null, "INSERT INTO TestPutGetNullable VALUES (1, 1), (2, NULL)"); var table = await Client.Tables.GetTableAsync("TestPutGetNullable"); var view = table!.GetKeyValueView<long, long>(); var res1 = await view.GetAsync(null, 1); var res2 = await view.GetAsync(null, 2); }
Result:
System.InvalidOperationException : Binary tuple element with index 1 is null. at Apache.Ignite.Internal.Proto.BinaryTuple.BinaryTupleReader.ThrowNullElementException[T](Int32 index) in /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/BinaryTuple/BinaryTupleReader.cs:line 572 at Apache.Ignite.Internal.Proto.BinaryTuple.BinaryTupleReader.GetLong(Int32 index) in /home/pavel/w/ignite-3/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/BinaryTuple/BinaryTupleReader.cs:line 155 at ReadApache.Ignite.Internal.Table.Serialization.KvPair`2[System.Int64,System.Int64](BinaryTupleReader& ) at Apache.Ignite.Internal.Table.Serialization.ObjectSerializerHandler`1.Read(MsgPackReader& reader, Schema schema, Boolean keyOnly) at Apache.Ignite.Internal.Table.Serialization.RecordSerializer`1.ReadValue(PooledBuffer buf, Schema schema) at Apache.Ignite.Internal.Table.RecordView`1.GetAsync(ITransaction transaction, T key) at Apache.Ignite.Internal.Table.KeyValueView`2.GetAsync(ITransaction transaction, TK key) at Apache.Ignite.Tests.Table.KeyValueViewPrimitiveTests.TestPutGetNullable()
ITable.GetKeyValueView does not allow nullable types ("where TV : notnull") - so we don't have a way to work with nullable columns in this case.
See how Java handles this with additional nullable methods: IGNITE-16115
Option<T> can represent 3 states to handle this situation:
- hasValue=true, value != null
- hasValue=true, value = null
- hasValue=false
Attachments
Issue Links
- is related to
-
IGNITE-16115 Implement getNullable and getOrDefault operations.
- Resolved
- links to