Skip to content

fix: update escape character for sqlite#4

Merged
sgress454 merged 1 commit intomasterfrom
sgress454/fleet-31222-update-escape-character-for-sqlite
Jan 27, 2026
Merged

fix: update escape character for sqlite#4
sgress454 merged 1 commit intomasterfrom
sgress454/fleet-31222-update-escape-character-for-sqlite

Conversation

@sgress454
Copy link
Copy Markdown
Owner

fixes fleetdm/fleet#31222

This PR updates the escape character sequences in SQLite to only be ''. From the SQLite docs (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.

This fix allows the following common query pattern to work:

SELECT * FROM "table_name" WHERE "column_name" LIKE '\_%' ESCAPE '\'

This sets the escape character to a backslash so that single-character wildcared _ char can be escaped, and you can look for values starting with an underscore.

@sgress454 sgress454 merged commit 15cb6f0 into master Jan 27, 2026
sgress454 added a commit that referenced this pull request Jan 27, 2026
sgress454 added a commit to fleetdm/fleet that referenced this pull request Jan 28, 2026
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #34635

# Details

This PR switches us to a [fork of
node-sql-parser](https://github.com/sgress454/node-sql-parser) that I'm
maintaining to fast-track fixes to the SQLite implementation. The first
published version of the fork is 5.4.0-fork.1 (forked from v5.4.0 of the
upstream), and includes fixes for #34635 and #30109 that haven't made it
to the upstream yet.

Fixes in 5.4.0-fork.1:

* sgress454/node-sql-parser#7
* sgress454/node-sql-parser#5
* sgress454/node-sql-parser#4

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [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.

## Testing

- [X] Added/updated automated tests
- Granular tests are added [in the package
itself](https://github.com/sgress454/node-sql-parser/blob/5.4.0-fork.1/test/sqlite.spec.js),
and new regression tests for the Fleet issues are added in the Fleet.
- [X] QA'd all new/changed functionality manually
 - Pasted the offending queries into the editor and saw no syntax errors
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.

1 participant