pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #13972: jsonb_to_record cant map camelcase keys
3+ messages / 3 participants
[nested] [flat]
* BUG #13972: jsonb_to_record cant map camelcase keys
@ 2016-02-18 13:12 zn@dbml.dk
0 siblings, 2 replies; 3+ messages in thread
From: zn@dbml.dk @ 2016-02-18 13:12 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 13972
Logged by: Jacob Zneider
Email address: zn@dbml.dk
PostgreSQL version: 9.4.5
Operating system: OS x 10.11.3
Description:
Try the following:
select * from json_to_record('{"aA":1,"bB":[1,2,3],"c":"bar"}') as x(aA int,
bB text, c text)
first two columns will be empty.
select * from json_to_record('{"aa":1,"bb":[1,2,3],"c":"bar"}') as x(aA int,
bB text, c text)
All columns are mapped.
select * from json_to_record('{"aa":1,"bb":[1,2,3],"c":"bar"}') as x(aa int,
bb text, c text)
All columns are mapped.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #13972: jsonb_to_record cant map camelcase keys
@ 2016-02-18 16:52 David G. Johnston <david.g.johnston@gmail.com>
parent: zn@dbml.dk
1 sibling, 0 replies; 3+ messages in thread
From: David G. Johnston @ 2016-02-18 16:52 UTC (permalink / raw)
To: zn@dbml.dk; +Cc: pgsql-bugs
On Thu, Feb 18, 2016 at 6:12 AM, <zn@dbml.dk> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 13972
> Logged by: Jacob Zneider
> Email address: zn@dbml.dk
> PostgreSQL version: 9.4.5
> Operating system: OS x 10.11.3
> Description:
>
> Try the following:
>
> select * from json_to_record('{"aA":1,"bB":[1,2,3],"c":"bar"}') as x(aA
> int,
> bB text, c text)
>
> first two columns will be empty.
>
> select * from json_to_record('{"aa":1,"bb":[1,2,3],"c":"bar"}') as x(aA
> int,
> bB text, c text)
>
> All columns are mapped.
>
> select * from json_to_record('{"aa":1,"bb":[1,2,3],"c":"bar"}') as x(aa
> int,
> bb text, c text)
>
>
Working as intended.
Unquoted identifiers in SQL are folded to lower case. There is no
difference between the "as x(...)" in your example. They all result in
(aa, bb, c). The fact that json_to_record attempts to match in a
case-sensitive manner is intentional.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #13972: jsonb_to_record cant map camelcase keys
@ 2016-02-18 17:03 Tom Lane <tgl@sss.pgh.pa.us>
parent: zn@dbml.dk
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2016-02-18 17:03 UTC (permalink / raw)
To: zn@dbml.dk; +Cc: pgsql-bugs
zn@dbml.dk writes:
> Try the following:
> select * from json_to_record('{"aA":1,"bB":[1,2,3],"c":"bar"}') as x(aA int,
> bB text, c text)
> first two columns will be empty.
You need to do it like this:
select * from json_to_record('{"aA":1,"bB":[1,2,3],"c":"bar"}') as x("aA" int,
"bB" text, c text);
aA | bB | c
----+---------+-----
1 | [1,2,3] | bar
(1 row)
Without the quotes, the SQL names aA etc are case-folded to aa etc.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2016-02-18 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-02-18 13:12 BUG #13972: jsonb_to_record cant map camelcase keys zn@dbml.dk
2016-02-18 16:52 ` David G. Johnston <david.g.johnston@gmail.com>
2016-02-18 17:03 ` Tom Lane <tgl@sss.pgh.pa.us>
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