Parsing of literal composite type containing array
See original GitHub issueAs per https://github.com/hasura/graphql-engine/issues/1041, I’m using the literal type escape hatch in order to insert a record into a table which contains a composite type.
This is a simplified sql mockup of my data:
CREATE TYPE public.value_qualifier AS
ENUM ('qualifier1','qualifier2','qualifier3','qualifier4');
CREATE TYPE public.value_qualified AS
(
value text,
qualifier public.value_qualifier[]
);
CREATE TABLE public.test (
id serial NOT NULL,
value public.value_qualified,
CONSTRAINT test_pkey PRIMARY KEY (id)
);
The issue arises when trying to insert data into the value
column that contains more than one element in the array.
That’s a bit of a mouthful, so as a set of examples, this works using the HTTP interface that graphiQL uses (not tested on graphQL):
{
value: "('some-text',{})"
}
This also works
{
value: "('some-text',{qualifier1})"
}
However, this doesn’t:
{
value: "('some-text',{qualifier1,qualifier2})"
}
The error I’m getting is something like Warning: Missing translation for key: "{"path":"$.args","error":"malformed array literal: \"{qualifier1\"","code":"data-exception"}"
Not having looked at the source code I’ve been scratching my head as to why this happens. It looks to me as if the parsing of the composite type does something like split(",", x)
in a way that divides the string within the parentheses into x number of values. However, if this is the case, the parsing is breaking the array up.
It’s as if hasura is sending {qualifier1
as a value, hence the malformed array error
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Was looking into related issue regarding escaping and found that this seems to work:
Parsing can potentially be handled using:
Bump! My colleague @ilica and I just ran into this, and it would be pretty nice to be able to pass straight JSON into columns typed as ARRAYs.