Closed mkrecek234 closed 2 years ago
Model is currently a domain/scope, eg. violation any conditions must always throw/rollback and never allow to save out-of-scope model data.
What you need is to have a Model /wo such filtering conditions and then close it for filtering an unread messages. But when saving such message as read, you must use the unfiltered model or remove the filtering cond before save.
Please post also the traversing back and forth case which might be solveable, but here is nothing we can do.
The only thing I think we can do is introduce a flag to every condition marking if such condition is filtering one or a model/hard one, if non-hard, we can ignore such condition on save.
Even if we will ignore conditions set outside Model::init(), it is not logical to be able to save a record that cannot be selected later
Typical usecase is softdelete. I belive such usecase, and answer/solution for you?, is to temporary relax/ignore such condition during save in try&finally (remove&restore) approach
Reopening as in Discord discussion. Also see branch https://github.com/atk4/data/tree/save_wo_scope
I am closing this issue. We can discuss it under your PR. No need for 2 places.
Steps to reproduce:
Current workaround: change reaload_after_save of model to false.
Problem for developers: Saving values to entity which might result that they no longer are part of a model with conditions happens regularly.
Idea: The reload will be performed to the model without conditions to ensure entity can be found.