PGBI / cakephp3-soft-delete

83 stars 60 forks source link

Validation IsUnique problem with softdeleted item #34

Open thiagojeffery opened 6 years ago

thiagojeffery commented 6 years ago

Can´t use IsUnique when there is an item softdeleted, the validation ignore it and the DB return "Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry".

abdulzeedo commented 6 years ago

I would suggest to not use soft delete on tables where the primary key is not generated. However, you could always check before inserting if there are soft deleted records with the same primary key.

As for the validation, it should not ignore soft deleted records, how would you guarantee primary key uniqueness otherwise?