pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christophe Pettus <xof@thebuild.com>
To: Tony Shelver <tshelver@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: JSONB order?
Date: Thu, 5 Nov 2020 08:12:56 -0800
Message-ID: <2871D4AD-7885-40BF-86A7-90E321C4E3AF@thebuild.com> (raw)
In-Reply-To: <CAG0dhZCROB_8usnZ_WytoVrYdvRYn3GRTYQuXPY15-ybcya17w@mail.gmail.com>
References: <CAG0dhZD8tAuSe3mQQ1sUfj92njUgHQ39sht4yNamkJfZx386gg@mail.gmail.com>
	<85B65AB1-BD99-4F15-9B33-86F2B00EA106@thebuild.com>
	<CAG0dhZAYGKsiYf5qHKbE6H-+f3Pw3tWdcBywc3sQ-k3_uL7mPA@mail.gmail.com>
	<CAG0dhZCROB_8usnZ_WytoVrYdvRYn3GRTYQuXPY15-ybcya17w@mail.gmail.com>



> On Nov 5, 2020, at 07:45, Tony Shelver <tshelver@gmail.com> wrote:
> Thanks Christophe, that's what I thought.  
> Just seemed weird that they were 'disordered' in exactly the same way every time.
> 
> FYI, as of Python 3.7, dicts are ordered.
> 
> The problem is that we are possibly going to have many versions of these forms with slightly differing keys, which will be a pain to order in some hard coded way.

As Magnus noted, you can use JSON instead of JSONB.  JSON is basically a text blob with a syntax check wrapper around it, so it will be order-stable once created.  (If you run it through a JSONB-expecting function, then the ordering may change again.)  It's less efficient to operate on than JSONB, but that might be OK for your purposes.

--
-- Christophe Pettus
   xof@thebuild.com






view thread (9+ messages)  latest in thread

Message-ID: <2871D4AD-7885-40BF-86A7-90E321C4E3AF@thebuild.com>
Permalink:  ../2871D4AD-7885-40BF-86A7-90E321C4E3AF@thebuild.com/
Also on:    postgresql.org/message-id/2871D4AD-7885-40BF-86A7-90E321C4E3AF@thebuild.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: xof@thebuild.com, tshelver@gmail.com
  Subject: Re: JSONB order?
  In-Reply-To: <2871D4AD-7885-40BF-86A7-90E321C4E3AF@thebuild.com>
  References: <CAG0dhZD8tAuSe3mQQ1sUfj92njUgHQ39sht4yNamkJfZx386gg@mail.gmail.com> <85B65AB1-BD99-4F15-9B33-86F2B00EA106@thebuild.com> <CAG0dhZAYGKsiYf5qHKbE6H-+f3Pw3tWdcBywc3sQ-k3_uL7mPA@mail.gmail.com> <CAG0dhZCROB_8usnZ_WytoVrYdvRYn3GRTYQuXPY15-ybcya17w@mail.gmail.com> <2871D4AD-7885-40BF-86A7-90E321C4E3AF@thebuild.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox