-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] UniqueEntity allow boolean value for repositoryMethod parameter #60441
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
Comments
Returning a boolean wouldn’t work for updates since you wouldn’t know if your method returns |
Yes I know. Of course this would require some thought. $result = $repository->{$constraint->repositoryMethod}(...$arguments); $result = $repository->{$constraint->repositoryMethod}(...$arguments, $value); For example, when $value is entity object and identifierFieldNames is 'id':
This is only example. In this example above, just a COUNT(id) SQL query is enough, instead of SELECT *. It seemed more optimal to me. But this validator doesn't allow this. If it makes sense, I'd be happy to try a pull request. ;-) |
If Is hydration really that costly? If the entities are too large, it's probably because the database was poorly designed or Doctrine shouldn't be used in that part of the code. This solution would only make sense when adding new records. It’s enough to create a method like the one you created and then return something or nothing. However, I don’t think it requires additional code. Anyone who has performance issues can define such a method in the repository and provide its name. |
Hi, it probably doesn't matter if it's a Doctrine entity or not. But I understand that identifierFieldNames is only specified if it's not a Doctrine entity. My mistake for writing it that way. My idea comes from real usage. For example, we have it over an entity where there is a Uuid and 8x scalar column + one OneToOne relation. It's nothing major. But I still think that the classic SELECT * + hydration will be a little less efficient than COUNT(*). But yes, maybe that's an unnecessary hammer to a mosquito. |
Description
I have this code
and the repository method could be
The idea is that I don't need to download the complete data and certainly not hydrate it.
Sometimes just a method like this with COUNT(...) and returning a boolean is enough.
What do you think? Is it OK or would you rather write a new class and your own validator? Or integrate this?
If someone approves, I'll feel free to make a pull request. But if not, I don't want to waste time.
Thank you.
Example
No response
The text was updated successfully, but these errors were encountered: