-
Notifications
You must be signed in to change notification settings - Fork 573
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
Realm not converting a flat number 1.0
into double
correctly
#6219
Comments
@maichongju Thank you for reporting. We will try to reproduce in our tests to find the root cause. If you have tried with a version prior to 12, did you observe the same error? |
I am sorry, but I don't have a setup for pre12. Is there any update on this issue? |
For whoever might have the same issue. The workaround I am using right now is to add or subtract a very small number (0.00001) when const flat_number = 1.0
if (Number.isInteger(flat_number)){
flat_number = flat_number + 0.00001;
} |
@kneth Did you release a fix for this? It's been more than a year, and Realm is still throwing exceptions for "int," "double," etc., due to the optimization of NodeJS converting to the smallest type possible. We are obliged to set everything as a "number," which is not ideal. Let me know if there's a workaround better than transforming the value itself. Thank you |
I believe this is a bug on app services, where we get the number 1 in json and treat it as an integer. Unfortunately, resolving it could impact many customers, so we'll have to be careful about how we approach it. In the meantime, you could do could try and tell the server that you explicitly want a double by passing in the ejson double representation: await mongoUser.mongoClient('mongodb-atlas').db('main').collection('test').insertOne({
geoLocation: {
type: 'Point',
coordinates: [ { $numberDouble: "1.0" }, { $numberDouble: "2.0" }],
}
}) It is obviously less convenient and you could probably add a helper function to avoid having to write the expansion everytime. |
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. |
How frequently does the bug occur?
Always
Description
When inserting a flat number
1.0
into the MongoDB Atlas. Realm does not convert the number intodouble
. When the schema is defined as only acceptdouble
datatype, insertion will failed.Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
test
on MongoDB atlas with the following validation schema.insert not permit
errorVersion
"realm": "^12.2.1",, "@realm/react": "^0.6.0",
What services are you using?
Atlas App Services: Functions or GraphQL or DataAPI etc
Are you using encryption?
No
Platform OS and version(s)
Win11 23H2
Build environment
Which debugger for React Native: ..
Cocoapods version
No response
The text was updated successfully, but these errors were encountered: