-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve LazyCriteriaCollection matching #10640
Improve LazyCriteriaCollection matching #10640
Conversation
I opened a PR within the collection repository for merging two Criteria together Feature Criteria merge. The uninitialized matching return could be changed to |
I think this deserves more explanation, because with your changes, I think calling |
Calling |
Okay, but what it is not initialized? |
That will result in two new lazy collection instances that are not initialized with the merged |
Well if you get 2 collections, chances are, you are going to do things with them eventually. If that's the case, you will initialize them, and end up with 2 SQL queries where there was just one before. Let me know if I'm missing something. |
In one of my projects I'm having a entity with a large With the code in this PR when I call |
I mean, I happily re-approve the CI workflow again and again, but you do know you can run all those checks locally, right? 😓 |
@TheDutchScorpion thanks for the explanation
Are you calling it on the relation again, or are you calling it on the object returned by the first call to |
I'm calling it on the Collection returned by the first |
Old situation
New situation
|
Ok, I think I fully get it now: this postpones the SQL query to $bar = 'bar';
$collection = LazyCriteriaCollection;
$newCollection = $collection->matching(Criteria::expr()->eq('foo', $bar)); // SQL query here
// … later on
$newCollection = $collection->matching(Criteria::expr()->eq('foo', $bar)); // also an SQL query here If that's accurate I'm not sure we can merge this. WDYT @derrabus @SenseException ? |
Maybe it would be an idea to create another fetch type for this, because in some situations you don't want too fetch everything before matching on it. |
If this is going to be merged then I wouldn't to it in 2.15, maybe not even in 2.x. This change in behavior may affect performance for other people negatively, as mentioned before, and I don't see a major advantage in having this behavior in ORM. |
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
This pull request was closed due to inactivity. |
This will prevent initializing when matching on a LazyCriteriaCollection and will keep the Collection lazy.