-
Notifications
You must be signed in to change notification settings - Fork 823
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
BUG Update DataQuery::exists to return false when limit causes no result to be returned #9946
BUG Update DataQuery::exists to return false when limit causes no result to be returned #9946
Conversation
…ult to be returned
$this->assertTrue(ObjectE::get()->exists()); | ||
$this->assertFalse(ObjectE::get()->where(['"Title" = ?' => 'Foo'])->exists()); | ||
$this->assertTrue(ObjectE::get()->dataQuery()->groupby('"SortOrder"')->exists()); | ||
$this->assertTrue( |
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.
I've updated the scenarios here to test both the DataList exist and the DataQuery exists. I've added scenarios for the limit and added explicit message for each assertion.
LGTM. Needs a lint fix. Wondering if it should also handle cases where |
Why would a limit return zero results? Is this in the instance where you're fetching page 3 or something, and your limit is I wonder how the engine handles an exists statement that has a limit - would you lose potential performance benefits when indexes may not be consulted? I guess it'll have to be extra important that parts of the code that are looking for any record regardless of pagination ensure they have not set a limit on their DataQuery. |
Yes. We can have a look at the performance impact, but this is a regression and we need to find some fix. You can't trigger this behaviour with |
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.
Looks good
Weird behaviour is probably linked to this change 9159137
It's consistent with the original report (on slack) about count()
working correct, though exists()
being strange
The original report also had an replication example provided of $results->limit(4, 12811);
which is a small limit with a huge offset, which is similar to what Guy mentioned earlier re LIMIT 20 OFFSET 40 on a 35 row table
This was raised by @mfendeksilverstripe.
While upgrading from 4.5 to 4.7, he discovered that DataList who are constrained by a limit into retuning 0 results, would still be considered "truthy" when a
if
statement was applied to them in an SS template: