feat: Add wrapOnWhere() method to group JOIN ON conditions#253
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #253 +/- ##
=========================================
Coverage 95.68% 95.68%
- Complexity 2034 2038 +4
=========================================
Files 137 137
Lines 5764 5775 +11
=========================================
+ Hits 5515 5526 +11
Misses 249 249 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new wrapOnWhere() method to JoinTrait that wraps all currently registered ON conditions of the last registered JOIN into a single nested AND-group, mirroring the existing WhereTrait::wrapWhere(). This enables ORM scopes on joined relations to stay protected from later orOnWhere additions, supporting cycle/orm#567.
Changes:
- Add
wrapOnWhere(): selftoJoinTrait, with a no-op when no JOIN is registered or the last JOIN has no ON tokens. - Add unit tests covering no-op cases, wrapping behavior, last-join targeting, and isolation from WHERE tokens.
- Add functional tests verifying the produced SQL across realistic JOIN scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Query/Traits/JoinTrait.php | Introduces wrapOnWhere() mirroring wrapWhere() for JOIN ON tokens. |
| tests/Database/Unit/Query/Tokens/SelectQueryTest.php | Unit tests covering token-level behavior including no-op and last-join targeting. |
| tests/Database/Functional/Driver/Common/Query/SelectWithJoinQueryTest.php | Functional tests verifying generated SQL for typical wrap scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🔍 What was changed
Added
SelectQuery::wrapOnWhere()method🤔 Why?
Required for cycle/orm#567
📝 Checklist