From 5b44243c1ba16e13a6e3af9786d807f6ed791413 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 3 Jun 2025 12:42:24 +0300 Subject: [PATCH 1/3] added _deletedAt to $deletedAt translation --- src/Database/Adapter/SQL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index 85916ad00..c621b512b 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -1738,6 +1738,7 @@ protected function getInternalKeyForAttribute(string $attribute): string '$tenant' => '_tenant', '$createdAt' => '_createdAt', '$updatedAt' => '_updatedAt', + '$deletedAt' => '_deletedAt', '$permissions' => '_permissions', default => $attribute }; From 4792316e34a3e13a62a2389a3ea089e06836abfb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Apr 2026 04:53:18 +0000 Subject: [PATCH 2/3] add symmetric _deletedAt handling in getDocument and getAttributeProjection Agent-Logs-Url: https://github.com/utopia-php/database/sessions/68d0e3c1-0a6e-486c-875a-24e50241ccf4 Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com> --- src/Database/Adapter/SQL.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index c621b512b..2304e86b9 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -386,6 +386,10 @@ public function getDocument(string $collection, string $id, array $queries = [], $document['$updatedAt'] = $document['_updatedAt']; unset($document['_updatedAt']); } + if (\array_key_exists('_deletedAt', $document)) { + $document['$deletedAt'] = $document['_deletedAt']; + unset($document['_deletedAt']); + } if (\array_key_exists('_permissions', $document)) { $document['$permissions'] = json_decode($document['_permissions'] ?? '[]', true); unset($document['_permissions']); @@ -1707,6 +1711,10 @@ protected function getAttributeProjection(array $selections, string $prefix = '' $selections[] = $this->getInternalKeyForAttribute('$updatedAt'); $selections = \array_diff($selections, ['$updatedAt']); } + if (\in_array('$deletedAt', $selections)) { + $selections[] = $this->getInternalKeyForAttribute('$deletedAt'); + $selections = \array_diff($selections, ['$deletedAt']); + } if (\in_array('$collection', $selections)) { $selections[] = $this->getInternalKeyForAttribute('$collection'); $selections = \array_diff($selections, ['$collection']); From 26e34164e21eb892a48f61cf4786761bae8b3f50 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Apr 2026 05:03:42 +0000 Subject: [PATCH 3/3] fix: only select _deletedAt when explicitly requested; add Mongo adapter support Agent-Logs-Url: https://github.com/utopia-php/database/sessions/b90d2aa4-7e7a-4baf-9931-9b151266a79e Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com> --- src/Database/Adapter/Mongo.php | 1 + src/Database/Adapter/SQL.php | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Database/Adapter/Mongo.php b/src/Database/Adapter/Mongo.php index 77c7f22d2..b4c9da0f5 100644 --- a/src/Database/Adapter/Mongo.php +++ b/src/Database/Adapter/Mongo.php @@ -2055,6 +2055,7 @@ protected function getInternalKeyForAttribute(string $attribute): string '$tenant' => '_tenant', '$createdAt' => '_createdAt', '$updatedAt' => '_updatedAt', + '$deletedAt' => '_deletedAt', '$permissions' => '_permissions', default => $attribute }; diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index a4b3e5e69..a4011df4f 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -2434,15 +2434,20 @@ protected function getAttributeProjection(array $selections, string $prefix): mi '$permissions', '$createdAt', '$updatedAt', - '$deletedAt', ]; - $selections = \array_diff($selections, [...$internalKeys, '$collection']); + $hasDeletedAt = \in_array('$deletedAt', $selections); + + $selections = \array_diff($selections, [...$internalKeys, '$deletedAt', '$collection']); foreach ($internalKeys as $internalKey) { $selections[] = $this->getInternalKeyForAttribute($internalKey); } + if ($hasDeletedAt) { + $selections[] = $this->getInternalKeyForAttribute('$deletedAt'); + } + $projections = []; foreach ($selections as $selection) { $filteredSelection = $this->filter($selection);