Skip to content

functions.create/retrieve fails for multi-word argument types #1146

Description

@hsusul

Bug

functions.retrieve({ args }) (and therefore functions.create, which retrieves after create) resolves each arg to a type by taking only the last space-separated token and casting it to regtype:

STRING_TO_ARRAY(arg, ' ')[last]::regtype

That breaks SQL-standard multi-word types:

arg last token result
double precision precision invalid type name "precision"
timestamp with time zone zone error
x double precision precision error

Repro

await pgMeta.functions.create({
  name: 'test_multiword_arg',
  schema: 'public',
  args: ['x double precision', 'ts timestamp with time zone'],
  definition: 'select x',
  return_type: 'double precision',
  language: 'sql',
  behavior: 'STABLE',
  security_definer: false,
})
// CREATE succeeds; retrieve-by-args fails → create returns an error

Expected

Args should resolve using the full type name (and drop only an optional leading parameter name), so Studio/API can create and look up functions with common SQL types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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