[PR #1576] Chained selectable matching #9631

Open
opened 2026-01-22 16:04:56 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/1576

State: closed
Merged: No


The purpose is to make it possible to do selectable matching keeping the _lazy behavior_, aggregating the criterias until the collection is initialized(used)

$selectable->matching(Criteria::create())->matching(Criteria::create())->matching(Criteria::create());

The current behavior get the results as soon as you call the matching, and it forces us to build the full criteria before calling matching, however, if this change is approved it will do the query only when the selectable is in fact used (any other method)

PS: I ended up in this solution because the second call to matching (which should filter it on ArrayCollection) was giving me a collection with results I didn't expect to see, and that probably means that there is some sort of issue with ArrayCollection matching, but maybe I am missing something.

I also would like some advice in the $this->any() on the tests. I did it to make sure that the cloned mock will receive the same value provided in the original one, but I couldn't use $this->once(), because it would fail in the original mock.

**Original Pull Request:** https://github.com/doctrine/orm/pull/1576 **State:** closed **Merged:** No --- The purpose is to make it possible to do selectable matching keeping the **_lazy behavior**_, aggregating the criterias until the collection is initialized(used) ``` php $selectable->matching(Criteria::create())->matching(Criteria::create())->matching(Criteria::create()); ``` The current behavior get the results as soon as you call the matching, and it forces us to build the full criteria before calling matching, however, if this change is approved it will do the query only when the selectable is in fact used (any other method) PS: I ended up in this solution because the second call to matching (which should filter it on ArrayCollection) was giving me a collection with results I didn't expect to see, and that probably means that there is some sort of issue with ArrayCollection matching, but maybe I am missing something. _I also would like some advice in the `$this->any()` on the tests. I did it to make sure that the cloned mock will receive the same value provided in the original one, but I couldn't use `$this->once()`, because it would fail in the original mock._
admin added the pull-request label 2026-01-22 16:04:56 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9631