-
Notifications
You must be signed in to change notification settings - Fork 814
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
Bug: object with decimals are converted to strings #121
Comments
This seems to be an issue related to how the |
This issue actually applies to decimals, but SurrealDB currently defaults non-integers to decimals not floats: > create thing:float set num = <float> 4.2;
[{"time":"543.52µs","status":"OK","result":[{"id":"thing:float","num":4.2}]}]
> create thing:decimal set num = <decimal> 4.2;
[{"time":"453.885µs","status":"OK","result":[{"id":"thing:decimal","num":"4.2"}]}] As a workaround, you can cast to |
But wouldn't this potentially truncate the |
Yes, and this isn't ideal, but I think that is part of the reason why BigDecimal likes to serialize to string. No matter what language you use SurrealDB with, the value wont be truncated. Serializing the BigDecimal as a float would lead to truncation if deserialized in a language like JavaScript which treats JSON numbers as floats. |
I see your point - unless the client somehow deserializes it to some arbitrary-length decimal type like |
@finnbear I've updated the title |
Ran into the same issue when using the Rust client library with the latest nightly version of the database (v1.0.0-beta.8 `#[derive(Debug,Serialize,Deserialize)] #[derive(Debug,Serialize,Deserialize)] #[tokio::main]
And I get the following error: As described above here the f64 inputs are casted as decimals instead of f64. Is there any work on this, or anything I can do? |
This is no longer an issue on v1. |
Describe the bug
When setting an object, floating numbers are converted to strings
Steps to reproduce
Tested via both REST/curl and node.js (using node-red).
Expected behaviour
A floating number
SurrealDB version
surreal 1.0.0-beta.7 for linux on x86_64
Contact Details
No response
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: