8.14.5 jsonb subscripting
8.14.5 jsonb subscripting
От:
PG Doc comments form <noreply@postgresql.org>
Дата:
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/16/datatype-json.html
Description:
Using subscripts with square brackets is not supported, one must use -> or
#> operators
The given examples result in error:
SELECT ('{"a": 1}'::jsonb)['a'];
-- Extract nested object value by key path
SELECT ('{"a": {"b": {"c": 1}}}'::jsonb)['a']['b']['c'];
-- Extract array element by index
SELECT ('[1, "2", null]'::jsonb)[1];
Re: 8.14.5 jsonb subscripting
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Arne Sommerfelt writes: > I am running on AWS RDS - it says engine version 12.17 i thought that was > the postgres version. If so, the [] subscripting should be supported > according to docs. According to what docs? Generic subscripting was added in v14. regards, tom lane
Re: 8.14.5 jsonb subscripting
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Arne Sommerfelt writes: > Thank you! When googling it is easy to end up with latest docs, > unfortunately That's actually good news --- it used to be that Google would tend to steer people to very ancient versions of our docs. Sounds like the SEO work that we've done is paying off. However, if you're running a moderately old PG version, you need to make use of the links at the top of the page to go to the equivalent page in the older version's docs. regards, tom lane
Re: 8.14.5 jsonb subscripting
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 9 Apr 2024, at 16:07, Arne Sommerfelt wrote: > > OK, sorry if am making unnecessary noise. Since my version was listed as supported I assumed the docs was valid for me. No worries, we're all here to learn. The "supported version" means that 12 is a version which the project still supports with bugfixes. -- Daniel Gustafsson
Re: 8.14.5 jsonb subscripting
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 9 Apr 2024, at 16:04, Arne Sommerfelt wrote: > > 12 is in the list of supported versions at the top of chapter 8.14. And the non-working examples is in subsection 8.14.5 I think you've misunderstood the header of the page. This is the documentation you should be reading for your version if Postgres: https://www.postgresql.org/docs/12/index.html -- Daniel Gustafsson
Re: 8.14.5 jsonb subscripting
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 9 Apr 2024, at 16:02, Arne Sommerfelt wrote: > Thats the documentation for v16, not the version you are running. -- Daniel Gustafsson
Re: 8.14.5 jsonb subscripting
От:
Arne Sommerfelt <arne.sommerfelt@gmail.com>
Дата:
Thank you! When googling it is easy to end up with latest docs, unfortunately
Arne
tir. 9. apr. 2024 kl. 16:06 skrev Daniel Gustafsson <daniel@yesql.se>:
> On 9 Apr 2024, at 16:04, Arne Sommerfelt <arne.sommerfelt@gmail.com> wrote:
>
> 12 is in the list of supported versions at the top of chapter 8.14. And the non-working examples is in subsection 8.14.5
I think you've misunderstood the header of the page. This is the documentation
you should be reading for your version if Postgres:
https://www.postgresql.org/docs/12/index.html
--
Daniel Gustafsson
Re: 8.14.5 jsonb subscripting
От:
Arne Sommerfelt <arne.sommerfelt@gmail.com>
Дата:
12 is in the list of supported versions at the top of chapter 8.14. And the non-working examples is in subsection 8.14.5
tir. 9. apr. 2024 kl. 16:02 skrev Arne Sommerfelt <arne.sommerfelt@gmail.com>:
tir. 9. apr. 2024 kl. 16:00 skrev Tom Lane <tgl@sss.pgh.pa.us>:Arne Sommerfelt <arne.sommerfelt@gmail.com> writes:
> I am running on AWS RDS - it says engine version 12.17 i thought that was
> the postgres version. If so, the [] subscripting should be supported
> according to docs.
According to what docs? Generic subscripting was added in v14.
regards, tom lane
Re: 8.14.5 jsonb subscripting
От:
Arne Sommerfelt <arne.sommerfelt@gmail.com>
Дата:
OK, sorry if am making unnecessary noise. Since my version was listed as supported I assumed the docs was valid for me.
Thanks for your help
cheers
Arne
tir. 9. apr. 2024 kl. 16:04 skrev Daniel Gustafsson <daniel@yesql.se>:
> On 9 Apr 2024, at 16:02, Arne Sommerfelt <arne.sommerfelt@gmail.com> wrote:
> <image.png>
Thats the documentation for v16, not the version you are running.
--
Daniel Gustafsson
Re: 8.14.5 jsonb subscripting
От:
Arne Sommerfelt <arne.sommerfelt@gmail.com>
Дата:
Thank you all for super prompt and friendly support.
Best regards
Arne
tir. 9. apr. 2024 kl. 16:26 skrev Tom Lane <tgl@sss.pgh.pa.us>:
Arne Sommerfelt <arne.sommerfelt@gmail.com> writes:
> Thank you! When googling it is easy to end up with latest docs,
> unfortunately
That's actually good news --- it used to be that Google would
tend to steer people to very ancient versions of our docs.
Sounds like the SEO work that we've done is paying off.
However, if you're running a moderately old PG version, you need
to make use of the links at the top of the page to go to the
equivalent page in the older version's docs.
regards, tom lane
Re: 8.14.5 jsonb subscripting
От:
Arne Sommerfelt <arne.sommerfelt@gmail.com>
Дата:
I am running on AWS RDS - it says engine version 12.17 i thought that was the postgres version. If so, the [] subscripting should be supported according to docs.
Arne
tir. 9. apr. 2024 kl. 13:16 skrev Laurenz Albe <laurenz.albe@cybertec.at>:
On Tue, 2024-04-09 at 09:31 +0000, PG Doc comments form wrote:
> Page: https://www.postgresql.org/docs/16/datatype-json.html
>
> Using subscripts with square brackets is not supported, one must use -> or
> #> operators
> The given examples result in error:
>
> SELECT ('{"a": 1}'::jsonb)['a'];
>
> -- Extract nested object value by key path
> SELECT ('{"a": {"b": {"c": 1}}}'::jsonb)['a']['b']['c'];
>
> -- Extract array element by index
> SELECT ('[1, "2", null]'::jsonb)[1];
You must be using an old PostgreSQL version where that is not yet supported.
Yours,
Laurenz Albe
Re: 8.14.5 jsonb subscripting
От:
Arne Sommerfelt <arne.sommerfelt@gmail.com>
Дата:
tir. 9. apr. 2024 kl. 16:00 skrev Tom Lane <tgl@sss.pgh.pa.us>:
Arne Sommerfelt <arne.sommerfelt@gmail.com> writes:
> I am running on AWS RDS - it says engine version 12.17 i thought that was
> the postgres version. If so, the [] subscripting should be supported
> according to docs.
According to what docs? Generic subscripting was added in v14.
regards, tom lane
Re: 8.14.5 jsonb subscripting
От:
Arne Sommerfelt <arne.sommerfelt@gmail.com>
Дата:
I checked with SELECT VERSION(); and got:
PostgreSQL 12.17 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit
tir. 9. apr. 2024 kl. 15:05 skrev Arne Sommerfelt <arne.sommerfelt@gmail.com>:
I am running on AWS RDS - it says engine version 12.17 i thought that was the postgres version. If so, the [] subscripting should be supported according to docs.Arnetir. 9. apr. 2024 kl. 13:16 skrev Laurenz Albe <laurenz.albe@cybertec.at>:On Tue, 2024-04-09 at 09:31 +0000, PG Doc comments form wrote:
> Page: https://www.postgresql.org/docs/16/datatype-json.html
>
> Using subscripts with square brackets is not supported, one must use -> or
> #> operators
> The given examples result in error:
>
> SELECT ('{"a": 1}'::jsonb)['a'];
>
> -- Extract nested object value by key path
> SELECT ('{"a": {"b": {"c": 1}}}'::jsonb)['a']['b']['c'];
>
> -- Extract array element by index
> SELECT ('[1, "2", null]'::jsonb)[1];
You must be using an old PostgreSQL version where that is not yet supported.
Yours,
Laurenz Albe
Re: 8.14.5 jsonb subscripting
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Tuesday, April 9, 2024, Arne Sommerfelt <arne.sommerfelt@gmail.com> wrote:
Thank you! When googling it is easy to end up with latest docs, unfortunately
The 12 is a hyperlink so it is almost just as easy to view the current page in the prior version.
David J.
Re: 8.14.5 jsonb subscripting
От:
Laurenz Albe <laurenz.albe@cybertec.at>
Дата:
On Tue, 2024-04-09 at 09:31 +0000, PG Doc comments form wrote:
> Page: https://www.postgresql.org/docs/16/datatype-json.html
>
> Using subscripts with square brackets is not supported, one must use -> or
> #> operators
> The given examples result in error:
>
> SELECT ('{"a": 1}'::jsonb)['a'];
>
> -- Extract nested object value by key path
> SELECT ('{"a": {"b": {"c": 1}}}'::jsonb)['a']['b']['c'];
>
> -- Extract array element by index
> SELECT ('[1, "2", null]'::jsonb)[1];
You must be using an old PostgreSQL version where that is not yet supported.
Yours,
Laurenz Albe