Repository navigation
A return code on a text command follows ADO.NET (the SQL Server command refuses it), and MatchingOrdinals takes the first duplicate column - #323
Merged
Conversation
… definition
Old: ExecuteReturnAsync<T>() on a call of a text definition, a ReturnValue
member in ExecuteOutputAsync<TOut>() on a text command or in Output<TOut>()
on a text definition, and CaptureReturn (or a captured model with a
ReturnValue member) on a text command or a text definition threw
InvalidOperationException ("needs a stored procedure").
New: they run and give what the provider reports for a text command, as
ExecuteReturnAsync() on a text command always did. A provider package that is
certain can refuse it: a new internal hook on the command base, called before
anything runs by each call that reads a return code, does nothing in Core.
Reading the return code twice (a capture beside ExecuteReturnAsync) and a model
as the return code are still refused. The unused messages and the capture
set's definition-only entry point are removed; no public API changes.
The remarks of the return-code members, the article and the release notes say
what a text command gives and how to read a code from text (EXEC @r = dbo.p
with an output parameter). Tests that pinned the old refusals are replaced by
tests that run each path on a fake provider.
Behavior change: yes
Cost: none at run time; the hook is one virtual call per call that reads a
return code.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Old: on an ExpressiveSqlCommand whose type is text, ExecuteReturnAsync(), ExecuteReturnAsync<T>() and ExecuteReturn() ran and gave 0 (RETURN n in text is a server error), and a ReturnValue member in ExecuteOutputAsync<TOut>() and CaptureReturn threw a message about stored procedures. New: all of them throw InvalidOperationException before a connection is opened or taken, with a message that says to call the procedure by name with StoredProcedure(name), or to read the code from text with EXEC @r = dbo.p and an output parameter. A stored procedure called by name is unchanged. The SQL Server package overrides the hook that Core's command base calls before each call that reads a return code. The generic ExecuteReturnAsync<T>() now starts the non-generic call at the call, so the refusal (and a capture beside it, or a canceled token) is thrown at the call, not through the returned task, as the non-generic form always did. A definition (DbNonQuery.Text on a SqlConnection) is Core's and is not refused; the remarks say SQL Server reports 0 for it. The package lets the Core tests see its internal message constant. Behavior change: yes Cost: none at run time beyond one comparison of the command's type per call that reads a return code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the SQL Server command refuses a text command, and that ExecuteReturnAsync<T> refuses at the call A definition run on a SqlConnection is not refused, so the shared remark names the command of the SQL Server package. The first release note no longer reads as if the SQL Server command also runs a return code on text, and a new item records that ExecuteReturnAsync<T>() on a command throws a canceled token, a capture beside it and the refusals from the call itself instead of from the returned task. A test name says what it checks. Behavior change: no (documentation and a test name). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The Roslynator scan reports RCS1261 on the two async tests that built a connection with `using`; `await using` is what the rule asks for. Behavior change: no (tests only). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…one column has MatchingOrdinals with sort false kept the last column of a duplicated name and with sort true returned all of them, so the two modes disagreed and neither matched GetOrdinal. Both now return the first column of each requested name, as ADO.NET GetOrdinal does. Behavior change: yes. Old: sort false gave the last duplicate, sort true gave every duplicate. New: both give the first column of the name; alias in SQL to read another. Dictionary.TryAdd gets an internal netstandard2.0 shim, and RowMap uses it in place of its inline conditional block. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A method that declares Task<PooledArray<T>> can return the buffer itself instead of buffer.Items. The conversion is the Items task (the same task on every conversion), so a disposed buffer throws ObjectDisposedException as Items does. A null buffer throws ArgumentNullException with a message that says what to convert: Items does not guard null, so this is the only guard. There is no GetAwaiter; the rows are still awaited through Items. The ASP.NET Core controller sample returns the buffer, with the article text and the release note. Five existing tests that passed a lambda returning a PooledBuffer<T> to Assert.Throws or Record.Exception now use a statement lambda: a lambda that returns a buffer now also converts to Func<Task>, and xUnit refuses that overload. Behavior change: source level only. A lambda or argument whose type is a PooledBuffer<T> now also converts to Task<PooledArray<T>>, so an overload set that has a Func<Task> or Task parameter can bind to it where it did not. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The implicit conversion changes overload resolution for every argument or lambda of type PooledBuffer<T> (it can now bind to a Func<Task> or Task overload), which is not worth saving a call of Items. Removes the operator, its PublicAPI entry, its release note, the article and sample change, its tests, and puts back the five lambdas that the conversion made cast to Action. Behavior change: none against the last release; this undoes an addition that was never released. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two owner decisions for the 11.0.0 release, both behavior changes, each with a release-note bullet. The branch has the commits of both (squash to one).
1. A return code on a text command (A1-4)
Core now behaves as ADO.NET does and says so in the remarks; the strict check lives only in the SQL Server package.
ExecuteReturnAsync<T>()on aDbNonQuery.Textdefinition call, aReturnValuemember inExecuteOutputAsync<TOut>()orOutput<TOut>(), and a return-value capture (CaptureReturn, or a captured model with aReturnValuemember) ran intoInvalidOperationException("needs a stored procedure"); they now run and give what the provider reports (SQL Server: 0, andRETURN nin text is a server error).ExpressiveSqlCommandwhose type is text throwsInvalidOperationExceptionbefore a connection is used, forExecuteReturn,ExecuteReturnAsync,ExecuteReturnAsync<T>, aReturnValuemember inExecuteOutputAsync<TOut>()and a return capture. Before,ExecuteReturn*ran and gave 0. The message says to call the procedure by name or to useEXEC @r = dbo.pwith an output parameter. A procedure called by name, and a definition run on aSqlConnection, are unchanged (definitions get remarks only).ExecuteReturnAsync<T>()on a command now refuses at the call (an already canceled token, a capture of the return code beside the call, the refusals above), asExecuteReturnAsync()already did, instead of from the returned task.WithOnDefinition, two message consts). No public API change. The SQL Server refusal goes through an internal hook on the command base, also reached by the synchronousExecuteReturn.2.
MatchingOrdinalstakes the first column of a duplicated name (G3-1)With duplicate column names,
MatchingOrdinals(sort: false)gave the last column andsort: truegave all of them; both now give the first, asGetOrdinaldoes. Alias in SQL to read another.Dictionary.TryAddgets an internal netstandard2.0 shim (inCompatibility), andRowMapuses it instead of its inline#ifblock.Fail-first
InvalidOperationException); the ad hocExecuteReturnon text was pinned as a test that runs both before and after.Expected: [(Id, 0)] Actual: [(Id, 0), (Id, 1)]for sorted,Actual: [(Id, 1)]for unsorted); the other two are pins.Checks (head 816bda2)
dotnet formatstyle and analyzers 0 findings, 267 sample checks, docfx 0 warnings.internalmembers on public types (the new hook and the SQL Server override). Leak check over the whole diff and messages: clean.Not changed
Source/SqlClient(legacy, not published in v11). A definition run on aSqlConnectionis not refused for a return code on text: the remarks say what SQL Server reports.🤖 Generated with Claude Code