pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <depesz@depesz.com>
To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Misleading docs for SQL/JSON
Date: Thu, 14 Apr 2022 14:59:47 +0200
Message-ID: <20220414125947.GA8532@depesz.com> (raw)

Hi,
in docs for SQL/JSON, specifically these examples:
https://www.postgresql.org/docs/devel/functions-json.html#id-1.5.8.22.7.8.6.6

We can find this:

#v+
SELECT JSON_VALUE('"123.45"', '$' RETURNING float);
 json_value
------------
     123.45
(1 row)

SELECT JSON_VALUE('123.45', '$' RETURNING int ERROR ON ERROR);
 json_value
------------
        123
(1 row)

SELECT JSON_VALUE('"03:04 2015-02-01"', '$.datetime("HH24:MI YYYY-MM-DD")' RETURNING date);
 json_value 
------------
 2015-02-01
(1 row)
#v-

The thing is - none of these queries work:

#v+
$ SELECT JSON_VALUE('"123.45"', '$' RETURNING float);
ERROR:  JSON_VALUE() is not yet implemented for json type
LINE 1: SELECT JSON_VALUE('"123.45"', '$' RETURNING float);
               ^

$ SELECT JSON_VALUE('123.45', '$' RETURNING int ERROR ON ERROR);
ERROR:  JSON_VALUE() is not yet implemented for json type
LINE 1: SELECT JSON_VALUE('123.45', '$' RETURNING int ERROR ON ERROR...
               ^

$ SELECT JSON_VALUE('"03:04 2015-02-01"', '$.datetime("HH24:MI YYYY-MM-DD")' RETURNING date);
ERROR:  JSON_VALUE() is not yet implemented for json type
LINE 1: SELECT JSON_VALUE('"03:04 2015-02-01"', '$.datetime("HH24:MI...
               ^
#v-

They do work if I'll cast the item to jsonb, though:

#v+
$ SELECT JSON_VALUE(jsonb '"03:04 2015-02-01"', '$.datetime("HH24:MI YYYY-MM-DD")' RETURNING date);
 json_value 
────────────
 2015-02-01
(1 row)
#v-





Message-ID: <20220414125947.GA8532@depesz.com>
Permalink:  ../20220414125947.GA8532@depesz.com/
Also on:    postgresql.org/message-id/20220414125947.GA8532@depesz.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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: depesz@depesz.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Misleading docs for SQL/JSON
  In-Reply-To: <20220414125947.GA8532@depesz.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