Re: SQL/JSON in PostgreSQL

Oleg Bartunov <obartunov@gmail.com>

From: Oleg Bartunov <obartunov@gmail.com>
To: Nico Williams <nico@cryptonector.com>
Cc: "Sven R. Kunze" <srkunze@mail.de>, Magnus Hagander <magnus@hagander.net>, Peter van Hardenberg <pvh@pvh.ca>, Andres Freund <andres@anarazel.de>, David Steele <david@pgmasters.net>, Pavel Stehule <pavel.stehule@gmail.com>, Pgsql Hackers <pgsql-hackers@postgresql.org>, Nikita Glukhov <n.gluhov@postgrespro.ru>, Teodor Sigaev <teodor@postgrespro.ru>, Alexander Korotkov <a.korotkov@postgrespro.ru>, andrew Dunstan <andrew@dunslane.net>
Date: 2017-03-13T10:48:44Z
Lists: pgsql-hackers
On Mon, Mar 13, 2017 at 9:24 AM, Nico Williams <nico@cryptonector.com>
wrote:

> On Thu, Mar 09, 2017 at 07:12:07PM +0100, Sven R. Kunze wrote:
> > From my day-to-day work I can tell, the date(time) type is the only
> missing
> > piece of JSON to make it perfect for business applications (besides,
> maybe,
> > a "currency" type).
>
> And a binary type.  And a chunked-string type (to avoid having to escape
> strings).  And an interval type.  And...
>

Let's first have this basic implementation in postgres, then we'll add
extendability support not only for types, but also for operators.
Right now I see in our regression tests:

select _jsonpath_object(
'["10.03.2017 12:34 +1", "10.03.2017 12:35 +1", "10.03.2017 12:36 +1",
"10.03.2017 12:35 +2", "10.03.2017 12:35 -2"]',
'$[*].datetime("dd.mm.yyyy HH24:MI TZH") ? (@ < "10.03.2017 12:35
+1".datetime("dd.mm.yyyy HH24:MI TZH"))'
);
     _jsonpath_object
--------------------------
 "2017-03-10 14:34:00+03"
 "2017-03-10 13:35:00+03"
(2 rows)

Commits

  1. SQL/JSON: support the IS JSON predicate

  2. SQL/JSON: add standard JSON constructor functions