Skip to content

Commit

Permalink
Bumped version to 2.2, added test, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkWanderer committed Sep 19, 2020
1 parent 886af95 commit 133e6af
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
27 changes: 27 additions & 0 deletions ClickHouse.Client.Tests/ParameterizedInsertTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Threading.Tasks;
using ClickHouse.Client.ADO;
using ClickHouse.Client.Utility;
using NUnit.Framework;

namespace ClickHouse.Client.Tests
{
public class ParameterizedInsertTests
{
private readonly ClickHouseConnection connection = TestUtilities.GetTestClickHouseConnection();

[Test]
public async Task ShouldInsertParameterizedArray()
{
await connection.ExecuteStatementAsync("TRUNCATE TABLE IF EXISTS test.float_array");
await connection.ExecuteStatementAsync("CREATE TABLE IF NOT EXISTS test.float_array (arr Array(Float64)) ENGINE Memory");

var command = connection.CreateCommand();
command.AddParameter("values", new[] { 1.0, 2.0, 3.0 });
command.CommandText = "INSERT INTO test.float_array VALUES ({values:Array(Float32)})";
await command.ExecuteNonQueryAsync();

var count = await connection.ExecuteScalarAsync("SELECT COUNT(*) FROM test.float_array");
Assert.AreEqual(1, count);
}
}
}
3 changes: 2 additions & 1 deletion ClickHouse.Client.Tests/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static ClickHouseConnection GetTestClickHouseConnection(bool compression
{
var builder = GetConnectionStringBuilder();
builder.Compression = compression;
builder["set_session_timeout"] = 1; // Expire sessions quickly after test
return new ClickHouseConnection(builder.ConnectionString);
}

Expand All @@ -28,7 +29,7 @@ public static ClickHouseConnectionStringBuilder GetConnectionStringBuilder()
var devConnectionString = Environment.GetEnvironmentVariable("CLICKHOUSE_CONNECTION") ??
throw new InvalidOperationException("Must set CLICKHOUSE_CONNECTION environment variable pointing at ClickHouse server");

return new ClickHouseConnectionStringBuilder() { ConnectionString = devConnectionString };
return new ClickHouseConnectionStringBuilder(devConnectionString);
}

public struct DataTypeSample
Expand Down
2 changes: 2 additions & 0 deletions ClickHouse.Client/ADO/ClickHouseConnectionStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public ClickHouseConnectionStringBuilder()
{
}

public ClickHouseConnectionStringBuilder(string connectionString) => ConnectionString = connectionString;

public string Database
{
get => TryGetValue("Database", out var value) ? value as string : "default";
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.1.0.{build}
version: 2.2.0.{build}
image:
- Visual Studio 2019
- Ubuntu
Expand Down

0 comments on commit 133e6af

Please sign in to comment.