Re: JSON query help - Mailing list pgsql-novice

From Tom Lane
Subject Re: JSON query help
Date
Msg-id 31920.1567024996@sss.pgh.pa.us
Whole thread Raw
In response to Re: JSON query help  (Gavin Henry <gavin.henry@gmail.com>)
Responses Re: JSON query help
List pgsql-novice
Gavin Henry <gavin.henry@gmail.com> writes:
> This is 9.6 with BDR in.

Um ... I bet not.  Maybe you're confusing the version of psql with
that of the server?  Because jsonb_build_object() is definitely
there in 9.6.

> ERROR:  operator does not exist: jsonb @> json

This one you just need a cast for --- the server won't automatically
convert json to jsonb.  (I don't remember why we didn't make that
cast implicit, but probably there was a good reason.)

> How can I check if that function does exist?

On a 9.6 server, you should get

=# \df jsonb_build_object
                                 List of functions
   Schema   |        Name        | Result data type | Argument data types |  Type
------------+--------------------+------------------+---------------------+--------
 pg_catalog | jsonb_build_object | jsonb            |                     | normal
 pg_catalog | jsonb_build_object | jsonb            | VARIADIC "any"      | normal
(2 rows)

If, as I suspect, it's really 9.4, you could substitute
    json_build_object(...)::jsonb

            regards, tom lane



pgsql-novice by date:

Previous
From: Gavin Henry
Date:
Subject: Re: JSON query help
Next
From: Tom Browder
Date:
Subject: Anyone recommend omnidb.org?