-
Notifications
You must be signed in to change notification settings - Fork 4
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
diffs cardinality many through, inc tests #153
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #153 +/- ##
==========================================
+ Coverage 85.71% 87.25% +1.54%
==========================================
Files 1 1
Lines 91 102 +11
==========================================
+ Hits 78 89 +11
Misses 13 13
☔ View full report in Codecov by Sentry. |
f1499ca
to
08751b8
Compare
lib/ecto_diff.ex
Outdated
[_ | _] = diff -> | ||
List.flatten(diff) | ||
|
||
_ -> |
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.
ℹ️ I don't quite understand what is expected value here... perhaps an empty list?
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.
If the through
key is present, but the assoc_field
key is not, the return could be [nil]
, so _ ->
was to handle both [] || [nil]
. I have changed how we handle this so it can expect only empty lists.
lib/ecto_diff.ex
Outdated
[_ | _] = diff -> | ||
List.flatten(diff) | ||
|
||
_ -> |
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.
ℹ️ This should just be an empty list:
_ -> | |
[] -> |
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.
At the time, the return could also be [nil]
. Changed the way we handle this.
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.
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.
Unfortunately, without the select_fields option changes, testing the fallback when getting a diff for cardinality many through is difficult. In a sense, this is good; almost always EctoDiff should be able to retrieve the diff for the association via the through association diff, eliminating duplicate work being required. However, this has been tested locally by disabling the default path (get already diffed values) and verifying that all the tests still pass. Currently, the only test for this case is when there is no change on the through association, which triggers the fallback and as a side effect verifies that the default path matches the fallback path.
Resolves polymorphism association many through causes error.
Does this by first checking if the association has already been diffed in the association
If not then builds the diff.