Skip to content

Handle backslash escapes in boundQuery SQL parser#11

Merged
39ff merged 2 commits into
claude/plan-jetbrains-plugin-sGy4Lfrom
copilot/sub-pr-9
Feb 15, 2026
Merged

Handle backslash escapes in boundQuery SQL parser#11
39ff merged 2 commits into
claude/plan-jetbrains-plugin-sGy4Lfrom
copilot/sub-pr-9

Conversation

Copilot AI commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

The SQL parser in QueryEntry.boundQuery only handled doubled single-quotes ('') for escaping, but MySQL/MariaDB uses backslash escapes by default (\', \\) when NO_BACKSLASH_ESCAPES is disabled. Queries containing backslash-escaped quotes would incorrectly treat escaped quotes as string delimiters, breaking placeholder substitution.

Parser Updates

  • When inside a string literal and encountering \, consume both the backslash and following character without toggling string state
  • Preserve both doubled-quote ('') and backslash escape (\') mechanisms

Test Coverage

  • Added 12 tests covering: basic substitution, NULL params, quote escaping in values, placeholders in strings, both escape styles, edge cases

Example fixed:

// Before: incorrectly treats \' as closing quote, replaces ? inside 'Brien'
QueryEntry(
    query = "SELECT * FROM users WHERE name = 'O\\'Brien' AND age = ?",
    params = listOf("25")
).boundQuery
// "SELECT * FROM users WHERE name = 'O\  (broken)

// After: correctly preserves escaped quote, replaces only outside placeholder
// "SELECT * FROM users WHERE name = 'O\\'Brien' AND age = '25'"

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: 39ff <7544687+39ff@users.noreply.github.com>

Copilot AI commented Feb 15, 2026

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cache-redirector.jetbrains.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.5-bin/5t9huq95ubn472n8rpzujfbqh/gradle-8.5/lib/gradle-launcher-8.5.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.5-bin/5t9huq95ubn472n8rpzujfbqh/gradle-8.5/lib/agents/gradle-instrumentation-agent-8.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.5 (dns block)
  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr view 9 --json body,comments,reviews --jq .reviews[] | select(.id == &#34;PRR_kwDOMJI8cc6dkPaI&#34;) | {body, comments} (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update logging for bound parameter values in prepared statements Handle backslash escapes in boundQuery SQL parser Feb 15, 2026
Copilot AI requested a review from 39ff February 15, 2026 13:32
@39ff 39ff marked this pull request as ready for review February 15, 2026 14:25
@39ff 39ff merged commit 2d7b46b into claude/plan-jetbrains-plugin-sGy4L Feb 15, 2026
34 checks passed
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