Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Database/Adapter/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,7 @@ protected function getInternalKeyForAttribute(string $attribute): string
'$tenant' => '_tenant',
'$createdAt' => '_createdAt',
'$updatedAt' => '_updatedAt',
'$deletedAt' => '_deletedAt',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

LGTM! Verify the complete implementation of $deletedAt support.

The mapping addition follows the established pattern correctly and aligns with the existing timestamp attribute mappings ($createdAt and $updatedAt). This change enables the SQL adapter to recognize and translate the $deletedAt attribute for soft delete functionality.

Please verify that the implementation is complete by checking if similar handling for $deletedAt is needed in:


🏁 Script executed:

#!/bin/bash
# Description: Check if $deletedAt handling is needed in other methods like $createdAt and $updatedAt

echo "=== Checking getDocument method for timestamp handling patterns ==="
ast-grep --pattern $'if (\array_key_exists($_, $document)) {
    $document[$_] = $document[$_];
    unset($document[$_]);
}'

echo "=== Checking getAttributeProjection method for timestamp selection handling ==="
ast-grep --pattern $'if (\in_array($_, $selections)) {
    $selections[] = $this->getInternalKeyForAttribute($_);
    $selections = \array_diff($selections, [$_]);
}'

echo "=== Searching for any existing references to deletedAt ==="
rg -i "deletedat|deleted_at" --type php

Length of output: 845


Add symmetric handling for $deletedAt in SQL adapter

You’ve correctly added the '$deletedAt' => '_deletedAt' mapping, but to fully support soft deletes you’ll need to mirror the same conversion logic used for $createdAt and $updatedAt:

• In getDocument (around lines 381–388) convert _deletedAt back to deletedAt.
• In getAttributeProjection (around lines 1702–1708) include _deletedAt when deletedAt is selected.
• If your updateDocuments method applies special logic for _updatedAt, consider whether deletedAt updates need similar handling.

Please add these adjustments to ensure the adapter correctly translates and projects the deletedAt attribute.

🤖 Prompt for AI Agents
In src/Database/Adapter/SQL.php around lines 381 to 388, 1702 to 1708, and near
the updateDocuments method, you need to add symmetric handling for the
$deletedAt attribute to fully support soft deletes. Specifically, in
getDocument, convert the internal key _deletedAt back to deletedAt like you do
for _createdAt and _updatedAt. In getAttributeProjection, when deletedAt is
selected, include _deletedAt in the selections array similarly to the other
timestamps. Also, review updateDocuments for any special logic applied to
_updatedAt and add equivalent handling for deletedAt updates if needed. This
ensures consistent translation and projection of the deletedAt attribute
throughout the adapter.

'$permissions' => '_permissions',
default => $attribute
};
Expand Down