Skip to content
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

Bug: Soft deletes and model validation when unique #4162

Closed
mmacagnan opened this issue Jan 26, 2021 · 3 comments
Closed

Bug: Soft deletes and model validation when unique #4162

mmacagnan opened this issue Jan 26, 2021 · 3 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@mmacagnan
Copy link

Hi,

I try to use the soft deletes provided by framework, but when use in validation rules unique,
it doesn't ignores the deleted records.

@mmacagnan mmacagnan added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 26, 2021
@VipinFarswan
Copy link

VipinFarswan commented Jan 31, 2021

Its not a bug.Suppose you added new email in database which already exits in db but currently soft deleted but when in future you want to restore that soft deleted data then you will have two entries with same email in database.So if you don't have any intention to restore soft deleted data then its better to deleted that entry.

@jbotka
Copy link
Contributor

jbotka commented Feb 3, 2021

Hi,

I try to use the soft deletes provided by framework, but when use in validation rules unique,
it doesn't ignores the deleted records.

Hi @mmacagnan :)

You are mixing two things together. UNIQUE attribute is database constraint and soft delete is just CodeIgniter way how to select (ignore soft deleted rows). But you can not have two same unique values in the database (NEVER).

This is not bug. Works as designed ;)

@mmacagnan
Copy link
Author

Thanks for the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

4 participants