Skip to content

Commit ab65d39

Browse files
more fixes
1 parent d547c25 commit ab65d39

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/Ydb.Sdk/src/Ado/YdbDataReader.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -402,18 +402,13 @@ public override object GetValue(int ordinal)
402402
var type = GetColumnType(ordinal);
403403
var ydbValue = CurrentRow[ordinal];
404404

405-
if (type.IsNull())
405+
if (ydbValue.IsNull())
406406
{
407407
return DBNull.Value;
408408
}
409409

410410
if (type.IsOptional())
411411
{
412-
if (ydbValue.IsNull())
413-
{
414-
return DBNull.Value;
415-
}
416-
417412
type = type.OptionalType.Item;
418413
}
419414

@@ -578,16 +573,10 @@ private Type UnwrapColumnType(int ordinal)
578573
{
579574
var type = GetColumnType(ordinal);
580575

581-
if (type.IsNull())
582-
throw new InvalidCastException("Field is null.");
583-
584-
if (!type.IsOptional())
585-
return type;
586-
587576
if (CurrentRow[ordinal].IsNull())
588577
throw new InvalidCastException("Field is null.");
589578

590-
return type.OptionalType.Item;
579+
return type.IsOptional() ? type.OptionalType.Item : type;
591580
}
592581

593582
private Type GetColumnType(int ordinal) => ReaderMetadata.GetColumn(ordinal).Type;

0 commit comments

Comments
 (0)