-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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] Hasura doesn't calculate correctly small numbers _inc #4733
Comments
What postgres type are you using to store these values? And can you please also show which values you are adding up (including before, after, and expected values)? Note that the (Worse: adding two |
@abooij I am using numeric and I need values down to 1E-8 |
@perrosnk Could you please show which values you are adding up (including before, after, and expected values)? |
@abooij I am actually trying to decrement a value using |
@perrosnk Sorry, I'm really going to need some more details in order to reproduce this issue. Can you please show a sequence of GraphQL queries and their corresponding outputs, indicating precisely where you believe Hasura to be mistaken? |
@abooij I have a model I want to decrement the The amount is a variable sent by the user, and is update_users_by_pk(pk_columns: {id: "${senderId}"}, _inc: {balance: ${-amount}}) {
id
} hasura mistakenly decrements the balance by By the way, the variable Was that information enough or do you need any further information? Please let me know Edit: const senderId = "alonguuid"
const amount = 1E-8 |
Hi @perrosnk I guess it is getting clearer what the issue is. You are trying to send the literal Since this is not an actual valid graphql query:
because the variable usage is not graphql syntax. Could you send the final query that is being sent to the server? |
@tirumaraiselvan @abooij Here is the actual graphql string: mutation MyMutation {
update_users_by_pk(pk_columns: {id: "aLongUUID"}, _inc: {balance: -1e-8}) {
id
}
}
|
Thanks for reporting this, @perrosnk. I have found the origin of this issue. I will send in a PR to fix this today or tomorrow. |
@abooij Could this be released to npm as a patch version (ex.1.2.2) or do we need to wait for the next release? |
@perrosnk As a workaround, you can either pass the value as a string, or convert it to non-scientific notation. In other words, the following queries should work: mutation MyMutation {
update_users_by_pk(pk_columns: {id: "aLongUUID"}, _inc: {balance: "-1e-8"}) {
id
}
} mutation MyMutation {
update_users_by_pk(pk_columns: {id: "aLongUUID"}, _inc: {balance: 0.00000001}) {
id
}
} |
@abooij I tested the option of |
@perrosnk I'm sorry to hear the workaround doesn't work for you. Make sure you are using the quote symbols, so passing the value as In any case, I have prepared a fix for this, so hopefully this will be part of graphql-engine soon. |
@abooij I passed |
…sion (#4741) Fixes #4733. See also hasura/graphql-parser-hs#29.
@abooij Thank you very much for this! When may we expect this to be released? |
@perrosnk Keep an eye out for the latest releases, hopefully this fix will be released soon! |
…sion (#4741) Fixes #4733. See also hasura/graphql-parser-hs#29.
If you use a number less than 0.000001 (6 decimals) which javascript converts it to 1E-7 hasura doesn't calculate correctly the _inc value.
This has caused a lot of trouble to us. Could we expect a fix?
The text was updated successfully, but these errors were encountered: