Refactor to support all database functions by default - #4
Merged
Conversation
The previous approach required hardcoding function names and argument counts in each driver, making it brittle when databases added new functions or changed arity (e.g., toDateTime64 supporting 1-3 args but only implemented for 1-2). This created maintenance burden and prevented users from accessing newer database functions. Changes: - Remove TranslateFunction from Driver interface - Support any function with any arity at SQL generation time - Remove 1100+ lines of function translation code from drivers - Keep Validator for runtime function restrictions when needed - Remove unused ConcatOperator from Driver interface - Update documentation to reflect universal function support Functions are now passed through directly to the database for validation, providing maximum flexibility while maintaining safety through parameterization.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the function handling architecture to support all database functions by default, eliminating the need for hardcoded function translations in drivers. The previous approach required manually maintaining 1100+ lines of function translation code across drivers, creating maintenance burden when databases added new functions or changed argument counts.
Key changes:
- Remove TranslateFunction requirement from Driver interface
- Build function calls directly in SQL builder without driver involvement
- Remove ConcatOperator from Driver interface as unused
- Update documentation to emphasize universal function support
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sql_builder.go | Implements direct function template building without driver translation |
| parser.go | Updates function validation comments to clarify parse-time vs runtime validation |
| functions.go | Updates comments to clarify StandardFunctions is now documentation-only |
| example_test.go | Updates expected test outputs to reflect new generic function syntax |
| drivers/postgres/postgres_test.go | Updates test expectations for new function call format |
| drivers/postgres/postgres.go | Removes 530+ lines of PostgreSQL-specific function translation code |
| drivers/mysql/mysql.go | Removes 320+ lines of MySQL-specific function translation code |
| drivers/clickhouse/clickhouse.go | Removes 270+ lines of ClickHouse-specific function translation code |
| driver_test.go | Removes TranslateFunction and ConcatOperator from mock driver |
| driver.go | Updates Driver interface to remove function translation methods |
| README.md | Updates documentation to reflect universal function support |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
The previous approach required hardcoding function names and argument counts in each driver, making it brittle when databases added new functions or changed arity (e.g., toDateTime64 supporting 1-3 args but only implemented for 1-2). This created maintenance burden and prevented users from accessing newer database functions.
Changes:
Functions are now passed through directly to the database for validation, providing maximum flexibility while maintaining safety through parameterization.