Skip to content

Commit 18a995b

Browse files
github-actions[bot]claude-bot
authored andcommitted
fix(sqlite): guard json_encode fallback and seal updateAttribute cursor
`getLikeCondition` for array CONTAINS now mirrors MariaDB's `?: ''` guard so NAN/INF (which return `false`) don't degrade into an empty LIKE pattern that silently matches every row. `updateAttribute` resize scan also leaked the prepared cursor when `execute()` threw — the explicit `closeCursor()` came after the fetch and never ran on the failure path. Wrapped in try/finally so the cursor closes regardless.
1 parent 8d6956a commit 18a995b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/Database/Adapter/SQLite.php‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,13 @@ public function updateAttribute(string $collection, string $id, string $type, in
574574
if ($this->sharedTables) {
575575
$stmt->bindValue(':_tenant', $this->tenant, \is_int($this->tenant) ? PDO::PARAM_INT : PDO::PARAM_STR);
576576
}
577-
$stmt->execute();
578577

579-
$exceeds = $stmt->fetchColumn() !== false;
580-
$stmt->closeCursor();
578+
try {
579+
$stmt->execute();
580+
$exceeds = $stmt->fetchColumn() !== false;
581+
} finally {
582+
$stmt->closeCursor();
583+
}
581584

582585
if ($exceeds) {
583586
throw new TruncateException("Attribute '{$id}' has values exceeding new size {$size}");
@@ -3231,7 +3234,7 @@ protected function getLikeCondition(Query $query, array &$binds): string
32313234
Query::TYPE_STARTS_WITH, Query::TYPE_NOT_STARTS_WITH => $this->escapeWildcards($value) . '%',
32323235
Query::TYPE_ENDS_WITH, Query::TYPE_NOT_ENDS_WITH => '%' . $this->escapeWildcards($value),
32333236
Query::TYPE_CONTAINS, Query::TYPE_CONTAINS_ANY, Query::TYPE_NOT_CONTAINS => $onArray
3234-
? '%' . $this->escapeWildcards((string) \json_encode($value)) . '%'
3237+
? '%' . $this->escapeWildcards((string) (\json_encode($value) ?: '')) . '%'
32353238
: '%' . $this->escapeWildcards($value) . '%',
32363239
default => $value,
32373240
};

0 commit comments

Comments
 (0)