mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 18:27:56 +08:00
Datasource's JPQL "order by ... desc" leads to invalid transformation. #PL-2047
This commit is contained in:
parent
2d0cbed4f5
commit
e46f399954
@ -162,6 +162,41 @@ public class QueryTransformerRegexTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
public void testOrderByAscDesc() {
|
||||
QueryTransformerRegex transformer = new QueryTransformerRegex(
|
||||
"select c from sec$GroupHierarchy h join h.parent.constraints c where h.group = ?1 " +
|
||||
"group by c.level having c.level > 0 order by h.group asc",
|
||||
"sec$GroupHierarchy");
|
||||
transformer.replaceOrderBy("group", true);
|
||||
String res = transformer.getResult();
|
||||
assertEquals(
|
||||
"select c from sec$GroupHierarchy h join h.parent.constraints c where h.group = ?1 " +
|
||||
"group by c.level having c.level > 0 order by h.group desc",
|
||||
res);
|
||||
|
||||
transformer = new QueryTransformerRegex(
|
||||
"select c from sec$GroupHierarchy h join h.parent.constraints c where h.group = ?1 " +
|
||||
"group by c.level having c.level > 0 order by h.group desc",
|
||||
"sec$GroupHierarchy");
|
||||
transformer.replaceOrderBy("group", false);
|
||||
res = transformer.getResult();
|
||||
assertEquals(
|
||||
"select c from sec$GroupHierarchy h join h.parent.constraints c where h.group = ?1 " +
|
||||
"group by c.level having c.level > 0 order by h.group",
|
||||
res);
|
||||
|
||||
transformer = new QueryTransformerRegex(
|
||||
"select c from sec$GroupHierarchy h join h.parent.constraints c where h.group = ?1 " +
|
||||
"group by c.level having c.level > 0 order by h.group desc",
|
||||
"sec$GroupHierarchy");
|
||||
transformer.replaceOrderBy("group", true);
|
||||
res = transformer.getResult();
|
||||
assertEquals(
|
||||
"select c from sec$GroupHierarchy h join h.parent.constraints c where h.group = ?1 " +
|
||||
"group by c.level having c.level > 0 order by h.group desc",
|
||||
res);
|
||||
}
|
||||
|
||||
public void testOrderByAssociatedProperty() {
|
||||
// first level of association
|
||||
QueryTransformerRegex transformer = new QueryTransformerRegex(
|
||||
|
Loading…
Reference in New Issue
Block a user