Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
awn70 opened this issue Oct 28, 2024 · 4 comments
Closed

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

awn70 opened this issue Oct 28, 2024 · 4 comments
Assignees
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: spring-data-support theme: validation type: bug

Comments

@awn70
Copy link

awn70 commented Oct 28, 2024

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 );

@martinlippert
Copy link
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).

@shygnome
Copy link

shygnome commented Dec 5, 2024

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.

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Dec 6, 2024

@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)

@BoykoAlex
Copy link
Contributor

Fixed via 3e44b79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: spring-data-support theme: validation type: bug
Projects
None yet
Development

No branches or pull requests

4 participants