Skip to content

fix(jdbc): parse SQL queries containing empty string constant '' - #80

Open
arimu1 wants to merge 1 commit into
qos-ch:masterfrom
arimu1:fix/78-jdbc-empty-string-constant
Open

fix(jdbc): parse SQL queries containing empty string constant ''#80
arimu1 wants to merge 1 commit into
qos-ch:masterfrom
arimu1:fix/78-jdbc-empty-string-constant

Conversation

@arimu1

@arimu1 arimu1 commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • Fix JdbcPatternParser so SQL empty string constants ('') no longer break detection of later log4j pattern literals (e.g. '%m').
  • Add negative lookbehind (?<!') to STRING_LITERAL_PATTERN so only opening quotes start a string-literal match, not the closing quote of an adjacent ''.
  • Add testEmptyStringConstant regression test from SQL error in JDBC Appender if the sql query uses the empy string constant '' #78.

Root cause

The previous regex '((?>[^']|'')+)' could treat the second quote in NULLIF(a[2], '') as the start of a new string literal, leaving downstream pattern literals unparsed.

Test plan

  • mvn test -Dtest=JdbcPatternParserTest — all 5 tests pass (including new testEmptyStringConstant)
  • mvn test — full suite passes

Fixes #78

JdbcPatternParser treated the second quote in SQL '' as the start of a
string literal, breaking pattern substitution for later bind parameters.
Add a negative lookbehind so only opening quotes start a literal match.

Fixes qos-ch#78

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
@arimu1
arimu1 force-pushed the fix/78-jdbc-empty-string-constant branch from 0ccc6a1 to 25d98e4 Compare August 25, 2026 04:11
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.

SQL error in JDBC Appender if the sql query uses the empy string constant ''

1 participant