Skip to content

Refactor to support all database functions by default - #4

Merged
pseudomuto merged 1 commit into
mainfrom
default_to_all_funcs
Oct 15, 2025
Merged

Refactor to support all database functions by default#4
pseudomuto merged 1 commit into
mainfrom
default_to_all_funcs

Conversation

@pseudomuto

Copy link
Copy Markdown
Owner

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.

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.
@pseudomuto
pseudomuto requested a review from Copilot October 15, 2025 00:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pseudomuto
pseudomuto merged commit 24aee16 into main Oct 15, 2025
3 checks passed
@pseudomuto
pseudomuto deleted the default_to_all_funcs branch October 15, 2025 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants