-
-
Notifications
You must be signed in to change notification settings - Fork 344
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 exception message at ModelManager::batchDelete()
#1734
Conversation
f33f699
to
ed03b55
Compare
22bb576
to
4b66cc7
Compare
15c3ae2
to
85fd814
Compare
@@ -45,6 +45,8 @@ final class ModelManager implements ModelManagerInterface, LockInterface, ProxyR | |||
{ | |||
public const ID_SEPARATOR = '~'; | |||
|
|||
private const BATCH_SIZE = 20; |
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.
Could be useful to introduce the size as parameter
public function batchDelete(string $class, BaseProxyQueryInterface $query, int $batchSize = self::DEFAULT_BATCH_SIZE): void
f0004fb
to
1ec6d3b
Compare
src/Model/ModelManager.php
Outdated
{ | ||
if (!$query instanceof ProxyQueryInterface) { | ||
throw new \TypeError(sprintf('The query MUST implement %s.', ProxyQueryInterface::class)); | ||
} | ||
|
||
// NEXT_MAJOR: Remove this assignment. |
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.
You don't need to wait next major.
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 forgot our classes are (finally 😆) final now 🚀
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.
Could you apply the same for mongoDB?
@@ -345,7 +347,7 @@ public function addIdentifiersToQuery(string $class, BaseProxyQueryInterface $qu | |||
$qb->andWhere(sprintf('( %s )', implode(' OR ', $sqls))); | |||
} | |||
|
|||
public function batchDelete(string $class, BaseProxyQueryInterface $query): void | |||
public function batchDelete(string $class, BaseProxyQueryInterface $query, int $batchSize = self::BATCH_SIZE): void |
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.
shouldn't we add this to the interface? or at least with a next major comment?
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.
We cant add this to the interface since it wont be bc but yes we can add the next major constant and introduce the constant in the SonataAdminBundle instead
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 was thinking about the constant in SonataAdmin
, but I think this must be kept in the scope of each model manager (the behavior regarding the batch size, the way each driver handles the transactions and the cost it demands is specific and not a common concern).
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.
If we can't add the constant to the SonataAdmin interface, we can't add the batchSize parameter to the interface too.
I'm fine with both solution.
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.
Then what is the use case for adding this parameter on the function? How are you suposed to pass it on an admin?
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.
It would be easier to add it to the interface, but even if we don't, people can still pass the batch size as third parameter after a instanceof check.
Subject
I am targeting this branch, because this change respects BC.
Related to sonata-project/SonataDoctrineMongoDBAdminBundle#811 (comment).
Closes #1735.
Changelog