cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2368 ColumnSelect: Property.self() translates into wrong SQL code
Date Mon, 02 Oct 2017 12:35:10 GMT
Repository: cayenne
Updated Branches:
  refs/heads/STABLE-4.0 6c866e197 -> c0c0cfa05


CAY-2368 ColumnSelect: Property.self() translates into wrong SQL code

(cherry picked from commit b34c76b24a73355fb4c1085dfc10c4741668ea60)


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

Branch: refs/heads/STABLE-4.0
Commit: c0c0cfa05ff1386c3ba97b9f0d7ed9bdf99fd584
Parents: 6c866e1
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Mon Oct 2 15:35:02 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Mon Oct 2 15:35:02 2017 +0300

----------------------------------------------------------------------
 .../select/DefaultSelectTranslator.java         |  1 +
 .../apache/cayenne/query/ColumnSelectIT.java    | 31 ++++++++++++++++++++
 docs/doc/src/main/resources/RELEASE-NOTES.txt   |  1 +
 3 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/c0c0cfa0/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
index 39eda02..d35b0b4 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
@@ -412,6 +412,7 @@ public class DefaultSelectTranslator extends QueryAssembler implements
SelectTra
 		setAddBindingListener(bindingListener);
 
 		for(Property<?> property : query.getColumns()) {
+			joinTableAliasForProperty[0] = null;
 			int expressionType = property.getExpression().getType();
 
 			// forbid direct selection of toMany relationships columns

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c0c0cfa0/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
index 21e3d9e..fe4edba 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ColumnSelectIT.java
@@ -477,6 +477,37 @@ public class ColumnSelectIT extends ServerCase {
         assertEquals("ng1 artist1", a);
     }
 
+    @Test
+    public void testAliasOrder() {
+        // test that all table aliases are correct
+        List<Object[]> result = ObjectSelect.columnQuery(Artist.class,
+                Artist.PAINTING_ARRAY.outer().count(),
+                Property.createSelf(Artist.class),
+                Artist.PAINTING_ARRAY.dot(Painting.PAINTING_TITLE),
+                Property.createSelf(Artist.class),
+                Artist.PAINTING_ARRAY.dot(Painting.TO_GALLERY).dot(Gallery.GALLERY_NAME),
+                Artist.ARTIST_NAME,
+                Property.createSelf(Artist.class)
+        ).select(context);
+        assertEquals(21, result.size());
+        for(Object[] next : result) {
+            long count = (Long)next[0];
+            Artist artist = (Artist)next[1];
+            String paintingTitle = (String)next[2];
+            Artist artist2 = (Artist)next[3];
+            String galleryName = (String)next[4];
+            String artistName = (String)next[5];
+            Artist artist3 = (Artist)next[6];
+
+            assertTrue(paintingTitle.startsWith("painting"));
+            assertTrue(count == 4L || count == 5L);
+            assertEquals("tate modern", galleryName);
+            assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
+            assertEquals(PersistenceState.COMMITTED, artist2.getPersistenceState());
+            assertEquals(PersistenceState.COMMITTED, artist3.getPersistenceState());
+        }
+    }
+
     /*
      *  Test iterated select
      */

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c0c0cfa0/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 5b1201e..7aa154b 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -15,6 +15,7 @@ Bug Fixes:
 
 CAY-2364 Wrong logging in SQLTemplate
 CAY-2365 SQLExec query tries to convert (unexpected) result set into objects
+CAY-2368 ColumnSelect: Property.self() translates into wrong SQL code
 
 ----------------------------------
 Release: 4.0.B2


Mime
View raw message