-
-
Notifications
You must be signed in to change notification settings - Fork 25
Make None default for exclude fields #551
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing a fix. Could you include a test that covers your changes.
Codecov Report
@@ Coverage Diff @@
## main #551 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 285 285
=========================================
Hits 285 285
Continue to review full report at Codecov.
|
|
@saschahofmann other than changing the default type Arguably the use of |
|
Not sure I understand the question? The point of changing the behavior is that I expected all fields to be included when I provide an empty list for excluded fields. Maybe there are more explicit solutions to achieve this (e.g. another flag) but I thought this would already be quite good.
I didnt change the behaviour of the any clause except that now if you provide an empty list the clause will actually return Sorry if I am overexplaining not sure I got it 😅 |
|
@saschahofmann The design of the One way to get around copying all fields would be to provide an exclusion list with one field i.e all except this field. If your looking to get around declaring an excluded or included list of fields this change wouldn’t support copying related data from non declared fields since we also check for the field name existing in list. |
|
I think I'm not trying to get around declaring a list of excluded fields. This change has two effects:
But if I provide a list with one field suddenly all fields except that field are copied. Ok that makes sense but if I provide an empty list I think the logical behaviour would be that all fields are cloned! PS: I'm actually going to comment on the other issue I have open with some more suggestions on how copying all fields could be made more robust. |
|
And I think your last point isn't true? If I now provide an empty list for an exclude the first part of the any will still return false but second part now returns true. That being said maybe I should write a test for that. |
|
@saschahofmann After taking a look seems your right using an empty list should get around the issue. Though I’m still thinking that there should be a better way instead of having a user declare an empty list to get the behaviour of copying all related fields. A separate class property can be used toggle on the copy all related fields functionality as opposed to an empty list and we can always assume the excluded fields to be a list and check for the presence or absence of the field. |
|
I think it'd definitely be an option to create another flag but do you disagree that the naive expectation of providing an empty list (not knowing that it's the default already) would be that it includes are all fields? |
|
Since the presence of a list would create two side effects ie. (Don’t copy field ‘x’ in the list, but also copy all fields if the list is empty). I’ll prefer using a more explicit flag to distinguish between the later. |
|
Interesting, for me that is a single side-effect 😄 and exactly what I expected to happen but I guess we have to agree to disagree here then. |
Closes #549
@jackton1 That's all I had in mind. I had a quick scan over
get_fields_and_unique_fields_from_clswhich seems to be the only other place the excluded fields are used but I don't see anything obvious where this could break things.