objection-unique icon indicating copy to clipboard operation
objection-unique copied to clipboard

Use objection-unique with objection-soft-delete

Open ravipatelopenxcell opened this issue 7 years ago • 2 comments

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.

ravipatelopenxcell avatar May 10 '18 06:05 ravipatelopenxcell

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.

nunorafaelrocha avatar May 10 '18 10:05 nunorafaelrocha

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.

mits87 avatar Apr 24 '20 12:04 mits87