Skip to content

Sqlx comment parsing backslashes - #2339

Merged
Ford544 merged 1 commit into
mainfrom
sqlx-comment-parsing-backslashes
Sep 25, 2026
Merged

Ford544 merged 1 commit into
mainfrom
sqlx-comment-parsing-backslashes

Conversation

@Ford544

@Ford544 Ford544 commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Escape backslashes in sql comments in sqlx files.
Currently, the compiler escapes backticks (`) and dollar signs ($) in sql comments to prevent them from being interpreted as the end of string/JS block by the JS runtime. However, these symbols can still remain unescaped if they are preceded by a backslash in the user code, for example:
-- \`
after escaping becomes:
-- \\`
the backslash is escaped and the backtick remains unescaped, which is likely to trigger a SyntaxError
With this change, all backslashes are escaped, so the result would instead be:
-- \\\`
with the backtick still escaped.

Additionally, tests were added covering this behavior.

Comment thread core/compilers.ts Fixed
Comment thread core/compilers.ts Fixed
@Ford544
Ford544 marked this pull request as ready for review September 23, 2026 09:55
@Ford544
Ford544 requested a review from a team as a code owner September 23, 2026 09:55
Comment thread core/compilers.ts
return code;
}

export function extractJsBlocks(code: string): { sql: string; js: string } {

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.

This function will be removed in #2340

Comment thread core/compilers.ts
Comment thread core/main_sqlx_chars_test.ts
Comment thread core/compilers.ts
@Ford544
Ford544 force-pushed the sqlx-comment-parsing-backslashes branch from fa3a484 to efe7314 Compare September 25, 2026 06:33
@Ford544
Ford544 merged commit 566e3c1 into main Sep 25, 2026
10 checks passed
@Ford544
Ford544 deleted the sqlx-comment-parsing-backslashes branch September 25, 2026 06:48
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