Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kai7G-0001zG-Rt for pgsql-general@arkaria.postgresql.org; Thu, 05 Nov 2020 16:28:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kai7F-0003ax-QV for pgsql-general@arkaria.postgresql.org; Thu, 05 Nov 2020 16:28:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kai7F-0003ap-Cs for pgsql-general@lists.postgresql.org; Thu, 05 Nov 2020 16:28:01 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kai7D-0003uh-02 for pgsql-general@lists.postgresql.org; Thu, 05 Nov 2020 16:28:00 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 79so1953752otc.7 for ; Thu, 05 Nov 2020 08:27:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=Dv2T6HXWcxlktsz0wuxStTood5vOaoeN40atL3P78LU=; b=KsxjydTcFm8u4TORlzSdWjhHUmiW7Ld8NR1f9scSyvJcSlk5OBwC1kqIj6bCBxxvpX UONdI72JzgN7tUev/D0c+xpwGlq1xxQdOWxh1+g8P+HsK0UcOirQP4i1sts+qcpR9TmU 05fWnawBsvF/AlrkfHsS1P5d2dewyyiUL89IMDCjonk/N2C1N7yLPuBbvmc02nIBNPmk uQCI3iuF3XiIRnzVSGlt+mcmv1/bP3HB5KGnyyrGh9eRfeKAHSCEpVgXTNXWM95W8ich s5d64M4uPLuHhr5ucSCVS9VbjZcV0dethIi9/Lrc6ZAJEu7vAZMtVqhuK8ORZLcF9EAV hCYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=Dv2T6HXWcxlktsz0wuxStTood5vOaoeN40atL3P78LU=; b=HuBXnAkOvgkNCrmRkRellGYZSwwyyb6EL6POFPKJ070uwHsLgqsoPlTiz3eZTSBE1G JWkflXItd0aq8T+w2NKsptGTop5gJK9RTTmvCWNqq5dwf4pwyAK5k86vINHSwsiEfr5C YH/aaCf8J6d+orrp6EUyPjukkKwLjROAwpbmmpeIdl/IstvyMRgcb2ES4iDA7X0l1P78 tRSUgDL7UJ6N0SGW4P5EoiyACkgbjcNssxg2usRomfI1NZ+n/gxli8neTmU61REoqnmU TA+TKVx9Va0lsq7emt28lHXL4EIXa0/enWOff4oEsC61InI48xp9EAB6B/tybmFG1T0P aXMg== X-Gm-Message-State: AOAM5312j8466KbXsv2nAqQXNabCf6SINXo7wq+pkHx15SwXJwGREwXK NNfqdaZZp3IEeO6yn6OiVxM= X-Google-Smtp-Source: ABdhPJzBcz42cLLDh7eUjiqTW1Oi6fbtVZljO7vEDUcMvSFBcXeYFR0YqSij9QV36imIk4UY+jTdKw== X-Received: by 2002:a9d:645:: with SMTP id 63mr2099777otn.182.1604593678080; Thu, 05 Nov 2020 08:27:58 -0800 (PST) Received: from [192.168.1.104] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id p5sm412207otl.43.2020.11.05.08.27.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Nov 2020 08:27:57 -0800 (PST) From: Rob Sargent Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_FF457B52-4FED-4CF9-B347-44A77ED7A026" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: JSONB order? Date: Thu, 5 Nov 2020 09:27:43 -0700 In-Reply-To: Cc: pgsql-general To: Tony Shelver References: <85B65AB1-BD99-4F15-9B33-86F2B00EA106@thebuild.com> X-Mailer: Apple Mail (2.3608.120.23.2.4) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_FF457B52-4FED-4CF9-B347-44A77ED7A026 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Nov 5, 2020, at 8:45 AM, Tony Shelver wrote: >=20 >=20 >=20 > ---------- Forwarded message --------- > From: Tony Shelver > > Date: Thu, 5 Nov 2020 at 17:45 > Subject: Re: JSONB order? > To: Christophe Pettus > >=20 >=20 > Thanks Christophe, that's what I thought. =20 > Just seemed weird that they were 'disordered' in exactly the same way = every time. >=20 > FYI, as of Python 3.7, dicts are ordered. >=20 > 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. >=20 >=20 >=20 > On Thu, 5 Nov 2020 at 17:40, Christophe Pettus > wrote: >=20 >=20 > > On Nov 5, 2020, at 07:34, Tony Shelver > wrote: > > But... seen above, the order gets mixed up. > >=20 > > Any ideas? >=20 > JSON objects, like Python dicts, are not automatically ordered by key. = Once you move from the column space to the JSON object space, you can't = rely on the object keys being in a consistent order. >=20 > You'll want to have a step when ingesting the JSON object into a = report that lines up the key values appropriately with the right = presentation in the report. > -- > -- Christophe Pettus > xof@thebuild.com >=20 Sounds like you=E2=80=99ll need a separate mechanism for maintaining = versions of the forms and which headers represent the same data concept. = Always access data via canonical header translated to current form. --Apple-Mail=_FF457B52-4FED-4CF9-B347-44A77ED7A026 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Nov 5, 2020, at 8:45 AM, Tony Shelver <tshelver@gmail.com> = wrote:



---------- = Forwarded message ---------
From: Tony Shelver <tshelver@gmail.com>
Date: Thu, 5 = Nov 2020 at 17:45
Subject: Re: JSONB order?
To: Christophe Pettus <xof@thebuild.com>

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.



On Thu, 5 Nov 2020 at 17:40, Christophe = Pettus <xof@thebuild.com> wrote:


> On Nov 5, 2020, at 07:34, Tony Shelver <tshelver@gmail.com> wrote:
> But...  seen above, the order gets mixed up.
>
> Any ideas?

JSON objects, like Python dicts, are not automatically ordered by = key.  Once you move from the column space to the JSON object space, = you can't rely on the object keys being in a consistent order.

You'll want to have a step when ingesting the JSON object into a report = that lines up the key values appropriately with the right presentation = in the report.
--
-- Christophe Pettus
   xof@thebuild.com


Sounds like you=E2=80=99ll = need a separate mechanism for maintaining versions of the forms and = which headers represent the same data concept.  Always access data = via canonical header translated to current form.


= --Apple-Mail=_FF457B52-4FED-4CF9-B347-44A77ED7A026--