Skip to content
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

Feature/unmrashall #13

Merged
merged 4 commits into from
Oct 20, 2023
Merged

Feature/unmrashall #13

merged 4 commits into from
Oct 20, 2023

Conversation

p3ps1-man
Copy link
Contributor

No description provided.

types/types.go Outdated Show resolved Hide resolved
types/types.go Outdated
@@ -89,6 +90,22 @@ func (o *NullBool) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error {

return nil
}
func (o *NullBool) JSONUnmarshal(data []byte) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name of the method UnmarshalJSON -> implements json.Unmarshaler

types/types.go Outdated
@@ -89,6 +90,22 @@ func (o *NullBool) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error {

return nil
}
func (o *NullBool) JSONUnmarshal(data []byte) error {
if len(data) <= 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be just == 0, but also need to handle the case of "null" in bytes

if len(data) == 0 || bytes.Compare(jsonNullBytes, data) == 0 {
  // value is true JSON null

types/types.go Outdated
return nil
}

var isTrue bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for simple types such as JSON boolean, there are only two possible values, we can make a happy path

switch(utils.UnsafeString(data) {
case "true":
case "false" 
default:
 // Fall back to JSON marshaler to the thing

@codecov-commenter
Copy link

Codecov Report

Attention: 18 lines in your changes are missing coverage. Please review.

Comparison is base (c70b088) 31.88% compared to head (2e417d1) 31.54%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
- Coverage   31.88%   31.54%   -0.34%     
==========================================
  Files          24       24              
  Lines        1700     1718      +18     
==========================================
  Hits          542      542              
- Misses       1117     1135      +18     
  Partials       41       41              
Flag Coverage Δ
unit-tests 31.54% <0.00%> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
types/types.go 0.68% <0.00%> (-0.03%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CodeLieutenant CodeLieutenant merged commit 38d0a2e into master Oct 20, 2023
@CerealKiller97 CerealKiller97 deleted the feature/unmrashall branch October 20, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants