Repository navigation
Source: derived parameter names are resolved on every run, so a reused command sends the right names - #168
Merged
Conversation
…e Params (R20) A command object run again against another database (a factory that hands out connections to several, or ChangeDatabase) sent the first run's parameter names and lost the members of an AddParams object that the first procedure did not take, because the first run cached its answer by rewriting Params in place and clearing the derived flag. SQL Server rejected the second run (error 201 or 8145). The name memory (keyed by server, database and procedure) was already right; only the mutation was wrong. Now Params is never written by a run: the names are resolved in every run for the connection that run uses, and the send list is built per thread, set up and reset in one synchronous stretch around the unchanged AddParams(TCommand) hook, which still sees the resolved names through the Params getter. No public or protected member changes. After a run, Params shows what was added, not the resolved names. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the multi-line ifs (A6 style findings) Rename the three thread-static fields of ExpressiveCommandBase to _preparing, _sendList and _spareList, and add braces to four multi-line if statements, as the style gate asks. No behaviour change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
electricessence
marked this pull request as ready for review
November 16, 2026 22:40
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 this changes
A command that gets its parameter names from the database (a stored procedure called with
AddParam(value)and no names) resolved those names once and wrote them into the command'sParams. A second run on the same command object then reused the first run's names: after a connection change, a different database or a different procedure, it sent the wrong names (SQL Server: "Procedure ... expects parameter '@p_order_id', which was not supplied"). This fixes it with no public or protected change.What changes inside. The derived names are resolved on every run into a per-run send list, and
Paramsis never rewritten: it keeps what the caller added. The unchangedAddParams(TCommand)hook still sees the resolved list throughParamswhile that command'sPrepareCommandruns on that thread. That uses thread-static state (Preparing,SendList,SpareList) that is reset in afinally, restores the previous values for nested prepares, and keeps concurrent runs of one command object safe. A command with no derived names takes today's path with one field read. OnlyExpressiveCommandBase.cschanged inSource/.AddParams(TCommand)overrides are not edited.Paramsshows what the caller added; before, it showed the resolved names.expressive-commands.mdsaid the second; the sentence is rewritten, and the migration notes carry a line. What was sent is readable throughExecute(command => ...).AddParamswith an object). A reused command whose provider reports no names now asks the provider on every run instead of once (the provider's lookup is a schema query for the database-connection command); commands created per call are unchanged.Paramsis still what was added after a run.Checks
🤖 Generated with Claude Code