Skip to content

Commit

Permalink
#188 - Fix double encoding bug (doubles being encoded as integers) (#189
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cleve-fauna authored Jul 25, 2023
1 parent fec7173 commit afc8275
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions __tests__/unit/tagged-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ describe.each`
${LONG_MAX} | ${LONG_MAX} | ${long_type} | ${"@long"} | ${"2**64 - 1"}
${1.3 ** 63} | ${1.3 ** 63} | ${"number"} | ${"@double"} | ${"1.3**63"}
${1.3} | ${1.3} | ${"number"} | ${"@double"} | ${"1.3"}
${0.000000008} | ${0.000000008} | ${"number"} | ${"@double"} | ${"0.000000008"}
`(
`Properly encodes and decodes number $testCase`,
async ({ input, expected, expectedType, tag, testCase }) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fauna",
"version": "0.9.3",
"version": "0.9.4",
"description": "A driver to query Fauna databases in browsers, Node.js, and other Javascript runtimes",
"homepage": "https://fauna.com",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion src/tagged-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const encodeMap = {
throw new RangeError(`Cannot convert ${value} to a Fauna type.`);
}

if (`${value}`.includes(".")) {
if (!Number.isInteger(value)) {
return { "@double": value.toString() };
} else {
if (value >= INT_MIN && value <= INT_MAX) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/package-version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//THIS FILE IS AUTOGENERATED. DO NOT EDIT. SEE .husky/pre-commit

/** The current package version. */
export const packageVersion = "0.9.3";
export const packageVersion = "0.9.4";

0 comments on commit afc8275

Please sign in to comment.