Skip to content

Commit 4dea493

Browse files
dev: supported specification tests for YdbDataReader (#259)
* Fix bug: GetValue(int ordinal) return DBNull.Value if fetched NULL value. * Fix: NextResult() moves to the next result and skip the first ResultSet. * Added specification DbDataReaderTests. * If dataOffset is larger than the length of data, GetChars and GetBytes methods will return 0. * If YdbDataReader is closed, `throw new InvalidOperationException("The reader is closed")`.
1 parent e8eb3f9 commit 4dea493

File tree

14 files changed

+680
-85
lines changed

14 files changed

+680
-85
lines changed

.github/scripts/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ then
88
exit 1;
99
fi;
1010

11-
LAST_TAG=$(git tag | tail -n 1);
11+
LAST_TAG=$(git tag --sort=-creatordate | head -n 1);
1212
MAJOR=$(echo $LAST_TAG | sed -E 's/v([0-9]+)\..*/\1/');
1313
MINOR=$(echo $LAST_TAG | sed -E 's/v[0-9]+\.([0-9]+)\..*/\1/');
1414
PATCH=$(echo $LAST_TAG | sed -E 's/v[0-9]+\.[0-9]+\.([0-9]+)($|-rc[0-9]+)/\1/');

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Fix bug: GetValue(int ordinal) return DBNull.Value if fetched NULL value.
2+
* Fix: NextResult() moves to the next result and skip the first ResultSet.
3+
* Added specification DbDataReaderTests.
4+
* If dataOffset is larger than the length of data, GetChars and GetBytes methods will return 0.
5+
* If YdbDataReader is closed: `throw new InvalidOperationException("The reader is closed")`.
16
* InvalidOperationException on ConnectionString property has not been initialized.
27
* One YdbTransaction per YdbConnection. Otherwise, throw an exception: InvalidOperationException("A transaction is already in progress; nested/concurrent transactions aren't supported.").
38
* ConnectionString returns an empty.String when it is not set.

src/Ydb.Sdk/src/Ado/ThrowHelper.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Ydb.Sdk.Value;
2+
3+
namespace Ydb.Sdk.Ado;
4+
5+
internal static class ThrowHelper
6+
{
7+
internal static T ThrowInvalidCast<T>(YdbValue ydbValue)
8+
{
9+
throw new InvalidCastException($"Field type {ydbValue.TypeId} can't be cast to {typeof(T)} type.");
10+
}
11+
12+
internal static void ThrowIndexOutOfRangeException(int columnCount)
13+
{
14+
throw new IndexOutOfRangeException("Ordinal must be between 0 and " + (columnCount - 1));
15+
}
16+
}

src/Ydb.Sdk/src/Ado/YdbCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ public override async Task<int> ExecuteNonQueryAsync(CancellationToken cancellat
5252
{
5353
await using var dataReader = await ExecuteReaderAsync(CommandBehavior.Default, cancellationToken);
5454

55-
var data = await dataReader.ReadAsync(cancellationToken)
56-
? dataReader.IsDBNull(0) ? null : dataReader.GetValue(0)
57-
: null;
55+
var data = await dataReader.ReadAsync(cancellationToken) ? dataReader.GetValue(0) : null;
5856

5957
while (await dataReader.NextResultAsync(cancellationToken))
6058
{

src/Ydb.Sdk/src/Ado/YdbConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public override string ConnectionString
173173

174174
internal YdbDataReader? LastReader { get; set; }
175175
internal string LastCommand { get; set; } = string.Empty;
176-
internal bool IsBusy => LastReader is { IsClosed: false };
176+
internal bool IsBusy => LastReader is { IsOpen: true };
177177
internal YdbTransaction? CurrentTransaction { get; private set; }
178178

179179
public override string DataSource => string.Empty; // TODO

0 commit comments

Comments
 (0)