-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Enhance QueryConditionBuilder
with offset expression methods and simplify NestedSetsBehavior
updates.
#52
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
…ods and simplify `NestedSetsBehavior` updates.
WalkthroughThis update refactors the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant NestedSetsBehavior
participant QueryConditionBuilder
participant Database
Caller->>NestedSetsBehavior: moveNode(context, currentTree, targetTree)
alt Same tree
NestedSetsBehavior->>NestedSetsBehavior: executeSameTreeMove(context, currentTree)
NestedSetsBehavior->>QueryConditionBuilder: createOffsetUpdates(...)
QueryConditionBuilder-->>NestedSetsBehavior: offset updates
NestedSetsBehavior->>Database: update nodes with offset updates
else Cross tree
NestedSetsBehavior->>NestedSetsBehavior: executeCrossTreeMove(context, treeAttr, currentTree, targetTree)
NestedSetsBehavior->>QueryConditionBuilder: createOffsetUpdates(...)
QueryConditionBuilder-->>NestedSetsBehavior: offset updates
NestedSetsBehavior->>Database: update nodes for cross-tree move
end
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.15)Note: Using configuration file /phpstan.neon. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 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 (12)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 130 137 +7
===========================================
Files 4 4
Lines 525 554 +29
===========================================
+ Hits 525 554 +29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 (2)
src/NestedSetsBehavior.php
(15 hunks)src/QueryConditionBuilder.php
(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: terabytesoftw
PR: yii2-extensions/nested-sets-behavior#13
File: src/NestedSetsBehavior.php:145-145
Timestamp: 2025-06-29T11:22:41.889Z
Learning: The user terabytesoftw prefers to keep PRs focused and small, implementing enhancements in separate dedicated PRs rather than bundling multiple changes together.
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: phpunit / PHP 8.2-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.3-ubuntu-latest
- GitHub Check: phpunit / PHP 8.3-windows-latest
- GitHub Check: phpunit / PHP 8.1-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.1-windows-latest
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
🔇 Additional comments (14)
src/QueryConditionBuilder.php (3)
7-7
: LGTM! Clean import statement update.The addition of
Connection
andExpression
imports is appropriate for the new offset expression methods.
214-250
: Well-implemented SQL expression generator with proper security measures.The method correctly:
- Uses
quoteColumnName()
to prevent SQL injection- Handles positive and negative offsets appropriately
- Returns proper
Expression
objects for safe SQL generation
251-292
: Clean wrapper method for bulk offset expressions.Good implementation that promotes code reuse and maintains consistency across multiple attribute updates.
src/NestedSetsBehavior.php (11)
170-186
: Excellent refactoring using the new QueryConditionBuilder methods.The changes improve code clarity and maintainability by replacing manual SQL expression construction with the standardized helper methods.
518-536
: Clean refactoring with improved method chaining.Good simplification that removes unnecessary temporary variables while maintaining functionality.
804-820
: Consistent refactoring pattern applied.Maintains the same clean approach as other query methods.
903-910
: Clean simplification of sibling query.
947-966
: Consistent refactoring maintains code quality.
1038-1045
: Well-structured sibling query refactoring.
1068-1077
: Simplified attribute assignment improves readability.
1099-1106
: Consistent simplification in root node initialization.
1156-1166
: Excellent separation of concerns in node movement logic.The delegation to specialized methods for same-tree and cross-tree movements improves code clarity and maintainability.
1220-1232
: Consistent use of QueryConditionBuilder for attribute shifting.
1467-1503
: Well-structured refactoring with improved parameter ordering.The changes make the method signature more intuitive by placing the current tree value before the target tree value, and the implementation consistently uses the new QueryConditionBuilder methods.
Summary by CodeRabbit
Refactor
New Features
Chores