fix(db): LIKE wildcards % and _ should match newline characters#407
Open
sravan27 wants to merge 1 commit into
Open
fix(db): LIKE wildcards % and _ should match newline characters#407sravan27 wants to merge 1 commit into
sravan27 wants to merge 1 commit into
Conversation
`ilike()` compiled the LIKE pattern to a RegExp without the dotall flag, so `%` (-> .*) and `_` (-> .) did not match newline characters. This diverges from SQL LIKE semantics, where `%` matches any sequence and `_` any single character, newlines included — silently excluding rows whose value contains a newline (e.g. 'a\nb' did not match 'a%b'). Add the `s` flag and enable the previously `describe.todo` like/nlike suites with regression coverage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Someone is attempting to deploy a commit to the Aspen Cloud Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
like/nlikefilters compile the SQL pattern to aRegExpwithout the dotall(
s) flag (packages/db/src/filters.ts,ilike()), so the%(→.*) and_(→
.) wildcards don't match newline characters. This diverges from SQLLIKE,where
%matches any sequence and_any single character — newlines included.A stored value containing a newline is silently excluded from patterns it
should match.
Reproduce (before this PR)
Fix
Add the
s(dotall) flag to the compiled regex. JS$(without themflag)already anchors to the true end of the string, so there is no trailing-newline
false positive — only the missing matches needed fixing.
Tests
The
like/nlikesuites weredescribe.todoplaceholders (with aTODO: move over like/nlike testsnote), so this behaviour was shipping untested. Replacedthem with regression coverage for newline handling, using the existing
testFilterOpharness. The wildcard→regex mapping was also cross-checked againstSQL semantics with a small reference script: the current implementation diverges
on the newline cases; with the
sflag it matches on all cases (no regression onthe existing non-newline behaviour).
Opened as a draft pending a CI run of the db test suite.