Skip to content

Conversation

@sgress454
Copy link
Contributor

This PR fixes an issue where a string concatenation in a LIKE expression fails to parse:

SELECT * FROM file WHERE path LIKE 'C:' || CHAR(92) || 'Users' || CHAR(92) || 'example.txt';

The fix is to swap the precedence of the comparison_expr and literal alternatives, so that the entire concatenation expression is parsed rather than just taking 'C:' as a literal and then leaving || CHAR(92) || 'Users' || CHAR(92) || 'example.txt'; as an unparsable fragment.

@taozhi8833998 taozhi8833998 self-requested a review August 26, 2025 01:04
@taozhi8833998 taozhi8833998 added the enhancement New feature or request label Aug 26, 2025
@taozhi8833998 taozhi8833998 added this to the 5.3.12 milestone Aug 26, 2025
sgress454 added a commit to fleetdm/fleet that referenced this pull request Aug 26, 2025
for #30854 

# Details

This PR updates our SQL query parser to allow string concatenation
inside of LIKE expressions, e.g.

```sql
SELECT * FROM file WHERE path LIKE 'C:' || CHAR(92) || 'Users' || CHAR(92) || 'example.txt';
```

See https://github.com/sgress454/node-sql-parser/pull/1/files for the
code changes in the parser, which are packaged into the changes in this
PR using the instructions
[here](https://github.com/fleetdm/fleet/blob/sgress454/30854-allow-concat-in-like/frontend/utilities/node-sql-parser/README.md#L12).

PR to upstream package:
taozhi8833998/node-sql-parser#2552

# 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
(in upstream repo)

- [X] QA'd all new/changed functionality manually
@taozhi8833998 taozhi8833998 modified the milestones: 5.3.12, 5.3.13 Sep 2, 2025
@taozhi8833998 taozhi8833998 merged commit aced536 into taozhi8833998:master Sep 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants