Skip to content

VSCode: Error reported when "CALL {h-schema}" is used in @Query  #1395

Closed

Description

@awn70

When I use the {h-schema} placeholder in a @query native query with CALL for a stored procedure the following error is shown:
PostgreSQL: no viable alternative at input 'CALLh' vscode-spring-boot(SQL_SYNTAX)

Code:
@Modifying
@query( value = "CALL {h-schema}calcRequest( :i_session_id );", nativeQuery = true )
void calcRequest( @PARAM( "i_session_id" ) String sessionId );

Activity

  1. added
    for: eclipse
    for: vscode
    and removed on Oct 29, 2024
  2. added this to the 4.27.0.RELEASE milestone on Oct 29, 2024
  3. martinlippert commented on Oct 29, 2024

    @martinlippert
    Member

    Thanks for reporting this, we will look into this to improve the validation here. In the meantime, you can switch off the query validation in the preferences (if the error is too annoying).

  4. shygnome commented on Dec 5, 2024

    @shygnome

    We are also facing similar issues. We are using MySQL syntax in a @Query method with native query. I don't know if the issues we are facing are the same because they only show errors for specific words. Here is an example of the query snippet (We will hide the full query).

    @Query(value = "SELECT ..."
                + "..."
                + "WHERE lo.service_type = :serviceType "
                + "AND inv.issued_date >= :from AND inv.issued_date <= :to "
                + "..."
                + "GROUP BY inv.id", nativeQuery = true)
        List<SomeInterface> getSomeReport(String serviceType, LocalDate from, LocalDate to);

    And the reported error,

    MySQL: no viable alternative at input 'SELECT (...) WHERE lo.service_type = :serviceType AND inv.issued_date >= :from'

    The error only highlights the :from word.

  5. BoykoAlex commented on Dec 6, 2024

    @BoykoAlex
    Contributor

    @shygnome The MySQL queries grammar we use did not allow from and to to be used as identifiers as these were reserved keywords. I've relaxed this in the grammar so now it is likely to parse the query above if you update from the snapshot repo (pushed f53f1d7 as a fix for this)
    However, I think you can workaround this issue by replacing from with fromDate and to with toDate.

    (Not closing this issue as the problem reported in the comment above is not the same as reported initially in the description at the top)

  6. BoykoAlex commented on Dec 6, 2024

    @BoykoAlex
    Contributor

    Fixed via 3e44b79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

for: eclipsefor: vscodetheme: spring-data-supporttheme: validationtype: bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions