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-2362 ColumnSelect: unable to use Property without type
Date Mon, 11 Sep 2017 09:41:19 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 4a8eb1b06 -> cb3f9f498


CAY-2362 ColumnSelect: unable to use Property without type


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

Branch: refs/heads/master
Commit: cb3f9f4988bcc63820872ec5e7392f1d121902dd
Parents: 4a8eb1b
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Mon Sep 11 12:40:55 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Mon Sep 11 12:40:55 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/cayenne/blob/cb3f9f49/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 59bdc07..39eda02 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
@@ -415,7 +415,7 @@ public class DefaultSelectTranslator extends QueryAssembler implements
SelectTra
 			int expressionType = property.getExpression().getType();
 
 			// forbid direct selection of toMany relationships columns
-			if((expressionType == Expression.OBJ_PATH || expressionType == Expression.DB_PATH)
+			if(property.getType() != null && (expressionType == Expression.OBJ_PATH || expressionType
== Expression.DB_PATH)
 					&& (Collection.class.isAssignableFrom(property.getType())
 							|| Map.class.isAssignableFrom(property.getType()))) {
 				throw new CayenneRuntimeException("Can't directly select toMany relationship columns.
" +
@@ -424,7 +424,9 @@ public class DefaultSelectTranslator extends QueryAssembler implements
SelectTra
 
 			// evaluate ObjPath with Persistent type as toOne relations and use it as full object
 			boolean objectProperty = expressionType == Expression.FULL_OBJECT
-					|| (expressionType == Expression.OBJ_PATH && Persistent.class.isAssignableFrom(property.getType()));
+					|| (property.getType() != null
+						&& expressionType == Expression.OBJ_PATH
+						&& Persistent.class.isAssignableFrom(property.getType()));
 
 			// Qualifier Translator in case of Object Columns have side effect -
 			// it will create required joins, that we catch with listener above.
@@ -455,7 +457,12 @@ public class DefaultSelectTranslator extends QueryAssembler implements
SelectTra
 				}
 
 				int type = getJdbcTypeForProperty(property);
-				ColumnDescriptor descriptor = new ColumnDescriptor(builder.toString(), type, property.getType().getName());
+				ColumnDescriptor descriptor;
+				if(property.getType() != null) {
+					descriptor = new ColumnDescriptor(builder.toString(), type, property.getType().getName());
+				} else {
+					descriptor = new ColumnDescriptor(builder.toString(), type);
+				}
 				descriptor.setDataRowKey(alias);
 				descriptor.setIsExpression(true);
 				columns.add(descriptor);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/cb3f9f49/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 d4798c9..25fb80b 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
@@ -973,4 +973,17 @@ public class ColumnSelectIT extends ServerCase {
                 .select(context);
         assertEquals(22, result.size());
     }
+
+    /*
+     * Test deprecated property constructor
+     */
+
+    @Test
+    @SuppressWarnings("deprecation")
+    public void testDeprecateConstructor() {
+        Property<String> property = new Property<>("artistName");
+        List<String> names = ObjectSelect.columnQuery(Artist.class, property).select(context);
+        assertEquals(20, names.size());
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/cb3f9f49/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 fa8be5a..aef27f5 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -40,6 +40,7 @@ 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
+CAY-2362 ColumnSelect: unable to use Property without type
 
 ----------------------------------
 Release: 4.0.B1


Mime
View raw message