-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🐛 Fix label & method countResults to display good things with simple pager #8183
🐛 Fix label & method countResults to display good things with simple pager #8183
Conversation
But doesn't this make the simple pager super slow on huge datasets? I thought the whole reason to use the simple pager is because the count of the normal pager would take too long for certain entities? |
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.
But doesn't this make the simple pager super slow on huge datasets? I thought the whole reason to use the simple pager is because the count of the normal pager would take too long for certain entities?
This is exactly the purpose of the SimplePager. You lost every benefit with such implementation.
src/Datagrid/SimplePager.php
Outdated
/** @var ProxyQuery $query */ | ||
$query = $this->getQuery(); | ||
|
||
if (null === $query) { | ||
throw new \LogicException('Uninitialized query.'); | ||
} | ||
|
||
$query->select(sprintf('COUNT(%s.id)', $query->getRootAlias())); | ||
$query->setFirstResult(0); | ||
$query->setMaxResults(1); | ||
|
||
|
||
return $query->getDoctrineQuery()->getSingleScalarResult(); |
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.
This is wrong, you're introducing a dependy on Sonata\DoctrineORMAdminBundle
but SonataAdmin is supposed to work with any other database bundle like https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle or a custom one.
You can only use method from the ProxyQueryInterface API.
You're right, I'm going to lean more towards the idea of displaying something like this: "25+". |
4346a40
to
63db464
Compare
#8205 strategy should be preferred |
Subject
Using SimplePager renders wrong statement on batch actions.
For example: selecting 50 elements (on a table containing >1000 elements) the batch action checkbox "all_elements" would result in "all elements (51)".
Now with this PR, the display will change. A second basic query will be used to count the total number of results.
Using the example above, this would give: "all elements (1000)".
Closes #8164.
Changelog