-
Notifications
You must be signed in to change notification settings - Fork 55
Fix PDOException on increment array attribute #605
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 changes update the validation logic in both Changes
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
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/Database/Database.php (1)
5135-5136: Validation correctly rejects array‐typed attributes
The added check|| $attr->getAttribute('array')ensuresincreaseDocumentAttributenow throws aTypeExceptionwhen targeting an array field, aligning with the PR objective.
Nit: refine the exception message to “cannot” for consistency.- throw new TypeException('Attribute must be an integer or float and can not be an array.'); + throw new TypeException('Attribute must be an integer or float and cannot be an array.');
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/Database/Database.php(1 hunks)tests/e2e/Adapter/Scopes/AttributeTests.php(1 hunks)tests/e2e/Adapter/Scopes/DocumentTests.php(7 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/Database/Database.php (1)
src/Database/Document.php (1)
getAttribute(212-219)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Setup & Build Docker Image
🔇 Additional comments (7)
tests/e2e/Adapter/Scopes/AttributeTests.php (1)
1177-1177: LGTM! Good code cleanup.Removing the unused exception variable
$efrom the catch clause is a good practice. Since the exception isn't used within the catch block, this change improves code quality by eliminating an unused variable.tests/e2e/Adapter/Scopes/DocumentTests.php (6)
15-15: LGTM! Correct import for TypeException.The import is properly added to enable specific exception type checking in the updated test methods.
981-981: LGTM! Proper array attribute setup for testing.The 'sizes' attribute is correctly configured as an integer array to test the new validation logic for increment operations on array attributes.
988-988: LGTM! Appropriate test data for array attribute.The test data provides a simple integer array that can be used to verify that increment operations on array attributes are properly rejected.
1056-1062: LGTM! Improved test precision with specific exception type checking.The updated test method now specifically verifies that a
TypeExceptionis thrown when attempting to increment a string attribute, which is more precise than the previous generic exception expectation.
1067-1078: LGTM! Essential test for array increment validation.This new test method properly verifies that increment operations on array attributes throw a
TypeException, directly addressing the core issue mentioned in the PR objective. The test follows established patterns and is correctly implemented.
968-968: LGTM! Good formatting improvements.The added blank lines improve code readability and method separation, following good coding practices.
Also applies to: 1023-1023
Summary by CodeRabbit
Bug Fixes
Tests