Reputation: 8355
Is there a way to configure UniqueEntity to treat foo
and Foo
as duplicates?
Use case: I have @UniqueEntity("email")
on my user entity, since I'm using the email address as username. According to https://stackoverflow.com/a/9808332/1668200 the local part of an email address is case-sensitive in theory, but case-insensitive in practice.
I could certainly convert it to lowercase in setEmail()
(as suggested at
https://stackoverflow.com/a/31663365/1668200). Drawbacks:
That's not a good idea, since there is a small chance it will not get delivered.
So I'd rather reject the user [email protected]
's registration (if [email protected]
is already present), than convert all users' addresses to lowercase.
Upvotes: 2
Views: 1576
Reputation: 1057
Based on this UniqueEntity:
repositoryMethod type: string default: findBy()
The name of the repository method to use for making the query to determine the uniqueness. If it's left blank, the findBy() method will be used. This method should return a countable result.
You could create a function in the repository to find if that email exists applying UPPER() in the sql.
Upvotes: 3