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

fix: Handle proper type conversion on sort nodes. #228

Merged
merged 2 commits into from
Mar 2, 2022

Conversation

jsimnz
Copy link
Member

@jsimnz jsimnz commented Feb 24, 2022

Closes #227.

This ensures that decoded values from the fetcher are consistent with respect to the float/int edge case of the CBOR encoding/decoding.

@jsimnz jsimnz added bug Something isn't working area/query Related to the query component labels Feb 24, 2022
@jsimnz jsimnz added this to the DefraDB v0.2.1 milestone Feb 24, 2022
@jsimnz jsimnz self-assigned this Feb 24, 2022
@codecov
Copy link

codecov bot commented Feb 24, 2022

Codecov Report

Merging #228 (097cc08) into develop (ffd2236) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #228      +/-   ##
===========================================
- Coverage    57.95%   57.94%   -0.01%     
===========================================
  Files           99       99              
  Lines         9636     9648      +12     
===========================================
+ Hits          5585     5591       +6     
- Misses        3426     3432       +6     
  Partials       625      625              
Impacted Files Coverage Δ
document/encoded.go 65.59% <50.00%> (-2.31%) ⬇️

@@ -87,6 +87,20 @@ func (e EncProperty) Decode() (core.CType, interface{}, error) {
}
val = stringArray
}
} else { // CBOR often encodes values typed as floats as ints
switch e.Desc.Kind {
case base.FieldKind_FLOAT:
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure all these cases are needed - only uint64 is hit according to codecov - it would be wierd if it used int/unit, but int64 might be due to lack of negative number testing. Happy(ier?) for them all to stay in for now, but maybe (in an ideal world with lots of free time) we could revist this

Copy link
Member Author

Choose a reason for hiding this comment

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

I know at the very least it uses int64 and uint64 depending on if its a negative number. Im pretty sure I can drop the other cases.

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

Looks good - cheers for sorting this out, is a nice oddity to get rid of

@jsimnz jsimnz merged commit 263d912 into develop Mar 2, 2022
@jsimnz jsimnz deleted the jsimnz/fix/order-node-sort-types branch March 2, 2022 12:01
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Handled CBOR encoding edge case

* Fixed tests which manually casted results to uint64 due to previous encoding inconsistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Order queries panic on float types after document update
2 participants