Use objection-unique with objection-soft-delete
I have used "objection-soft-delete" package for soft delete data. I want to handle "objection-unique" with "objection-soft-delete". Currently, it's will also check deleted data.
Hi @ravipatelopenxcell, that's a common problem when using soft delete strategy.
If you state that an entity is soft-deleted and you re-assign the same "unique" field you may face data integrity issues - for instance, if you "undelete" the entity.
I would say our current approach it's correct one. An entity field that it's unique should always be unique (and it should have that constraint on the database as well). If you want to re-assign a field then I believe that you should handle that field on the soft-delete action.
Hi,
actually if we check more advanced packages like Rails ActiveRecord and the Paranoia gem (for soft deletion) then there is a possibility to validate uniqueness of field with NULL or not NULL value.
I think is a common case and it should be supported. Cheers.