Align contains query with utopia-php/database semantics#28
Merged
Conversation
The ClickHouse adapter translated Query::contains/notContains into IN/NOT IN lists — exact-value set matching. utopia-php/database treats contains on scalar attributes as a substring match: each value becomes LIKE '%value%' (OR'd together), and notContains becomes NOT LIKE (AND'd). Generate the same SQL here, escaping LIKE wildcards in the needles so '%' and '_' match literally. The Database adapter already delegates to utopia-php/database and needs no change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MkhSkCMPSXuJ4aY3T7XMbg
Greptile SummaryThis PR aligns ClickHouse usage queries with substring matching semantics. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "Add e2e coverage for LIKE wildcard escap..." | Re-trigger Greptile |
Verifies against a real server that '%' and '_' in contains needles match literally through the bound-parameter path: a '%' needle matches only the metric containing a literal percent sign, and 'cache_hit' does not match 'cache%hit'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MkhSkCMPSXuJ4aY3T7XMbg
abnegate
approved these changes
Jul 21, 2026
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.
What
The ClickHouse adapter translated
Query::contains/Query::notContainsinto SQLIN (...)/NOT IN (...)— exact-value set matching.utopia-php/databasetreatscontainson scalar attributes as a substring match instead. This aligns the adapter with that behavior:contains('attr', [v1, v2])→(attr LIKE '%v1%' OR attr LIKE '%v2%')notContains('attr', [v1, v2])→(attr NOT LIKE '%v1%' AND attr NOT LIKE '%v2%')%,_,\) in needles are escaped so they match literally, mirroring the database library'sescapeWildcardsstartsWith/endsWithhandlingThe Database adapter already delegates
contains/notContainstoutopia-php/databaseand needed no change.Behavior note
containsis now a genuine superset match:contains('metric', ['requests'])also matches a hypotheticalsub-requestsmetric. This is the database library's documented behavior; callers wanting exact set membership should useQuery::equalwith an array.Tests
testContainsQueryextended with substring assertions ('band'matchesbandwidth)testNotContainsQuerycovering negated substring matchingUsageBase🤖 Generated with Claude Code
https://claude.ai/code/session_01MkhSkCMPSXuJ4aY3T7XMbg
Generated by Claude Code