From: | Guyren Howe <guyren(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Text value within composite function result not quoted |
Date: | 2017-05-16 04:24:39 |
Message-ID: | A59CB1ED-A307-47ED-8D2E-4CE9BDF10B95@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Define a couple of types:
CREATE TYPE request_in AS
(
path text[],
args jsonb,
server text,
port smallint,
headers jsonb,
body bytea,
type_requested text[]
);
CREATE TYPE request_out AS
(
status smallint,
headers jsonb,
body text
);
and a function:
CREATE OR REPLACE FUNCTION request(
req request_in)
RETURNS "request_out"
LANGUAGE 'plv8'
COST 100.0
VOLATILE
AS $function$
return {'status': 200, 'headers': {}, 'body': "<body>Works!</body>"}
$function$;
call the function:
SELECT request(
(
'{}',
'{}'::jsonb,
'',
8080,
'{}'::jsonb,
''::bytea,
'{}')::request_in
)
get this result:
(200,{},<body>Works!</body>)
This is the textual representation of the result I get in psql and Ruby. Note that the textual final value is not quoted.
I imagine I can work out a way to deal with this, but this is not the most felicitous way of representing a text value that I can imagine.
Note that if I add a single space after “Works!”, I get quotes around the string.
This is 9.6.2 on MacOS.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-05-16 04:36:21 | Re: Text value within composite function result not quoted |
Previous Message | Adrian Klaver | 2017-05-15 23:45:46 | Re: Help: Installing 9.6 breaks local connections to 9.2 on Centos 6.9 |