Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feat SQL functions: Detect parameter type mismatches (error 42883) #432

Open
Labels
enhancementNew feature or request
@Donnerstagnacht

Description

@Donnerstagnacht

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

  1. Declare a table with DDL
  2. Create a sql function taking in an incorrect typed parameter that is
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp