Use connection search path when attempting to lookup ambiguous type#6446
Open
ickers wants to merge 1 commit intonpgsql:mainfrom
Open
Use connection search path when attempting to lookup ambiguous type#6446ickers wants to merge 1 commit intonpgsql:mainfrom
ickers wants to merge 1 commit intonpgsql:mainfrom
Conversation
…lly-qualified name
Contributor
|
We already looked into it in #4869, and the general consensus was that it's unreliable as user can change search_path via a regular query and we have no way to react to this. |
Member
|
Instead we implemented https://github.com/npgsql/npgsql/blob/main/src%2FNpgsql%2FNpgsqlTypeLoadingOptions.cs#L25 This achieves much of the same if the duplicates get in the way for you. |
1 similar comment
Member
|
Instead we implemented https://github.com/npgsql/npgsql/blob/main/src%2FNpgsql%2FNpgsqlTypeLoadingOptions.cs#L25 This achieves much of the same if the duplicates get in the way for you. |
Author
|
Is it worth me pivoting this PR to just updating the exception message to make |
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.
If an duplicate name for a type exists in multiple schemas and there is an attempt to use that name without schema-qualification then currently npgsql just throws an
ArgumentException.postgresql doesn't behave this way, instead it resolves unqualified type names based on some "search path" for the current session/user/database/connection, using the first matching type it finds in that search path.
This PR attempts to more closely align npgsql with postgresql's behaviour in this regard.
Future enhancement would be to retrieve the current search path for a connection (if not explicitly set in connection string) during initialisation instead of using hardcoded defaults as is done in this PR.