Re: BUG #14080: JSONB order changes when using json_pretty()

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: jack(at)fastly(dot)com
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14080: JSONB order changes when using json_pretty()
Date: 2016-04-10 15:54:58
Message-ID: CAKFQuwa6b076timjCWTGeO4goM5v1Mrjhw0LZ9EPk3=6UL2vVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Apr 8, 2016 at 3:43 PM, <jack(at)fastly(dot)com> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 14080
> Logged by: Jack
> Email address: jack(at)fastly(dot)com
> PostgreSQL version: 9.5.2
> Operating system: Mac OSX
> Description:
>
> while looking though datasets I noticed json_pretty is retuning a different
> record.
>
> This query will return an id that I expect and other defendant queries seem
> to work
> ```
> select jsonb_array_elements(details->'version'->'domains'), id from
> services
> order by id limit 1 offset 400;
> ```
>
> This query returns a random record both the id and the json are valid they
> are just the wrong one.
>
> ```
> select jsonb_pretty(details->'version'->'domains'), id from services order
> by id limit 1 offset 400;
> ```
>

​Your subject line and message do not seem to match each other.

WRT the subject line, jsonb documentation states:

> ​jsonb does not preserve white space, does not preserve the order of
object keys, and does not keep duplicate object keys.

So there isn't a bug there.

Without a self-contained example for the message body I'm inclined to
suspect user-error/mis-understanding. Please provide something that
someone else can run to see the misbehavior.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2016-04-10 16:13:20 Re: BUG #14079: Issues with query
Previous Message Miklós Fazekas 2016-04-10 14:17:17 Re: released savepoint blocking further statements