Repository navigation
Remove string connection string keys that have a default value - #6725
Open
johnkaram02 wants to merge 1 commit into
Open
johnkaram02 wants to merge 1 commit into
johnkaram02 wants to merge 1 commit into
Conversation
NpgsqlConnectionStringBuilder.Remove resets the property to its default
value, and for string properties relies on the setter to remove the key.
That only works when the default is null. Encoding and Kerberos Service
Name default to "UTF8" and "postgres", so their setters wrote the key
back: Remove("Encoding") left "Encoding=UTF8" in the connection string,
and Clear() left a builder with one key.
Also remove the key from the base dictionary for string properties that
have a default value.
This branch has not been deployed
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.
Fixes #
NpgsqlConnectionStringBuilder.Removeresets the property to its default value. For string properties it relies on the setter to remove the key, which only works when the default is null.EncodingandKerberos Service Namedefault toUTF8andpostgres, so their setters wrote the key back.Remove("Encoding")leftEncoding=UTF8in the connection string, andClear()left a builder with one key.This change updates the source generator template so the generated
Removealso removes the key from the base dictionary for string properties that have a default value. The properties still return their defaults after the key is removed.The new
Remove_string_property_with_default_valueandClear_string_property_with_default_valuetests fail without the fix and pass with it. I ranConnectionStringBuilderTests(13 passed),ConnectionTests(147 passed, 7 skipped) andDataSourceTests(34 passed) against PostgreSQL 17.11 on Linux with .NET SDK 10.0.403.