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