Skip to content

fix(spanner): support SELECT with ExecuteNonQuery - #16050

Open
alaricd wants to merge 1 commit into
googleapis:mainfrom
alaricd:codex/spanner-executenonquery-select
Open

alaricd wants to merge 1 commit into
googleapis:mainfrom
alaricd:codex/spanner-executenonquery-select

Conversation

@alaricd

@alaricd alaricd commented Oct 29, 2026

Copy link
Copy Markdown

Summary

Allow ExecuteNonQuery and ExecuteNonQueryAsync to run SELECT and read commands, discard the result reader, and return -1. Add sync and async regression tests.

Resolves #16049.

Microsoft contract

Microsoft documents IDbCommand.ExecuteNonQuery as executing SQL and returning -1 for statement types other than UPDATE, INSERT, and DELETE; its documentation includes a SELECT example: https://learn.microsoft.com/dotnet/api/system.data.idbcommand.executenonquery

Compatibility

SELECT/read commands that currently throw will execute, discard results, and return -1. DML and DDL behavior is unchanged. Callers using the exception to reject queries through this API may observe this change.

Validation

Focused provider tests: dotnet test apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.Tests/Google.Cloud.Spanner.Data.Tests.csproj --no-restore -f net8.0 -p:NoWarn=CS8981%3BxUnit2004%3BxUnit2013 --filter FullyQualifiedName~ExecuteNonQuery — 2 passed, 0 failed.

Discovery

Found using pengdows.AdoNetApiTest.conformance.

@alaricd
alaricd requested a review from a team as a code owner October 29, 2026 07:12
@google-cla

google-cla Bot commented Oct 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request enables the execution of Select and Read command types via ExecuteNonQuery and ExecuteNonQueryAsync by introducing a new ExecuteQueryNonQueryAsync method that executes the query and returns -1. It also updates the corresponding exception message and adds unit tests to verify this behavior. There are no review comments, and I have no feedback to provide.

@alaricd
alaricd force-pushed the codex/spanner-executenonquery-select branch from a3c09ea to 0bd5ebb Compare October 29, 2026 07:25
@alaricd alaricd changed the title Support result-producing SQL in ExecuteNonQuery fix(spanner): support SELECT with ExecuteNonQuery Oct 29, 2026
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Oct 29, 2026
@amanda-tarafa amanda-tarafa self-assigned this Oct 29, 2026
@amanda-tarafa
amanda-tarafa marked this pull request as draft October 29, 2026 16:26
@amanda-tarafa
amanda-tarafa self-requested a review October 29, 2026 16:27
@alaricd
alaricd marked this pull request as ready for review October 29, 2026 18:41

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpannerCommand.ExecuteNonQuery should accept result-producing SQL

2 participants