Skip to content

feat: Add wrapOnWhere() method to group JOIN ON conditions#253

Merged
roxblnfk merged 2 commits into
2.xfrom
wrap-on-where
May 28, 2026
Merged

feat: Add wrapOnWhere() method to group JOIN ON conditions#253
roxblnfk merged 2 commits into
2.xfrom
wrap-on-where

Conversation

@roxblnfk
Copy link
Copy Markdown
Member

🔍 What was changed

Added SelectQuery::wrapOnWhere() method

🤔 Why?

Required for cycle/orm#567

📝 Checklist

  • How was this tested:
    • Tested manually
    • Unit tests added

@roxblnfk roxblnfk requested review from a team as code owners May 28, 2026 19:20
@github-actions github-actions Bot added the type: test Test label May 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.68%. Comparing base (a064944) to head (fdea144).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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(): self to JoinTrait, 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.

@roxblnfk roxblnfk merged commit aafa2f6 into 2.x May 28, 2026
32 checks passed
@roxblnfk roxblnfk deleted the wrap-on-where branch May 28, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants