Skip to content

Conversation

@shimonewman
Copy link
Contributor

@shimonewman shimonewman commented Jun 3, 2025

Summary by CodeRabbit

  • New Features
    • Added support for handling a deleted timestamp attribute in the database adapter.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 3, 2025

Walkthrough

A new mapping was added in the SQL adapter's internal method to associate the attribute key '$deletedAt' with the database column '_deletedAt'. This extends the attribute-to-column translation logic to recognize and handle a deleted timestamp attribute.

Changes

File Change Summary
src/Database/Adapter/SQL.php Added mapping for '$deletedAt' to '_deletedAt' in attribute-to-column conversion logic

Poem

A hop and a skip in SQL's den,
Now $deletedAt is mapped again.
From code to column, smooth and neat,
_deletedAt makes the mapping complete.
With every change, the data flows right—
The rabbit’s code is out of sight! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3db51ec and 5b44243.

📒 Files selected for processing (1)
  • src/Database/Adapter/SQL.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup & Build Docker Image

'$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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant