Skip to content

Commit

Permalink
DataReader: do not throw exception on empty dataset #58
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkWanderer committed Jan 16, 2021
1 parent ecf5441 commit 6675910
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ClickHouse.Client.Tests/SqlAlterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public SqlAlterTests()
[Test]
public async Task ShouldExecuteAlterTable()
{
await connection.ExecuteStatementAsync($"CREATE TABLE IF NOT EXISTS test.table_delete_from (value Int32) ENGINE=MergeTree ORDER BY value");
await connection.ExecuteStatementAsync($"ALTER TABLE test.table_delete_from DELETE WHERE 1=1");
await connection.ExecuteScalarAsync($"CREATE TABLE IF NOT EXISTS test.table_delete_from (value Int32) ENGINE=MergeTree ORDER BY value");
await connection.ExecuteScalarAsync($"ALTER TABLE test.table_delete_from DELETE WHERE 1=1");
}
}
}
7 changes: 7 additions & 0 deletions ClickHouse.Client/ADO/Readers/ClickHouseDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ protected override void Dispose(bool disposing)

private void ReadHeaders()
{
if (reader.PeekChar() == -1)
{
// Empty dataset
FieldNames = new string[0];
RawTypes = new ClickHouseType[0];
return;
}
var count = reader.Read7BitEncodedInt();
FieldNames = new string[count];
RawTypes = new ClickHouseType[count];
Expand Down

0 comments on commit 6675910

Please sign in to comment.