Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillKurdyukov committed Sep 5, 2024
1 parent f4a2baf commit 483bae2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/Ydb.Sdk/src/Ado/YdbParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Data;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using Google.Protobuf.WellKnownTypes;
using Ydb.Sdk.Value;
using static System.String;

namespace Ydb.Sdk.Ado;

Expand Down Expand Up @@ -35,7 +35,7 @@ public sealed class YdbParameter : DbParameter
{ DbType.Currency, YdbValue.MakeOptionalDecimal() }
};

private string _parameterName = Empty;
private string _parameterName = string.Empty;

public YdbParameter()
{
Expand Down Expand Up @@ -72,7 +72,7 @@ public override string ParameterName
set => _parameterName = value ?? throw new YdbException("ParameterName must not be null!");
}

[AllowNull] [DefaultValue("")] public override string SourceColumn { get; set; } = Empty;
[AllowNull] [DefaultValue("")] public override string SourceColumn { get; set; } = String.Empty;
public override object? Value { get; set; }
public override bool SourceColumnNullMapping { get; set; }
public override int Size { get; set; }
Expand Down
39 changes: 31 additions & 8 deletions src/Ydb.Sdk/tests/Ado/YdbConnectionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Data;
using Xunit;
using Ydb.Sdk.Ado;
using Ydb.Sdk.Value;

namespace Ydb.Sdk.Tests.Ado;

Expand Down Expand Up @@ -174,17 +175,39 @@ INSERT INTO {tableName}
uint8_column, uint16_column, uint32_column, uint64_column, text_column, binary_column, json_column,
jsondocument_column, date_column, datetime_column, timestamp_column, interval_column) VALUES
($name1, $name2, $name3, $name4, $name5, $name6, $name7, $name8, $name9, $name10, $name11, $name12, $name13, $name14,
$name14, $name15, $name16, $name17, $name18, $name19);
$name15, $name16, $name17, $name18, $name19, $name20);
";
for (var i = 1; i < 20; i++)
{
ydbCommand.Parameters.AddWithValue("$name" + i, DBNull.Value);
}

ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name1", DbType = DbType.Int32, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name2", DbType = DbType.Boolean, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name3", DbType = DbType.Int64, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name4", DbType = DbType.Int16, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name5", DbType = DbType.SByte, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name6", DbType = DbType.Single, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name7", DbType = DbType.Double, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name8", DbType = DbType.Decimal, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name9", DbType = DbType.Byte, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name10", DbType = DbType.UInt16, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name11", DbType = DbType.UInt32, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name12", DbType = DbType.UInt64, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name13", DbType = DbType.String, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name14", DbType = DbType.Binary, Value = null });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name15", Value = YdbValue.MakeOptionalJson() });
ydbCommand.Parameters.Add(new YdbParameter
{ ParameterName = "$name16", Value = YdbValue.MakeOptionalJsonDocument() });
ydbCommand.Parameters.Add(new YdbParameter { ParameterName = "$name17", DbType = DbType.Date, Value = null });
ydbCommand.Parameters.Add(
new YdbParameter { ParameterName = "$name18", DbType = DbType.DateTime, Value = null });
ydbCommand.Parameters.Add(new YdbParameter
{ ParameterName = "$name19", DbType = DbType.DateTime2, Value = null });
ydbCommand.Parameters.Add(new YdbParameter
{ ParameterName = "$name20", Value = YdbValue.MakeOptionalInterval() });

await ydbCommand.ExecuteNonQueryAsync();
ydbCommand.CommandText = $"SELECT NULL, t.* FROM {tableName} t";
var ydbDataReader = await ydbCommand.ExecuteReaderAsync();
await ydbDataReader.ReadAsync();

for (var i = 0; i < 20; i++)
Assert.True(await ydbDataReader.ReadAsync());
for (var i = 0; i < 21; i++)
{
Assert.True(ydbDataReader.IsDBNull(i));
}
Expand Down

0 comments on commit 483bae2

Please sign in to comment.