Fix null named parameters in raw SQL queries (GH-3045)#4127
Merged
jeremydmiller merged 1 commit intomasterfrom Feb 11, 2026
Merged
Fix null named parameters in raw SQL queries (GH-3045)#4127jeremydmiller merged 1 commit intomasterfrom
jeremydmiller merged 1 commit intomasterfrom
Conversation
When using anonymous objects for named parameters in QueryAsync/AdvancedSqlAsync, null values caused PostgreSQL error 42P08 because NpgsqlDbType was not set. New NamedParameterHelper converts :paramName references to positional parameters with proper NpgsqlDbType inferred from the property's declared type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 17, 2026
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.
Summary
QueryAsync/AdvancedSqlAsynccaused PostgreSQL error42P08: could not determine data type of parameterNpgsqlDbTypewas never set on the parameter, so PostgreSQL couldn't infer the typeNamedParameterHelperconverts:paramNamereferences to positional$Nparameters withNpgsqlDbTypeinferred from the property's declared type (handlingNullable<T>viaGetUnderlyingType)Test plan
query_with_null_named_parameter_GH_3045covers the exact reported scenario (:param is null or ...pattern)query_by_one_named_parameter,query_by_two_named_parameters,query_two_fields_by_one_named_parameter) still pass::type casts, single-quoted strings, unknown parameter names🤖 Generated with Claude Code