Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ClickHouse.Driver.Tests/ADO/DataSourceTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if NET7_0_OR_GREATER
using System.Data;
using System.Threading.Tasks;
using ClickHouse.Driver.ADO;
using NUnit.Framework;

Expand All @@ -14,5 +16,16 @@ public void CanCreateConnection()
using var connection = dataSource.CreateConnection();
Assert.That(connectionString, Is.EqualTo(connection.ConnectionString));
}

[Test]
public async Task OpenConnectionAsync_WithoutCancellationToken_ReturnsOpenClickHouseConnection()
{
using var dataSource = new ClickHouseDataSource(TestUtilities.GetTestClickHouseClientSettings());
await using ClickHouseConnection connection = await dataSource.OpenConnectionAsync();
Assert.That(connection.State, Is.EqualTo(ConnectionState.Open));

using var command = connection.CreateCommand("SELECT 1");
Assert.That(await command.ExecuteScalarAsync(), Is.EqualTo(1));
}
}
#endif
2 changes: 1 addition & 1 deletion ClickHouse.Driver/ADO/ClickHouseDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected override DbConnection CreateDbConnection()

IClickHouseConnection IClickHouseDataSource.OpenConnection() => OpenConnection();

public new async Task<ClickHouseConnection> OpenConnectionAsync(CancellationToken cancellationToken)
public new async Task<ClickHouseConnection> OpenConnectionAsync(CancellationToken cancellationToken = default)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on this branch. The source change is real: ValueTask<DbConnection> t = ds.OpenConnectionAsync(); now fails with CS0029, and .AsTask() / .Preserve() on the call fail with CS1061. ((DbDataSource)ds).OpenConnectionAsync() still compiles and returns ValueTask<DbConnection>. DbConnection c = await ds.OpenConnectionAsync(); also still compiles.

  • Changelog: done in ac7929b. The 686 fragment now has a sub-bullet that names the new return type, the code that stops compiling, and the two ways to keep it compiling. changelog.cs --check passes.
  • docs/http.mdx: no change. The docs page describes the current API, and the #ado-net-datasource examples are already correct for it. The page has no per-version compatibility notes; its only migration guide is for the ClickHouse.Client → ClickHouse.Driver rename. CHANGELOG.md is where this repo records source breaks for an upgrade (for example the Logger → LoggerFactory entry). I left this thread open so a maintainer can decide whether they also want a docs note.

{
var cn = await OpenDbConnectionAsync(cancellationToken).ConfigureAwait(false);
return (ClickHouseConnection)cn;
Expand Down
2 changes: 1 addition & 1 deletion ClickHouse.Driver/PublicAPI/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ClickHouse.Driver.ADO.ClickHouseDataSource.CreateConnection() -> ClickHouse.Driv
ClickHouse.Driver.ADO.ClickHouseDataSource.LoggerFactory.get -> Microsoft.Extensions.Logging.ILoggerFactory
ClickHouse.Driver.ADO.ClickHouseDataSource.LoggerFactory.set -> void
ClickHouse.Driver.ADO.ClickHouseDataSource.OpenConnection() -> ClickHouse.Driver.ADO.ClickHouseConnection
ClickHouse.Driver.ADO.ClickHouseDataSource.OpenConnectionAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<ClickHouse.Driver.ADO.ClickHouseConnection>
ClickHouse.Driver.ADO.ClickHouseDataSource.OpenConnectionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<ClickHouse.Driver.ADO.ClickHouseConnection>
ClickHouse.Driver.ADO.ClickHouseDataSource.Settings.get -> ClickHouse.Driver.ADO.ClickHouseClientSettings
ClickHouse.Driver.ADO.ClickHouseDefaults
ClickHouse.Driver.ADO.Feature.Dynamic = 2048 -> ClickHouse.Driver.ADO.Feature
Expand Down
2 changes: 1 addition & 1 deletion ClickHouse.Driver/PublicAPI/net8.0/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ClickHouse.Driver.ADO.ClickHouseDataSource.CreateConnection() -> ClickHouse.Driv
ClickHouse.Driver.ADO.ClickHouseDataSource.Logger.get -> Microsoft.Extensions.Logging.ILogger
ClickHouse.Driver.ADO.ClickHouseDataSource.Logger.set -> void
ClickHouse.Driver.ADO.ClickHouseDataSource.OpenConnection() -> ClickHouse.Driver.ADO.ClickHouseConnection
ClickHouse.Driver.ADO.ClickHouseDataSource.OpenConnectionAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<ClickHouse.Driver.ADO.ClickHouseConnection>
ClickHouse.Driver.ADO.ClickHouseDataSource.OpenConnectionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<ClickHouse.Driver.ADO.ClickHouseConnection>
ClickHouse.Driver.ADO.Readers.ClickHouseDataReader.GetTuple(int ordinal) -> System.Runtime.CompilerServices.ITuple
ClickHouse.Driver.IClickHouseDataSource
ClickHouse.Driver.IClickHouseDataSource.ConnectionString.get -> string
Expand Down
7 changes: 7 additions & 0 deletions changelog.d/686-datasource-openconnectionasync.fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* Fixed `ClickHouseDataSource.OpenConnectionAsync()` without a cancellation token being typed as
`DbConnection` instead of `ClickHouseConnection`
([#686](https://github.com/ClickHouse/clickhouse-cs/issues/686)). The documented ADO.NET examples
now compile.
- The call now returns `Task<ClickHouseConnection>` instead of `ValueTask<DbConnection>`. Code
that stores it as a `ValueTask<DbConnection>`, or calls `.AsTask()` or `.Preserve()` on it, no
longer compiles: await the call directly, or call it through `DbDataSource` to keep the old type.
Loading