fauna/fauna-js

Bug on translating numbers to floats.

cleve-fauna opened this issue · 1 comments

an issue with js driver, this line:

      await faunaAnalyticsClient.query(fql`${0.000008}`);

is producing this on the wire:

{"arguments":{},"query":{"fql":[{"value":{"@double":"0.000008"}}]}}

but this line (pay attention to the extra decimal place):

      await faunaAnalyticsClient.query(fql`${0.0000008}`);

is producing this on the wire:

{"arguments":{},"query":{"fql":[{"value":{"@int":"8e-7"}}]}}

here is the bug: https://github.com/fauna/fauna-js/blob/main/src/tagged-type.ts#L145

We are trusting toString to give us a decimal representation.