From e46f3999543a1ae10c7600027196e357d3254fda Mon Sep 17 00:00:00 2001 From: Konstantin Krivopustov Date: Mon, 17 Jun 2013 15:02:31 +0000 Subject: [PATCH] Datasource's JPQL "order by ... desc" leads to invalid transformation. #PL-2047 --- .../global/QueryTransformerRegexTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java b/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java index 49185dfbc9..df8f3bf3ca 100644 --- a/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java +++ b/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java @@ -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(