Skip to content

Commit

Permalink
Add test case for #326 (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
smbecker authored Jul 3, 2023
1 parent 37d4b2e commit 31b3dd8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ClickHouse.Client.Tests/BulkCopyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,28 @@ public async Task ShouldNotLoseRowsOnMuptipleBatches()
Assert.AreEqual(Count, await connection.ExecuteScalarAsync($"SELECT count() FROM {targetTable}"));
}

[Test]
public async Task ShouldExecuteWithDBNullArrays()
{
var targetTable = $"test.dbnull_array";

await connection.ExecuteStatementAsync($"TRUNCATE TABLE IF EXISTS {targetTable}");
await connection.ExecuteStatementAsync($"CREATE TABLE IF NOT EXISTS {targetTable} (stringValue Array(String), intValue Array(Int32)) ENGINE TinyLog");

using var bulkCopy = new ClickHouseBulkCopy(connection)
{
DestinationTableName = targetTable,
};

await bulkCopy.WriteToServerAsync(new List<object[]>
{
new object[] { DBNull.Value, new[] { 1, 2, 3 } },
new object[] { new [] { "sample1", "sample2" }, DBNull.Value },
}, CancellationToken.None);

using var reader = await connection.ExecuteReaderAsync($"SELECT * from {targetTable}");
}

private static string SanitizeTableName(string input)
{
var builder = new StringBuilder();
Expand Down

0 comments on commit 31b3dd8

Please sign in to comment.