- Notifications
You must be signed in to change notification settings - Fork102
Description
Feature request
Describe the current behavior
If a user defines an sql function, that takes in function parameters and these function parameters are used as query operators (for example where clauses), the PLS does not detect type mismatches in operator comparisons and postgres throws an error42883
.
-- Incorrect code (PLS should mark this as an error)-- type input incorrectcreatefunctiontest_error_42883_operator_type_mismatch(user_idint) returnsusers_hidden.users language sqlas$$select*fromusers_hidden.users uwhereu.id= user_id;$$;-- corect codecreatefunctiontest_input_parameter_as_query(user_id uuid) returnsusers_hidden.users language sqlas$$select*fromusers_hidden.users uwhereu.id= user_id;$$;
To Reproduce
- Declare a table with DDL
- Create a sql function taking in an incorrect typed parameter that is
- Use the parameter as an operator (for example a where clause)
I guess there are type mismatches possible for other operators and input parameter usages.
Requested Feature/solution/expected behavior
The postgres language server should detect the type mismatch once the parameters are used as operators and mark the operator usage as invalid (code), e.g. extensions like the vs code extensions should indicate the type mismatch error with a squiggly line and a helpful type error message.
From a DX perspective, I would love it if the error message could include a hint that the type mismatch includes a function parameter and therefore the user should double check the function input parameter types.
System information
- OS: windows AMD
- PLS: 0.8.1 with vs-code extension
- postgres supabase
PS: Do you consider this a bug or a feature request?