Skip to content

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

Description

@FrostbittenKing

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions