|
15 | 15 | */ |
16 | 16 | package org.springframework.data.jpa.repository.query; |
17 | 17 |
|
18 | | -import static org.assertj.core.api.Assertions.assertThat; |
19 | | -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
20 | | -import static org.springframework.data.jpa.repository.query.QueryUtils.applySorting; |
21 | | -import static org.springframework.data.jpa.repository.query.QueryUtils.createCountQueryFor; |
22 | | -import static org.springframework.data.jpa.repository.query.QueryUtils.detectAlias; |
23 | | -import static org.springframework.data.jpa.repository.query.QueryUtils.getOuterJoinAliases; |
24 | | -import static org.springframework.data.jpa.repository.query.QueryUtils.hasConstructorExpression; |
25 | | -import static org.springframework.data.jpa.repository.query.QueryUtils.removeSubqueries; |
| 18 | +import static org.assertj.core.api.Assertions.*; |
| 19 | +import static org.springframework.data.jpa.repository.query.QueryUtils.*; |
26 | 20 |
|
27 | 21 | import java.util.Collections; |
28 | 22 | import java.util.Set; |
@@ -891,4 +885,30 @@ void orderByShouldWorkWithSubSelectStatements() { |
891 | 885 | + ") as timestamp\n" // |
892 | 886 | + "from foo f", sort)).endsWith("order by f.age desc"); |
893 | 887 | } |
| 888 | + |
| 889 | + @Test // GH-2884 |
| 890 | + void functionAliasShouldSupportArgumentsWithCommasOrArgumentsWithSemiColons() { |
| 891 | + |
| 892 | + assertThat(QueryUtils.getFunctionAliases(""" |
| 893 | + select s.id as id, s.name as name, gp.points |
| 894 | + from specialist s |
| 895 | + left join ( |
| 896 | + select q.specialist_id, listagg(q.points, ',') as points |
| 897 | + from qualification q |
| 898 | + group by q.specialist_id |
| 899 | + ) gp on gp.specialist_id = s.id |
| 900 | + where name like :name |
| 901 | + """)).containsExactly("points"); |
| 902 | + |
| 903 | + assertThat(QueryUtils.getFunctionAliases(""" |
| 904 | + select s.id as id, s.name as name, gp.points |
| 905 | + from specialist s |
| 906 | + left join ( |
| 907 | + select q.specialist_id, listagg(q.points, ';') as points |
| 908 | + from qualification q |
| 909 | + group by q.specialist_id |
| 910 | + ) gp on gp.specialist_id = s.id |
| 911 | + where name like :name |
| 912 | + """)).containsExactly("points"); |
| 913 | + } |
894 | 914 | } |
0 commit comments