Skip to content

fix(query): escape LIKE ESCAPE literals in display#19596

Merged
sundy-li merged 1 commit intodatabendlabs:mainfrom
sundy-li:fix/issue-19563-like-escape-display
Mar 24, 2026
Merged

fix(query): escape LIKE ESCAPE literals in display#19596
sundy-li merged 1 commit intodatabendlabs:mainfrom
sundy-li:fix/issue-19563-like-escape-display

Conversation

@sundy-li
Copy link
Member

@sundy-li sundy-li commented Mar 23, 2026

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

This fixes the LIKE ... ESCAPE formatter roundtrip bug for escape literals that contain single quotes. Statements such as SELECT 'a' LIKE 'a' ESCAPE ''''; now serialize back to valid SQL, so the parser's debug reparse assertion no longer panics.

Changes

  • render Expr::LikeSubquery, Expr::LikeAnyWithEscape, and Expr::LikeWithEscape escape literals with the shared QuotedString SQL string formatter
  • add a regression test covering plain LIKE, LIKE ANY (...), and LIKE ANY (SELECT ...) with ESCAPE ''''

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Pair with the reviewer to explain why

Validation:

  • cargo test -p databend-common-ast
  • cargo clippy -p databend-common-ast --tests -- -D warnings

Type of change

  • Bug fix

Fixes #19563


This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Mar 23, 2026
@sundy-li sundy-li added the agent-reviewable Ready for agent review label Mar 23, 2026
@sundy-li sundy-li requested a review from KKould March 24, 2026 11:55
@sundy-li sundy-li merged commit 21377cd into databendlabs:main Mar 24, 2026
185 of 187 checks passed
@sundy-li sundy-li deleted the fix/issue-19563-like-escape-display branch March 24, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-reviewable Ready for agent review pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LIKE ... ESCAPE '''' panics in parser reparse assertion because Expr::Display does not escape the escape literal

2 participants