supabase-community / postgres_lsp

A Language Server for Postgres
https://supabase.com
MIT License
3.32k stars 62 forks source link

feat: extend support for create function #75

Closed cvng closed 10 months ago

cvng commented 11 months ago

What kind of change does this PR introduce?

extend support for create function

What is the current behavior?

panics with SETOF panics with STRICT | RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT

What is the new behavior?

parser returns - added tests

Additional context

View log ```rust CreateFunctionStmt { is_procedure: false, replace: false, funcname: [ Node { node: Some( String( String { sval: "getfoo", }, ), ), }, ], parameters: [ Node { node: Some( FunctionParameter( FunctionParameter { name: "", arg_type: Some( TypeName { names: [ Node { node: Some( String( String { sval: "pg_catalog", }, ), ), }, Node { node: Some( String( String { sval: "int4", }, ), ), }, ], type_oid: 0, setof: false, pct_type: false, typmods: [], typemod: -1, array_bounds: [], location: 23, }, ), mode: FuncParamDefault, defexpr: None, }, ), ), }, ], return_type: Some( TypeName { names: [ Node { node: Some( String( String { sval: "users", }, ), ), }, ], type_oid: 0, setof: true, pct_type: false, typmods: [], typemod: -1, array_bounds: [], location: 58, }, ), options: [ Node { node: Some( DefElem( DefElem { defnamespace: "", defname: "language", arg: Some( Node { node: Some( String( String { sval: "sql", }, ), ), }, ), defaction: DefelemUnspec, location: 80, }, ), ), }, Node { node: Some( DefElem( DefElem { defnamespace: "", defname: "as", arg: Some( Node { node: Some( List( List { items: [ Node { node: Some( String( String { sval: "select * from \"users\" where users.id = $1;", }, ), ), }, ], }, ), ), }, ), defaction: DefelemUnspec, location: 109, }, ), ), }, ], sql_body: None, } ```