Open etienne-cartong opened 2 years ago
@etienne-cartong you need to implement event listeners on the Demo entity (https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#implementing-event-listeners). as when you encrypt the data and when it reach DB for persisting, it's already encrypted and every time you encrypt the data, it returns a different string every time. so at the DB level, the Unique constrain is honored. so you have to check yourself in code instead of relying on the UniqueEntity annotation.
It might not been an issue, but it's something I'm struggling with.
I'm working a project based on Symfony 4. I'm trying to make the @UniqueEntity works on an @Encrypted field, and I can't figure out how.
Without the @Encrypted annotation, the @UniqueEntity annotation prevents the duplication With the @Encrypted annotation, the @UniqueEntity annotation allows the duplication I feel like I'm missing something obvious here :)
Any idea ?
Maybe I'm not doing this right. But I want to encrypt stuff in my db and still avoid duplication. How else could I tackle this ?