Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typedef: quote_literal is not unique #16

Open
erichanson opened this issue Jan 27, 2023 · 0 comments
Open

typedef: quote_literal is not unique #16

erichanson opened this issue Jan 27, 2023 · 0 comments

Comments

@erichanson
Copy link
Collaborator

erichanson commented Jan 27, 2023

Creating a bundle throws a 500 because:

{
  "status_code": 500,
  "title": "Server Error",
  "message": {
    "state": "42725",
    "message": "function quote_literal(\"char\") is not unique",
    "detail": "",
    "context": "PL/pgSQL function meta.get_typedef_base(oid) line 5 at SQL statement\nPL/pgSQL function meta.get_typedef(oid) line 10 at RETURN\nPL/pgSQL assignment \"q := '\n            with inserted_row as (\n                insert into ' || quote_ident(_schema_name) || '.' || quote_ident(_relation_name) ||\n                case when args::text = '{}'::text then\n                    ' default values '\n                else\n                    ' (' || (\n                        select string_agg(quote_ident(json_object_keys), ',' order by json_object_keys)\n                        from json_object_keys(args)\n\n                    ) || ') values (' || (\n\n\n\n                           select string_agg('\n                                   case when json_typeof($3->' || quote_literal(json_object_keys) || ') = ''array'' then ((\n                                            select ''{'' || string_agg(value::text, '', '') || ''}''\n                                            from json_array_elements(($3->>' || quote_literal(json_object_keys) || ')::json)\n                                        ))\n                                        when json_typeof($3->' || quote_literal(json_object_keys) || ') = ''object'' then\n                                            ($3->' || quote_literal(json_object_keys) || ')::text\n                                        else ($3->>' || quote_literal(json_object_keys) || ')::text\n                                   end::' || case when json_typeof((args->json_object_keys)) = 'object' then 'json::'\n                                                  else ''\n                                             end || c.type_name, ',\n                                   '\n                                   order by json_object_keys\n                           ) from json_object_keys(args)\n                           inner join meta.relation_column c\n                                   on c.schema_name = _schema_name and\n                                      c.relation_name = _relation_name and\n                                      c.name = json_object_keys\n                           left join meta.type t on c.type_id = t.id\n\n\n\n                    ) || ') '\n                end ||\n                'returning *\n            )\n            select (''{\n                \"columns\": ' || endpoint.columns_json(_schema_name, _relation_name, null::text[], null::text[]) || ',\n                \"pk\":\"' || coalesce(endpoint.pk_name(_schema_name, _relation_name), 'null') || '\",\n                \"result\": [{ \"row\": '' || row_to_json(inserted_row.*, true) || '' }]\n            }'')::json\n            from inserted_row\n        '\"\nPL/pgSQL function row_insert(relation_id,json) line 20 at assignment\nSQL statement \"select 200, 'OK'::text, (select endpoint.row_insert(relation_id, post_data))::text, 'application/json'::text\"\nPL/pgSQL function endpoint.request(text,text,text,json,json) line 134 at RETURN QUERY",
    "sqlerr": "function quote_literal(\"char\") is not unique",
    "sqlstate": "42725"
  }
}
aquameta=# select * from meta.function where name='quote_literal';
-[ RECORD 1 ]--+-----------------------------------------------------
id             | ("(pg_catalog)",quote_literal,{anyelement})
schema_id      | (pg_catalog)
schema_name    | pg_catalog
name           | quote_literal
parameters     | {anyelement}
definition     | select pg_catalog.quote_literal($1::pg_catalog.text)
return_type    | text
return_type_id | ("(pg_catalog)",text)
language       | sql
returns_set    | f
-[ RECORD 2 ]--+-----------------------------------------------------
id             | ("(pg_catalog)",quote_literal,{text})
schema_id      | (pg_catalog)
schema_name    | pg_catalog
name           | quote_literal
parameters     | {text}
definition     | quote_literal
return_type    | text
return_type_id | ("(pg_catalog)",text)
language       | internal
returns_set    | f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant