Skip to content

Enhance default parsing of bind variables for SQL queries - #116

Open
garricko wants to merge 5 commits into
masterfrom
smart-bind-parsing
Open

Enhance default parsing of bind variables for SQL queries#116
garricko wants to merge 5 commits into
masterfrom
smart-bind-parsing

Conversation

@garricko

Copy link
Copy Markdown
Collaborator

Use smarter parsing of bind variables by default to avoid having to escape '?' and ':' characters elsewhere in the SQL

Use Options.useSmartSqlParameterParsing(false) to restore previous behavior.

…scape '?' and ':' characters elsewhere in the SQL

Use Options.useSmartSqlParameterParsing(false) to restore previous behavior.
Co-authored-by: garricko <1234201+garricko@users.noreply.github.com>

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

Introduces context-aware SQL bind-variable parsing as the default while retaining legacy parsing through configuration.

Changes:

  • Adds smart parsing for literals, identifiers, comments, and PostgreSQL casts.
  • Wires parsing options into select, insert, update, and batch execution.
  • Expands parser tests and changes Derby test dependency versions.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
MixedParameterSql.java Implements smart and legacy parsers.
Options.java Adds the parsing configuration API.
OptionsDefault.java Enables smart parsing by default.
OptionsOverride.java Delegates the new option.
SqlSelectImpl.java Applies the option to queries.
SqlInsertImpl.java Applies the option to inserts and batches.
SqlUpdateImpl.java Applies the option to updates.
DatabaseTest.java Adds parser and compatibility tests.
CommonTest.java Removes obsolete colon escaping.
pom.xml Downgrades Derby test dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main/java/com/github/susom/database/MixedParameterSql.java
Comment thread src/main/java/com/github/susom/database/Options.java Outdated
Comment thread src/main/java/com/github/susom/database/Options.java
…efault interface method, update javadoc

Co-authored-by: garricko <1234201+garricko@users.noreply.github.com>
@garricko

Copy link
Copy Markdown
Collaborator Author

@copilot add tests to cover those new database-specific syntax variations

…parsing

Co-authored-by: garricko <1234201+garricko@users.noreply.github.com>

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

@copilot add tests to cover those new database-specific syntax variations

Added four new test methods in DatabaseTest covering the new syntax variations:

  • smartParsingIgnoresCharsInDollarQuotedStrings – plain $$...$$, tagged $tag$...$tag$, and unterminated dollar-quoted strings
  • smartParsingFindsParameterAfterDollarQuotedString – verifies a real bind parameter after a dollar-quoted block is still resolved
  • smartParsingIgnoresCharsInBracketedIdentifiers – SQL Server [...], escaped ]] inside, and unterminated brackets
  • smartParsingFindsParameterAfterBracketedIdentifier – verifies a real bind parameter after a bracketed identifier is still resolved

@garricko
garricko requested a review from jpallas August 20, 2026 08:16

@jpallas jpallas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Defaulting to new parsing is a breaking change. Should increment major version number?

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.

4 participants