-
Notifications
You must be signed in to change notification settings - Fork 51
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
fix: Correctly handle serialisation of nil field values #1872
fix: Correctly handle serialisation of nil field values #1872
Conversation
Nil json values were being treated as delete operations. Setting a value to nil is not the same as deleting it.
Codecov ReportPatch coverage:
@@ Coverage Diff @@
## develop #1872 +/- ##
===========================================
- Coverage 70.44% 70.39% -0.04%
===========================================
Files 232 232
Lines 24184 24180 -4
===========================================
- Hits 17034 17021 -13
- Misses 5993 5999 +6
- Partials 1157 1160 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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.
LGTM!
question: I see most tests were removed and TestMutationUpdate_WithArrayOfBooleansToNil
removed the restriction only, if this bug was introduced again, are the existing tests enough to start failing / detect this?
//subdoc fields | ||
// subDoc := doc.values[doc.fields["Address"]].Value().(*Document) |
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.
nitpick: suggest removal
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.
don't further tempt me to remove this file completely :)
@@ -132,7 +132,8 @@ func TestSetWithJSON(t *testing.T) { | |||
assert.Equal(t, doc.values[doc.fields["Name"]].IsDocument(), false) | |||
assert.Equal(t, doc.values[doc.fields["Age"]].Value(), int64(27)) | |||
assert.Equal(t, doc.values[doc.fields["Age"]].IsDocument(), false) | |||
assert.Equal(t, doc.values[doc.fields["Address"]].IsDelete(), true) | |||
assert.Equal(t, doc.values[doc.fields["Address"]].Value(), nil) | |||
assert.Equal(t, doc.values[doc.fields["Address"]].IsDocument(), false) |
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.
question: Just to confirm the following is what we would expect if we tested it right?
assert.Equal(t, doc.values[doc.fields["Address"]].IsDelete(), false)
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.
yes
Yes, the tests would fail if the bug was re-introduced. There tests that were removed were just variants of the tests who's restrictions were removed. The setup and act were the same, but the assert documented the bug. |
…k#1872) ## Relevant issue(s) Resolves sourcenetwork#1842 ## Description Correctly handle serialisation of nil field values. Nil values are not empty byte arrays in CBOR, they need to be handled correctly.
Relevant issue(s)
Resolves #1842
Description
Correctly handle serialisation of nil field values.
Nil values are not empty byte arrays in CBOR, they need to be handled correctly.