Skip to content

Commit 6508c9d

Browse files
abnegateclaude
andcommitted
fix(sql): wrap json_encode value with LIKE wildcards in array CONTAINS fallback
The fallback LIKE branch in getSQLCondition for CONTAINS/CONTAINS_ANY/NOT_CONTAINS on array attributes was binding json_encode(value) without wrapping in '%' wildcards, so instead of substring-matching the JSON-encoded value inside the column, it required exact equality. This branch is unreachable on MariaDB (JSON_OVERLAPS is supported) but is the actual code path on SQLite which has no JSON_OVERLAPS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5132496 commit 6508c9d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Database/Adapter/MariaDB.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,8 +1649,8 @@ protected function getSQLCondition(Query $query, array &$binds): string
16491649
Query::TYPE_NOT_STARTS_WITH => $this->escapeWildcards($value) . '%',
16501650
Query::TYPE_ENDS_WITH => '%' . $this->escapeWildcards($value),
16511651
Query::TYPE_NOT_ENDS_WITH => '%' . $this->escapeWildcards($value),
1652-
Query::TYPE_CONTAINS, Query::TYPE_CONTAINS_ANY => ($query->onArray()) ? \json_encode($value) : '%' . $this->escapeWildcards($value) . '%',
1653-
Query::TYPE_NOT_CONTAINS => ($query->onArray()) ? \json_encode($value) : '%' . $this->escapeWildcards($value) . '%',
1652+
Query::TYPE_CONTAINS, Query::TYPE_CONTAINS_ANY => ($query->onArray()) ? '%' . $this->escapeWildcards(\json_encode($value)) . '%' : '%' . $this->escapeWildcards($value) . '%',
1653+
Query::TYPE_NOT_CONTAINS => ($query->onArray()) ? '%' . $this->escapeWildcards(\json_encode($value)) . '%' : '%' . $this->escapeWildcards($value) . '%',
16541654
default => $value
16551655
};
16561656

0 commit comments

Comments
 (0)