cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/2] cayenne git commit: CAY-2359 EJBQL: db path in not supported in ORDER BY
Date Thu, 31 Aug 2017 10:59:28 GMT
Repository: cayenne
Updated Branches:
  refs/heads/STABLE-4.0 084baf620 -> f074a59b7


CAY-2359 EJBQL: db path in not supported in ORDER BY

(cherry picked from commit 64dad56)


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/4adfc53a
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/4adfc53a
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/4adfc53a

Branch: refs/heads/STABLE-4.0
Commit: 4adfc53a8d5cb750da6114326aae844f43a3bf03
Parents: 084baf6
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Thu Aug 31 12:53:25 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Thu Aug 31 12:54:33 2017 +0300

----------------------------------------------------------------------
 .../translator/ejbql/EJBQLOrderByTranslator.java   | 11 +++++++++++
 .../org/apache/cayenne/query/EJBQLQueryIT.java     | 17 +++++++++++++++--
 docs/doc/src/main/resources/RELEASE-NOTES.txt      |  1 +
 3 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/4adfc53a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
index 41ca358..2183af4 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
@@ -69,4 +69,15 @@ class EJBQLOrderByTranslator extends EJBQLBaseVisitor {
         expression.visit(childVisitor);
         return false;
     }
+
+    @Override
+    public boolean visitDbPath(EJBQLExpression expression, int finishedChildIndex) {
+        expression.visit(new EJBQLDbPathTranslator(context) {
+            @Override
+            protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
+                throw new EJBQLException("Can't order on multi-column paths or objects");
+            }
+        });
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4adfc53a/cayenne-server/src/test/java/org/apache/cayenne/query/EJBQLQueryIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/EJBQLQueryIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/EJBQLQueryIT.java
index a60e9d2..d5e6766 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/EJBQLQueryIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/EJBQLQueryIT.java
@@ -675,8 +675,8 @@ public class EJBQLQueryIT extends ServerCase {
         registry.addCallback(LifecycleEvent.POST_LOAD, Painting.class, "postAddCallback");
 
         // select Paintings, where one of it will be null
-        EJBQLQuery queryFullProduct = new EJBQLQuery("select a.paintingArray+ from Artist
a order by a.artistName");
-        List<Painting> result1 = context.performQuery(queryFullProduct);
+        EJBQLQuery query = new EJBQLQuery("select a.paintingArray+ from Artist a order by
a.artistName");
+        List<Painting> result1 = context.performQuery(query);
         assertEquals(4, result1.size());
         assertNull(result1.get(3));
         for(int i=0; i<3; i++) {
@@ -684,4 +684,17 @@ public class EJBQLQueryIT extends ServerCase {
             assertTrue(result1.get(i).isPostAdded());
         }
     }
+
+    @Test
+    public void testOrderByDbPath() throws Exception {
+        tArtist.insert(1, "a3");
+        tArtist.insert(2, "a2");
+        tArtist.insert(3, "a1");
+
+        EJBQLQuery query = new EJBQLQuery("SELECT a FROM Artist a ORDER BY db:a.ARTIST_ID
DESC");
+        List<Artist> result = context.performQuery(query);
+        assertEquals("a1", result.get(0).getArtistName());
+        assertEquals("a2", result.get(1).getArtistName());
+        assertEquals("a3", result.get(2).getArtistName());
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4adfc53a/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index 5dc9861..1639dd7 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -26,6 +26,7 @@ CAY-2354 DbGenerator.runGenerator must commit its connection
 CAY-2356 EJBQL: Incorrect COUNT() on outer joined table
 CAY-2357 Generic select queries silently convert result to nulls if no PK column found
 CAY-2358 NPE when callbacks invoked on null objects
+CAY-2359 EJBQL: db path in not supported in ORDER BY
 
 ----------------------------------
 Release: 4.0.B1


Mime
View raw message