Skip to content

Merge pull request #378 from pengdows/fix/prepare-requires-open-connection - #378

Merged
Giorgi merged 2 commits into
Giorgi:developfrom
pengdows:fix/prepare-requires-open-connection
Oct 20, 2026
Merged

Giorgi merged 2 commits into
Giorgi:developfrom
pengdows:fix/prepare-requires-open-connection

Conversation

@alaricd

@alaricd alaricd commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

DuckDBCommand.Prepare() is an empty method, so it succeeds on a command with no connection or a closed one.

The contract

IDbCommand.Prepare, Exceptions:

InvalidOperationException: The Connection is not set. -or- The Connection is not Open().

Change

Prepare() now calls the existing EnsureConnectionOpen(), the same check the Execute* methods use. Statements are still prepared at execution, so an open connection sees no difference. Test: PrepareThrowsWithoutAnOpenConnection (no connection, a closed connection, and an open one). The full suite passes.

The same page notes that "there is no need to call this method directly", so this matters most to code that calls Prepare() up front to catch a misconfigured command early. I've kept it separate from the other contract fixes so you can take or leave it on its own.

Conformance tests: Prepare_throws_when_no_connection, Prepare_throws_when_connection_closed.

Found by the pengdows ADO.NET conformance suite, which runs the documented System.Data.Common contract against every provider; each failure it reports cites the learn.microsoft.com sentence the provider departs from.

🤖 Generated with Claude Code

IDbCommand.Prepare documents InvalidOperationException when "The
Connection is not set. -or- The Connection is not Open()." Prepare was
an empty method, so a command with no usable connection passed it and
failed only when it executed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Giorgi

Giorgi commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Can you resolve the conflict?

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 39421145951

Coverage increased (+0.02%) to 92.577%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4016
Covered Lines: 3780
Line Coverage: 94.12%
Relevant Branches: 2289
Covered Branches: 2057
Branch Coverage: 89.86%
Branches in Coverage %: Yes
Coverage Strength: 1003317.41 hits per line

💛 - Coveralls

@Giorgi Giorgi changed the title Prepare requires an open connection Merge pull request #378 from pengdows/fix/prepare-requires-open-connection Oct 20, 2026
@Giorgi
Giorgi merged commit 3b82994 into Giorgi:develop Oct 20, 2026
11 of 12 checks passed
@alaricd

alaricd commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

The merge conflict has been resolved and the branch is synchronized. Build and CodeQL are passing; thanks for flagging it.

This branch is waiting to be deployed

1 waiting deployment
external — 4c05c1cb Waiting Oct 20, 2026 by alaricd via Authorize #687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants