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

Parameter Parsing fails on concat operator in SQLText#parse #590

Open
FrostbittenKing opened this issue Jul 9, 2023 · 0 comments
Open

Comments

@FrostbittenKing
Copy link

FrostbittenKing commented Jul 9, 2023

Hi, Since changes in spring boot 3.1.1 (to be precise, in spring-data-jpa 3.1.1), SQLText fails to correctly parse expressions like
....where my_number like('%'||?||'%').
spring boot replaces where my_number like %:paramName% with where my_number like CONCAT('%',:paramName,'%') and hibernate in turn translates this to where my_number like ('%'||?||'%').
Unfortunately SQLText incorrectly detects here the jsonb operator ?| / ?&, instead of recognizing it as a concat operation.
As far as I can tell, this regression was introduced in this commit.
b41dac8

I have experimented with some workarounds.

  1. Patch hibernates class ConcatPipeFunction, to generate a translated statement of where my_number like ('%' || ? || '%') (added whitespaces), which makes SQLText again correctly parse the expressions parameters.
  2. Patch SQLText to lookahead another character if there is another pipe character, suggesting a concat. Idk if this works all the time, or if there need to be more checks.
  3. Replace jpql queries with || expression directly so, instead of hibernate translating it to '%'||?||'%', I write it myself exactly as '%' || ? || '%').

I guesss, Quickest fix for me would be Nr. 1. This fix has less complexity than Nr 2, But Nr 2. would be better in the long term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant