Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZC6q3-0005dg-GW for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jul 2015 13:53:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZC6q1-0005hN-Qx for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jul 2015 13:53:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZBMEj-0001z2-Ju for pgsql-bugs@postgresql.org; Sat, 04 Jul 2015 12:08:01 +0000 Received: from mail-wi0-f179.google.com ([209.85.212.179]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZBMEa-0003Fr-Tf for pgsql-bugs@postgresql.org; Sat, 04 Jul 2015 12:08:00 +0000 Received: by wiga1 with SMTP id a1so194983201wig.0 for ; Sat, 04 Jul 2015 05:07:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=KiBzwzSGlHnmjj2hNiJe/Kjpt5k6Lmq7Pbw1VyuS9ks=; b=Qr4Jx5mgQcWLbAbYG09+2M8ZV00SHSHDrWGRTjpEC/BaTtZPBnc0BJ5EQgJeTf3mvI ORD2GgODjhS0ZD5+8T1XRk62Vo1HasI/oYC7KyH3c6Gd/CnmLO5Id6gPEejeHl0fIBJu s9xEWpdYMVM4j6esDXuYgpusIz21CMADG2wv9DndZYs7KvQ9QKQwTGTxNiNicScmLRGt LaZES2KtiSCyzK8HZel2rrl0dB2tht3tX9AeFRpBEBRgQikEmTWGfVq8gFZFniDjUcVT cWizGRUBUWlwZGOTsmudimHmaGyhupBXjR1oNSE3ycRb6k9cJquzTbnoZZn2rEd08+Kf ZUaQ== X-Gm-Message-State: ALoCoQksx1ONVHhA5XKSfoS/nOXukICgFwjoox3HaZHGrwINxHG4PbKLUoa4dv1ftoVUiw8I/hhV X-Received: by 10.180.73.244 with SMTP id o20mr36480724wiv.31.1436011671804; Sat, 04 Jul 2015 05:07:51 -0700 (PDT) Received: from [172.20.10.2] (70.236.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch. [178.197.236.70]) by mx.google.com with ESMTPSA id xa9sm17778705wjc.43.2015.07.04.05.07.50 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 Jul 2015 05:07:51 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_C1D43300-2CB4-461E-A8E1-3AFAB2B6BC0D" Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: BUG #13485: JSONB To recordset not working with CamelCase From: Roberto Morelli In-Reply-To: Date: Sat, 4 Jul 2015 14:07:49 +0200 Cc: "pgsql-bugs@postgresql.org" Message-Id: <19939E93-C49F-4AC2-8A60-CB6D6127322A@oneoverzero.net> References: <20150703144657.1187.69398@wrigleys.postgresql.org> To: "David G. Johnston" X-Mailer: Apple Mail (2.2102) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --Apple-Mail=_C1D43300-2CB4-461E-A8E1-3AFAB2B6BC0D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hello David, yes, it works, thank you!!! CREATE TYPE nsp.TraitInfluence AS ( "traitId" uuid, "direction" nsp.direction_enum, "confidence" nsp.confidence_enum ); Best regards Roberto > On 03 Jul 2015, at 20:53, David G. Johnston = wrote: >=20 > On Friday, July 3, 2015, > wrote: > The following bug has been logged on the website: >=20 > Bug reference: 13485 > Logged by: Roberto Morelli > Email address: roberto.morelli@oneoverzero.net > PostgreSQL version: 9.4.4 > Operating system: MacOSX > Description: >=20 > Hello, >=20 > I have encountered a problem with the jsonb type and the procedure > jsonb_populate_recordset. >=20 > If I have a type defined as: >=20 > CREATE TYPE nsp.confidence_enum AS > ENUM ('probably', 'conclusively', 'reliabily'); >=20 > CREATE TYPE nsp.direction_enum AS > ENUM ('true', 'false'); >=20 > CREATE TYPE nsp.TraitInfluence AS > ( > traitId uuid, > direction nsp.direction_enum, > confidence nsp.confidence_enum > ); >=20 > Note the camel case in traitId of nsp.TraitInfluence. If I try to = populate a > recordset with the jsonb in the following way: >=20 > select jsonb_populate_recordset(null::nsp.TraitInfluence, = '[{"traitId": > "c7fd7224-3f09-4a0a-941d-7a6a96d655b5", "direction": "true", = "confidence": > "probably"}]'::jsonb) >=20 > I get the following result: >=20 > "(,true,probably)" >=20 > That is the traitId value is missing. I cannot change the camel case = in the > json payload because it is a third party data. >=20 > How can I overcome this problem? The correct result should be: >=20 > "(c7fd7224-3f09-4a0a-941d-7a6a96d655b5,true,probably)" >=20 >=20 > Double-quote the field name in the create type statement. >=20 > David J.=20 --Apple-Mail=_C1D43300-2CB4-461E-A8E1-3AFAB2B6BC0D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Hello David,

yes, it works, thank you!!!

CREATE TYPE nsp.TraitInfluence AS
(
"traitId"     = uuid,
"direction"   nsp.direction_enum,
= "confidence" = nsp.confidence_enum
);

Best regards
Roberto

On 03 Jul 2015, at 20:53, David G. Johnston = <david.g.johnston@gmail.com> wrote:

On Friday, July 3, = 2015, <roberto.morelli@oneoverzero.net> wrote:
The following bug has = been logged on the website:

Bug reference:      13485
Logged by:          Roberto Morelli
Email address:      roberto.morelli@oneoverzero.net
PostgreSQL version: 9.4.4
Operating system:   MacOSX
Description:

Hello,

I have encountered a problem with the jsonb type and the procedure
jsonb_populate_recordset.

If I have a type defined as:

CREATE TYPE nsp.confidence_enum AS
ENUM ('probably', 'conclusively', 'reliabily');

CREATE TYPE nsp.direction_enum AS
ENUM ('true', 'false');

CREATE TYPE nsp.TraitInfluence AS
(
        traitId       uuid,
        direction    =  nsp.direction_enum,
        confidence    = nsp.confidence_enum
);

Note the camel case in traitId of nsp.TraitInfluence. If I try to = populate a
recordset with the jsonb in the following way:

select jsonb_populate_recordset(null::nsp.TraitInfluence, = '[{"traitId":
"c7fd7224-3f09-4a0a-941d-7a6a96d655b5", "direction": "true", = "confidence":
"probably"}]'::jsonb)

I get the following result:

"(,true,probably)"

That is the traitId value is missing. I cannot change the camel case in = the
json payload because it is a third party data.

How can I overcome this problem? The correct result should be:

"(c7fd7224-3f09-4a0a-941d-7a6a96d655b5,true,probably)"


Double-quote the field name in the create type = statement.

David= J. 

= --Apple-Mail=_C1D43300-2CB4-461E-A8E1-3AFAB2B6BC0D--