-
Notifications
You must be signed in to change notification settings - Fork 16
Add snapshot methods to query Builder/Model #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request introduces snapshot functionality across the application. In the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Query/Concerns/UsesSnapshots.php (1)
29-37
: Fix PHPDoc comment to match implementation.The PHPDoc comment references a parameter
$toggle
that doesn't exist in the implementation. Also, the return type in the comment is$this
but the method returnsstatic
.- * @param bool $toggle + * @param TimestampBoundInterface $timestamp * @return $this
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/Connection.php
(1 hunks)src/Query/Builder.php
(2 hunks)src/Query/Concerns/UsesSnapshots.php
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Run-PHPUnit
🔇 Additional comments (4)
src/Query/Builder.php (2)
35-35
: LGTM! Trait integration looks good.The
UsesSnapshots
trait is properly added to theBuilder
class alongside other existing traits that provide similar functionality. This maintains code organization consistency.
246-249
: Implementation for snapshot functionality looks correct.The condition properly checks if snapshots are enabled and adds the necessary options to the query. The implementation follows the same pattern as existing features like data boost and timestampBound.
src/Connection.php (1)
628-630
: Snapshot functionality implementation looks good.The implementation correctly checks for the
snapshotEnabled
option and delegates to the appropriate method. The placement before the existing snapshot check is logical, as it allows for explicitly enabling snapshots through options, while maintaining compatibility with the existinginSnapshot()
method.src/Query/Concerns/UsesSnapshots.php (1)
1-54
: Overall implementation of snapshot trait looks good.The trait is well-structured and follows the existing patterns in the codebase:
- Proper type hints and return types
- Clear method names following convention
- Straightforward implementation of the snapshot functionality
This implementation successfully addresses the PR objective to "introduce the capability to use the
snapshot()
method when executing Eloquent queries on Models, as well as when utilizing the Builder directly."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
README.md (1)
186-210
: Great addition of snapshot reads documentation!The snapshot reads section provides clear examples for all three usage patterns: Connection, Model, and Query Builder. This enhances the documentation by showing the flexibility of the new feature.
However, note that the heading style is inconsistent with other headings in the document. Consider using setext style (with underlines) instead of ATX style (with hash symbols) to match the document's style.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
186-186: Heading style
Expected: setext; Actual: atx(MD003, heading-style)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.md
(1 hunks)src/Connection.php
(2 hunks)src/Query/Concerns/UsesSnapshots.php
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Query/Concerns/UsesSnapshots.php
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
186-186: Heading style
Expected: setext; Actual: atx
(MD003, heading-style)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Run-PHPUnit
🔇 Additional comments (2)
src/Connection.php (2)
28-28
: Appropriate import addition.The TimestampBoundInterface import is needed for proper type checking in the new code path.
629-633
: Well-implemented snapshot execution path.The implementation correctly checks for the snapshot option and handles the execution within the appropriate context. Good use of type assertion to ensure the timestamp bound is of the correct interface type.
The code maintains a clear separation between the existing snapshot functionality and the new opt-in approach, allowing for better backward compatibility.
tests/SnapshotTest.php
Outdated
@@ -46,6 +46,23 @@ public function test_snapshot(): void | |||
$this->assertSame('ok', $result); | |||
} | |||
|
|||
public function test_builder_snapshot(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this test to Query/BuilderTest.php
There was a problem hiding this 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 UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/Query/BuilderTest.php
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Run-PHPUnit
🔇 Additional comments (1)
tests/Query/BuilderTest.php (1)
1078-1096
: Overall test implementation looks goodThis test correctly verifies the snapshot functionality by:
- Confirming the connection is not in snapshot state before the operation
- Running a transaction and inserting test data
- Creating a snapshot query with ExactStaleness
- Verifying the snapshot is properly configured
- Checking that the query returns expected results
The test provides good coverage of the new snapshot capabilities mentioned in the PR objectives.
This PR resolves #231 and adds the ability to specify snapshot() when writing Eloquent queries on Models, or when using Builder directly
It can be used like so:
Summary by CodeRabbit