feat(sqlite): support ESCAPE in LIKE expressions#2496
Merged
taozhi8833998 merged 2 commits intotaozhi8833998:masterfrom Jul 16, 2025
Merged
feat(sqlite): support ESCAPE in LIKE expressions#2496taozhi8833998 merged 2 commits intotaozhi8833998:masterfrom
taozhi8833998 merged 2 commits intotaozhi8833998:masterfrom
Conversation
sgress454
commented
Jul 16, 2025
| ast = parser.astify(sql, { database: 'mariadb' }) | ||
| expect(parser.sqlify(ast, DEFAULT_OPT)).to.be.equal('CREATE TABLE "Test" ("id" INT(11) NOT NULL, "name" VARCHAR(255) NOT NULL, PRIMARY KEY ("id"), UNIQUE ("name"))') | ||
| sql = `SELECT | ||
| sql = `SELECT |
Contributor
Author
There was a problem hiding this comment.
This is from the trim_trailing_whitespace editor rule, I can back it out if you prefer formatting fixes to be in separate PRs.
Owner
|
@sgress454 Thanks for the pr, merged. |
Contributor
Author
|
@taozhi8833998 any ETA on 5.3.11 release? 😉 |
2 tasks
sgress454
added a commit
to fleetdm/fleet
that referenced
this pull request
Jul 25, 2025
for #30109 # Details This PR fixes an issue in our current SQL parsing library that was causing queries like this to be marked invalid: ``` SELECT * FROM table_name WHERE column_name LIKE '\_%' ESCAPE '\' ``` This is valid in SQLite because the `\` is not considered an escape character by default. From [the SQLite docs](https://www.sqlite.org/lang_expr.html) (see section 3 "Literal Values (Constants)"; emphasis mine): > A string constant is formed by enclosing the string in single quotes ('). A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal. C-style escapes using the backslash character are not supported because they are not standard SQL. # Use of forked code Part of the fix for this was [submitted as a PR to the node-sql-parser library](taozhi8833998/node-sql-parser#2496) we now use, and merged. I then found that another fix was needed, which I submitted as [a separate PR](taozhi8833998/node-sql-parser#2512). As these fixes have yet to be made part of an official release of the library, I made a fork off of the release we were using (5.3.10) and bundled the necessary build artifacts with Fleet. We have an [ADR proposing the use of submodules for this purpose](#31079); I'm happy to implement that instead if we approve that, although for a front-end module with a build step it's a bit more complicated. Hopefully this code will be released in `node-sql-parser` soon and we can revert back to using the dependency. Here is the [full set of changes](taozhi8833998/node-sql-parser@master...sgress454:node-sql-parser:5.3.10-plus). # Checklist for submitter - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [X] Manual QA for all new/changed functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for
ESCAPEin SQLiteLIKEexpressions. This support is documented in the official SQLite docs.