fix: strip function parentheses from result column names (#75)#76
Merged
Conversation
…olumn names Fixes GitHub #75 - pgAdmin4 breaks because SQLite returns column names like 'version()' instead of 'version'. The sanitizer strips everything from the first '(' onward, matching PostgreSQL behavior.
After sanitizing column names by stripping parentheses, function names like 'json_extract' arrive without parens instead of 'json_extract(...)'. Add exact-match handling for known function names (without parens) before falling back to query-based alias detection.
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
Fixes #75 — PostgreSQL returns function names as column names (e.g.,
version), but SQLite returns the full expression (e.g.,version()). This breaks clients like pgAdmin4 that expect PostgreSQL-compatible column names.Changes
sanitize_column_name()function (src/query/column_sanitizer.rs) — strips everything from the first(onward, turningversion()→version,count(*)→count,max(id)→max, etc.stmt.column_name(i)call sites across 5 files —db_handler.rs,fast_path.rs,query_interceptor.rs,statement_pool.rs,read_only_optimizer.rsget_aggregate_return_type_with_query()to handle bare function names (without parentheses) — since column names now arrive sanitized, the type inference logic needs to matchjson_extractnot justjson_extract(...).Testing
sanitize_column_nametest_now_functionfailure unrelated to this change)cargo check,cargo build,cargo clippyall clean