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.
Bug
functions.retrieve({ args })(and thereforefunctions.create, which retrieves after create) resolves each arg to a type by taking only the last space-separated token and casting it toregtype:STRING_TO_ARRAY(arg, ' ')[last]::regtypeThat breaks SQL-standard multi-word types:
double precisionprecisioninvalid type name "precision"timestamp with time zonezonex double precisionprecisionRepro
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.