Hi, I don't know if it's my fault but I save the values as double but they are saved as int.
which causes me an error, because I expect a double value
As far as I can see, appwrite approximates the closest value, but that's not what I want. Is there any way to disable this approximation?
Hi - let me take a look at this
are you writing values in console?
can you please elaborate a bit about how you are storing values so i can see if this could be a bug?
Either way, it doesn't save as a double value. Either saving from the console for example default value or values saved from the project
although creating a document from the console does work
we tried replicating this and we are able to make the document with decimal values. Can you elaborate on what are you exactly trying to do (the steps) and/or code piece so we can see what's happening
I already found the reason. It is because when we save a value, for example 25.0, it is saved as 25. But if 25.1 is saved if the double value is respected.
but this generates problems for me because I would have to be converting the values obtained to double
Tagging @Torsten Dittmann here
This might be an interesting issue. I am pretty sure on the backend its handled properly, but Javascript/the browser uses the same data type for both int/float values.
So it is properly saved into the backend, but the moment Javascript gets it from the Database, it makes it an integer. On many other languages it should be interpreted correctly.
Mmm I understand. And it is not possible to make a condition .endsWith(".00") and if it is fulfilled, apply a toFixed?
or the best solution would be to convert the values obtained from the database back to double? although it should be an unnecessary task
In flutter, you'll need to convert/cast it to a double
From the Appwrite side, it is expected to return something like:
{
"price": 333
}
JSON is JavaScript and JavaScript does not differentiate between int or double. As such, whole numbers will be simplified to drop the decimals.
In a language that differentiates the two, you'll have to convert it accordingly. For example, you can do json["price"]?.toDouble()
.
or you can use the num
type
Ok friend thanks, if there is no other way I will choose to convert the values to double 👍
[SOLVED] double attributes are saved as int
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.
- Current User is Not authorized
recreating same Thread