Unable to parse functions in schemas
amonks opened this issue · comments
It looks like calling a function that is defined within a schema produces a parser error.
Calling a created function always produces a warning ("unknown function"), which is a known issue, but a parser error seems like a distinct issue.
It doesn't seem like this error affects sqltyper's output, so it has no real user impact—just like any function call, it produces mostly-correct types, with an extra | null
on the return type. I just thought it was curious 🤷.
--- setup -----------------------------------------------------------------
CREATE SCHEMA s;
CREATE FUNCTION s.func() RETURNS boolean AS $$
SELECT true
$$ LANGUAGE sql;
--- query -----------------------------------------------------------------
SELECT s.func();
Produces this error:
Failed to run schema-function.sql: WARNING: The internal SQL parser failed to parse the SQL statement.
Parse error: Expect the end of source at (1:14)
1| SELECT s.func();
^
(By the way—sqltyper is freakin' awesome and I love it. Thank you.)
Seems this should be easy to fix in the parser.
The result of calling a custom function will be nullable, at least for now, because finding out the return value’s nullability would require inspecting the body of the function itself, I think.
(By the way—sqltyper is freakin' awesome and I love it. Thank you.)
Thanks!
It required a bit more work than I thought :D The problem was that there was no support for non-builtin functions at all. See #90 for a fix.
Fixed in #90
Released in v1.1.0