8000 UniqueEntityValidator: Retrieve at max two entities to check uniqueness. by AndreasA · Pull Request #43611 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

UniqueEntityValidator: Retrieve at max two entities to check uniqueness. #43611

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

Merged
merged 1 commit into from
Oct 26, 2021
Merged

UniqueEntityValidator: Retrieve at max two entities to check uniqueness. #43611

merged 1 commit into from
Oct 26, 2021

Conversation

AndreasA
Copy link
Contributor
@AndreasA AndreasA commented Oct 20, 2021
Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Tickets Fix #43254
License MIT
Doc PR symfony/symfony-docs#15965

It is enough to retrieve two entities to check for uniqueness.

  • No entity returned, it is definitely unique.
  • Two or more entities returned and it cannot be unique.
  • One entity returned, it depends on the entity if it is unique or not.

By providing a limit it avoids potential performance and memory issues in case the entity uniqueness check is not done on a unique field.

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@AndreasA AndreasA marked this pull request as ready for review October 20, 2021 11:07
@carsonbot carsonbot added this to the 5.4 milestone Oct 20, 2021
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@AndreasA AndreasA changed the title UniqueEntityValidator: Retrieve at max two entities to check uniqueness. [DoctrineBridge] UniqueEntityValidator: Retrieve at max two entities to check uniqueness. Oct 20, 2021
@carsonbot carsonbot changed the title [DoctrineBridge] UniqueEntityValidator: Retrieve at max two entities to check uniqueness. UniqueEntityValidator: Retrieve at max two entities to check uniqueness. Oct 20, 2021
@carsonbot
Copy link

Hey!

I think @GromNaN has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@fabpot
Copy link
Member
fabpot commented Oct 26, 2021

Thank you @AndreasA.

@fabpot fabpot merged commit ed3660a into symfony:5.4 Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DoctrineBridge] [Validator] UniqueEntityValidator should limit the retrieved entities to 2 to avoid potential memory issues with broad queries
6 participants
0