Repository navigation
Conversation
The value is text, not a pattern: %, _ and the backslash are escaped.
A string is escaped before it is bound; a param or expression is escaped
in SQL with replace(). { insensitive: true } writes ILIKE. Postgres gets
ESCAPE '\'; ClickHouse already escapes with a backslash. escapeLike()
is the escape step on its own.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
A
.like()pattern built from user text treats%and_in that text as wildcards. A search for "50%" also finds "500", and there is no portable way to say "case-insensitive contains".Closes #83.
Part of #52.
Changes
Expr:.contains(value),.startsWith(value),.endsWith(value). The value is text, not a pattern.%,_and\in it are escaped with a backslash, and the helper adds the wildcards.replace()calls, because its value is known only at run time.{ insensitive: true }(TextMatchOptions) writesILIKEon both dialects. On ClickHouse 26.8,ILIKEfolds UTF-8. On Postgres it folds by the databaseLC_CTYPE(ASCII only in aClocale, as in PGlite). The docs say this.ESCAPE '\'. ClickHouse uses the backslash as its LIKE escape already, so it gets no clause (this also keeps older ClickHouse versions working).escapeLike(text): the escape step on its own, for a pattern you build for.like().src/ch/text-match.test.ts), type tests (expr.test-d.ts), a docs example test, and three new core cases (text-match,text-match-param,text-match-insensitive). The core cases run live on Postgres (PGlite) and ClickHouse, on rows that contain%,_and\. Each case has a row that an unescaped pattern would also match, so a missing escape fails the case.docs/expressions.md, anddocs/reference.mdupdates. Changeset:minor.Left out
ESCAPEclause (it has no default escape) and itsLIKEignores case for ASCII only. MySQL needsESCAPE '\\'and its case rules follow the collation. The escape clause is written only for non-ClickHouse dialects, so a new dialect gets it, butinsensitiveon those dialects needs a decision (ILIKEdoes not exist there;lower()on both sides is one choice).lower()-based fallback for Postgres.ILIKEkeeps the Postgres semantics users expect, and alower()rewrite would not use the same indexes (pg_trgmsupportsILIKEdirectly).positionCaseInsensitiveUTF8/startsWith()rendering.LIKE/ILIKEwith escaping gives the same results, ClickHouse already rewritesLIKE '%x%'to a substring search, and one SQL shape for both dialects is simpler to review.notContainsand friends.CH.not(...)covers it.Validation
Run in the PR worktree, with a live ClickHouse 26.8.2.7 (the CI version) and
EFFECT_ORM_CLICKHOUSE_*set, so no suite is skipped:bun run build: pass.bun run typecheck: pass.bunx vitest run --testTimeout=60000 --hookTimeout=60000: 61 files passed, 1059 tests passed, 0 skipped. (The long timeouts are only for a loaded machine.)node scripts/check-doc-citations.mjs: ok (25 files).node scripts/check-exports-documented.mjs: ok (289 /clickhouse, 207 /postgres exports).node scripts/check-doc-examples.mjs: ok (21 files typechecked).bun scripts/check-package.ts: isolated tarball and CommonJS consumer ok.Upstream CI for a fork PR waits for a maintainer to approve the run.
Need help on this PR? Tag
@codesmith-botwith what you need.