1

I'm using a jsonb column, where the JSON documents contain large integers (PostgreSQL 9.5). I've noticed that when the value stored has too many significant digits, it gets truncated.

As an example, I insert this into my table:

{"value": 7598786232076607106}

And when I select back the same row, I get:

{"value": 7598786232076607000}

According to the documentation, numeric fields in jsonb are stored using the standard numeric type from postgres, and numeric normally allows:

up to 131072 digits before the decimal point; up to 16383 digits after the decimal point

Is it possible to actually get this behavior with jsonb, instead of truncation?

asked Apr 30, 2017 at 23:51
4
  • numeric isn't jsonb. In jsonb you're just storing structured text, not binary or decimal numbers. Can you show the query that produces this so we can see the actual origin of the issue? Commented May 1, 2017 at 1:43
  • Maybe I wasn't clear. I was talking about a numeric field in a JSON document stored in a jsonb column. Basically, I insert: {"value": 7598786232076607106}, and when I select back, I get {"value": 7598786232076607000}. The documentation says numeric values in jsonb are using the standard numeric type from postgres. Commented May 1, 2017 at 10:17
  • Please show full, complete SQL example. Commented May 1, 2017 at 11:00
  • Actually, I think that's a rendering problem with PgAdmin 4. Commented May 1, 2017 at 13:34

1 Answer 1

5

The issue wasn't with PostgreSQL itself, but with pgAdmin 4, which apparently is not capable of parsing JSON properly, and truncates the response from PostgreSQL.

I will be using a different tool from now on.

answered May 1, 2017 at 13:39
1
  • Please report a bug too. Commented May 1, 2017 at 23:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.