Auto-detect function argument types when dropping or updating#203
Draft
teoljungberg wants to merge 10 commits into
Draft
Auto-detect function argument types when dropping or updating#203teoljungberg wants to merge 10 commits into
teoljungberg wants to merge 10 commits into
Conversation
e035865 to
e47e07c
Compare
d5ccab1 to
02c3803
Compare
e47e07c to
a94c6c2
Compare
teoljungberg
added a commit
that referenced
this pull request
Mar 8, 2026
- Fetch `pg_get_function_identity_arguments` in the schema dump query so each `Fx::Function` knows its argument types - Add `Function#signature` returning the full PostgreSQL identity (e.g. `add(integer, integer)` or `now_utc()`) - Use `signature` for `==` and `<=>` so overloaded functions with the same name but different arguments are correctly distinguished - `arguments` is kept private; `signature` is the public API Foundational change that both #203 and the dependency sorting PR can build on.
5675428 to
297eb3d
Compare
Functions with parameters previously could not be dropped or updated because PostgreSQL requires the argument types in DROP FUNCTION for functions that accept arguments. The adapter now looks up argument types from pg_proc automatically, removing the need for manual intervention. For overloaded functions (same name, different signatures), an explicit `arguments:` option is available on drop_function and update_function to disambiguate. When multiple overloads exist and no arguments are given, an AmbiguousFunctionError is raised with guidance. Closes #7
- Use .presence on pg_get_function_identity_arguments result so no-arg functions preserve the original DROP FUNCTION name form instead of generating unnecessary empty parens - Handle quoted identifiers in schema-qualified names (e.g. "My_Schema"."My_Func") by parsing with a regex instead of split - Document that the arguments: option is Postgres-specific and that custom adapters must accept the keyword to use it
Replace manual signature string construction with Function#signature in drop_function and the ambiguous function error message.
Replace the separate FUNCTION_ARGUMENTS_QUERY with a lookup against the existing functions method, which already fetches arguments via pg_get_function_identity_arguments.
The command recorder passes arguments through when reverting drop_function, so create_function must accept it even though it is unused during creation.
50e05ae to
7bc3c52
Compare
|
This looks great. I like that it handles the unambiguous case automatically, and provides a straightforward way to handle overloads. What will it take to get this into the released version of the gem? I'd love to start using it right away. |
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.
Functions with parameters could not be dropped or updated
because PostgreSQL requires argument types in DROP FUNCTION.
This has been the longest-standing open issue (#7, 2017).
drop/update time
update_function for overloaded functions
overloads exist and no arguments: option is given
**options.slice(:arguments), keeping custom adapters working
Closes #7