-
Notifications
You must be signed in to change notification settings - Fork 46
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
Do not mutate Field::default/system property in scope condition #662
Comments
It's how it was before - BC way of doing things. |
you are right, this is actually hide field (because of system) with nested conditons like (a > 5 or (a = 5)) (the code will trigger becauseof |
It can be implemented to be set to the value only when the condition is definitive - all parent scopes up to root scope have AND junction. We have to look into alternatives to set it as well. |
one possibility, but this can imply default arguments for API etc., which is not fully correct (too implicit) I think we should drop it - what code relies on it? |
The issue is that this functionality is used on model references.
|
please post PR to discuss more concrete - save() works on either loaded row/ID or a new one, right? so if this is only a ref issue, we should be addresses there - you mean the issue is that you will otherwise have to set payment_id on a new row? |
The issue comes from sub-scoping models like here. So new entries are expected to have the value assigned permanently. |
This is quite legit argument - only in this case it can be changed to system But I think, we have only two options:
|
What we can do is check if condition is definite (all parents have AND junction) and only then set the value as deault and lock the field. Quite easy to implement and BC |
we can not - scope can be further modified |
Question is if that changes the definitiveness of the condition. |
The only usecase I see is strictly "helpful/simplified logic for conditions creation in model setup" so I stay firm behind my "two options" - drop completely or allow to define condition with full control - like proposed my question is - what does this approach NOT solve? |
When adding it should save type invoice as it is now.
|
as addEqualToSystemCondition will call addCondition, it behaves 1:1, only with addEqualToSystemCondition there will be side effect of system/default on related field everything other stays, conditions are not definitive, like now, do basically whatever you want ;-) |
I agree with you. |
this and the sensetence below are two different things, right? :)
Something liek that, I tried to stress is MUST ALWAYS BE with for data/ui, we can dump first which functions/usages were using this |
Solution with a method in Model does not work as this needs to be triggered on model change (in case of clones or copying of scopes). I believe the best and cleanest solution is:
|
absolutely not - you use |
I understand the idea of this, for modelling, if and only if a condition is definitive (is always valid), default value can be set, but: a) PK/ID should never be set (fixed in b24d858) |
as mentioned in #662 (comment), we need to check if definitive definitely :) the current design seems to work well, but the problem is when a condition is removed, is this is wanted to be fully supported, we should track the default/system changes from definitive conditions and revert if the conditions are removed. Complicated, but removed conditions should revert the model state completely. Another issue is removed conditions but model used before for traversal /w materialized conditions. But I belive this is fine, as the traversal does not store the originating model. |
see https://github.com/atk4/data/pull/660/files/e1e0ae7947f60c268245e51ca12eafa5a45810dd#diff-d11d2f7d35e15c2e79f43737267e1c00
and related code:
data/src/Model/Scope/Condition.php
Lines 101 to 115 in 2f89724
The text was updated successfully, but these errors were encountered: