Skip to content

typedef: quote_literal is not unique #16

@erichanson

Description

@erichanson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions