Postgraphile: Numeric is returned as string

Created on 5 Oct 2018  路  1Comment  路  Source: graphile/postgraphile

I'm reporting a bug I came across when upgrading to PostGraphile version: 4.0.0

Minimal SQL file that can be loaded into a clean database:

CREATE TABLE test (
    id text PRIMARY KEY,
    name text,
    integer integer,
    numeric numeric,
    float float
);
INSERT INTO "public"."test"("id","name","integer","numeric","float")
VALUES (E'row1',E'string',22,33.3,44.44);

Current behaviour:

image

Expected behaviour:

the numeric column should be return as float and not as string.
"numeric": "33.3", -> "numeric": 33.3,

鉁栵笍 invalid

Most helpful comment

This is not a bug, it's actually the fix to a bug. It's not possible to represent arbitrary precision numbers such as NUMERIC / DECIMAL as GraphQL floats (64-bit IEEE754 floating point numbers).

This is documented in the migration guide here:

https://www.graphile.org/postgraphile/v3-migration/#very-large-numbers

And there's a couple of plugins you can use to restore the old behaviour:

>All comments

This is not a bug, it's actually the fix to a bug. It's not possible to represent arbitrary precision numbers such as NUMERIC / DECIMAL as GraphQL floats (64-bit IEEE754 floating point numbers).

This is documented in the migration guide here:

https://www.graphile.org/postgraphile/v3-migration/#very-large-numbers

And there's a couple of plugins you can use to restore the old behaviour:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

k-ogawa-1988 picture k-ogawa-1988  路  3Comments

ssomnoremac picture ssomnoremac  路  5Comments

safaiyeh picture safaiyeh  路  3Comments

kilianc picture kilianc  路  4Comments

marshall007 picture marshall007  路  3Comments