File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
antlr4/org/springframework/data/jpa/repository/query
java/org/springframework/data/jpa/repository/query
test/java/org/springframework/data/jpa/repository/query Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -686,7 +686,7 @@ character
686686 ;
687687
688688functionName
689- : reservedWord
689+ : reservedWord ( ' . ' reservedWord)*
690690 ;
691691
692692reservedWord
Original file line number Diff line number Diff line change @@ -2503,7 +2503,17 @@ public List<JpaQueryParsingToken> visitCharacter(HqlParser.CharacterContext ctx)
25032503
25042504 @ Override
25052505 public List <JpaQueryParsingToken > visitFunctionName (HqlParser .FunctionNameContext ctx ) {
2506- return visit (ctx .reservedWord ());
2506+
2507+ List <JpaQueryParsingToken > tokens = new ArrayList <>();
2508+
2509+ ctx .reservedWord ().forEach (reservedWordContext -> {
2510+ tokens .addAll (visit (reservedWordContext ));
2511+ NOSPACE (tokens );
2512+ tokens .add (TOKEN_DOT );
2513+ });
2514+ CLIP (tokens );
2515+
2516+ return tokens ;
25072517 }
25082518
25092519 @ Override
Original file line number Diff line number Diff line change @@ -1556,4 +1556,32 @@ void typeShouldBeAValidParameter() {
15561556 assertQuery ("select e from Employee e where e.type = :_type" );
15571557 assertQuery ("select te from TestEntity te where te.type = :type" );
15581558 }
1559+
1560+ @ Test // GH-3099
1561+ void functionNamesShouldSupportSchemaScoping () {
1562+
1563+ assertQuery ("""
1564+ SELECT b
1565+ FROM MyEntity b
1566+ WHERE b.status = :status
1567+ AND utl_raw.cast_to_varchar2((nlssort(lower(b.name), 'nls_sort=binary_ai'))) LIKE lower(:name)
1568+ ORDER BY utl_raw.cast_to_varchar2((nlssort(lower(b.name), 'nls_sort=binary_ai'))) ASC
1569+ """ );
1570+
1571+ assertQuery ("""
1572+ select b
1573+ from Bairro b
1574+ where b.situacao = :situacao
1575+ and utl_raw.cast_to_varchar2((nlssort(lower(b.nome), 'nls_sort=binary_ai'))) like lower(:nome)
1576+ order by utl_raw.cast_to_varchar2((nlssort(lower(b.nome), 'nls_sort=binary_ai'))) ASC
1577+ """ );
1578+
1579+ assertQuery ("""
1580+ select b
1581+ from Bairro b
1582+ where b.situacao = :situacao
1583+ and CTM_UTLRAW_NLSSORT_LOWER(b.nome) like lower(:nome)
1584+ order by CTM_UTLRAW_NLSSORT_LOWER(b.nome) ASC
1585+ """ );
1586+ }
15591587}
You can’t perform that action at this time.
0 commit comments