pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
json_to_recordset not working with camelcase json keys
3+ messages / 2 participants
[nested] [flat]

* json_to_recordset not working with camelcase json keys
@ 2015-12-15 21:46 Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>
  2015-12-15 23:17 ` Re: json_to_recordset not working with camelcase json keys Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Daniel Kellenberger @ 2015-12-15 21:46 UTC (permalink / raw)
  To: pgsql-bugs

Hi all,

We tried to extract from a json with camel case keys values, but unfortunatelly they are not mapped.

Testcase: (PostgreSQL 9.4.5)

select * from json_to_recordset('[{"aB":1,"bC":"foo"},{"aB":"2","cD":"bar"}]') as x(aB int, bC text);

Expected:
aB | bC
1   | foo
2   | null

Actual:
aB  | bC
null | null
null | null

Does anyone knows if this is a bug?
Thanks for any help.

Kind regards,
Daniel

--
Our software sets the course: http://nca.me/software

Daniel Kellenberger | daniel.kellenberger@netcetera.com | T +41 44 297 58 14 |
Netcetera AG | 8040 Z?rich | Switzerland | http://netcetera.com |

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: json_to_recordset not working with camelcase json keys
  2015-12-15 21:46 json_to_recordset not working with camelcase json keys Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>
@ 2015-12-15 23:17 ` Joe Conway <mail@joeconway.com>
  2015-12-17 07:56   ` Re: json_to_recordset not working with camelcase json keys Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Joe Conway @ 2015-12-15 23:17 UTC (permalink / raw)
  To: Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>; pgsql-bugs

On 12/15/2015 01:46 PM, Daniel Kellenberger wrote:
> We tried to extract from a json with camel case keys values, but
> unfortunatelly they are not mapped.
> 
> Testcase: (PostgreSQL 9.4.5)
> 
> select * from
> json_to_recordset('[{"aB":1,"bC":"foo"},{"aB":"2","cD":"bar"}]') as x(aB
> int, bC text);

Not a bug, I believe. You probably meant this:

select * from json_to_recordset('[{"aB":1,"bC":"foo"},
                                  {"aB":"2","cD":"bar"}]')
              as x("aB" int, "bC" text, "cD" text);
 aB | bC  | cD
----+-----+-----
  1 | foo |
  2 |     | bar
(2 rows)

Unquoted identifiers are lowercased in postgres, so for camel case
identifiers you would need double quotes.

HTH,

Joe

-- 
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

Attachments:

  signature.asc (application/pgp-signature, 835B) download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: json_to_recordset not working with camelcase json keys
  2015-12-15 21:46 json_to_recordset not working with camelcase json keys Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>
  2015-12-15 23:17 ` Re: json_to_recordset not working with camelcase json keys Joe Conway <mail@joeconway.com>
@ 2015-12-17 07:56   ` Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Daniel Kellenberger @ 2015-12-17 07:56 UTC (permalink / raw)
  To: Joe Conway <mail@joeconway.com>; pgsql-bugs

Hi Joe

Thanks for your answer, this solved our issue.
In one project we are currently switching from Oracle to PostgreSQL and are excited about the database.

Kind regards,
Daniel

-- 
Our software sets the course: http://nca.me/software

Daniel Kellenberger | daniel.kellenberger@netcetera.com | T +41 44 297 58 14 |
Netcetera AG | 8040 Zürich | Switzerland | http://netcetera.com | 

________________________________________
Von: Joe Conway <mail@joeconway.com>
Gesendet: Mittwoch, 16. Dezember 2015 00:17
An: Daniel Kellenberger; pgsql-bugs@postgresql.org
Betreff: Re: [BUGS] json_to_recordset not working with camelcase json keys

On 12/15/2015 01:46 PM, Daniel Kellenberger wrote:
> We tried to extract from a json with camel case keys values, but
> unfortunatelly they are not mapped.
>
> Testcase: (PostgreSQL 9.4.5)
>
> select * from
> json_to_recordset('[{"aB":1,"bC":"foo"},{"aB":"2","cD":"bar"}]') as x(aB
> int, bC text);

Not a bug, I believe. You probably meant this:

select * from json_to_recordset('[{"aB":1,"bC":"foo"},
                                  {"aB":"2","cD":"bar"}]')
              as x("aB" int, "bC" text, "cD" text);
 aB | bC  | cD
----+-----+-----
  1 | foo |
  2 |     | bar
(2 rows)

Unquoted identifiers are lowercased in postgres, so for camel case
identifiers you would need double quotes.

HTH,

Joe

--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development



-- 
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:[~2015-12-17 07:56 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-12-15 21:46 json_to_recordset not working with camelcase json keys Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>
2015-12-15 23:17 ` Joe Conway <mail@joeconway.com>
2015-12-17 07:56   ` Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>

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