You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2020/02/03 11:05:39 UTC
[ignite] branch master updated: IGNITE-12561: SQL: Fix incorrect
check for conflict of field names in key and value. This closes #7294.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new d687afb IGNITE-12561: SQL: Fix incorrect check for conflict of field names in key and value. This closes #7294.
d687afb is described below
commit d687afb2675e362606c8a166367b347b28477d02
Author: Evgeniy Rudenko <er...@gridgain.com>
AuthorDate: Mon Feb 3 14:04:42 2020 +0300
IGNITE-12561: SQL: Fix incorrect check for conflict of field names in key and value. This closes #7294.
---
.../cache/query/QueryEntityClassProperty.java | 7 ++++
.../cache/query/QueryEntityTypeDescriptor.java | 10 ++---
.../cache/index/QueryEntityValidationSelfTest.java | 45 ++++++++++++++++++++++
3 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityClassProperty.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityClassProperty.java
index e21b73c..ad96d72 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityClassProperty.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityClassProperty.java
@@ -103,6 +103,13 @@ public class QueryEntityClassProperty {
}
/**
+ * @return Field's name.
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
* @return Full name with all parents in dot notation.
*/
public String fullName() {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java
index 814d707..acdcb20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java
@@ -166,18 +166,16 @@ public class QueryEntityTypeDescriptor {
* @param failOnDuplicate Fail on duplicate flag.
*/
public void addProperty(QueryEntityClassProperty prop, boolean key, boolean failOnDuplicate) {
- String name = prop.fullName();
-
- if (props.put(name, prop) != null && failOnDuplicate) {
- throw new CacheException("Property with name '" + name + "' already exists for " +
+ if (props.put(prop.name(), prop) != null && failOnDuplicate) {
+ throw new CacheException("Property with name '" + prop.name() + "' already exists for " +
(key ? "key" : "value") + ": " +
"QueryEntity [key=" + keyCls.getName() + ", value=" + valCls.getName() + ']');
}
- fields.put(name, prop.type());
+ fields.put(prop.fullName(), prop.type());
if (key)
- keyProps.add(name);
+ keyProps.add(prop.fullName());
}
/**
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
index 408535e..d25659b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
@@ -22,9 +22,11 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.Callable;
+import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.testframework.GridTestUtils;
import org.junit.Test;
@@ -155,4 +157,47 @@ public class QueryEntityValidationSelfTest extends AbstractIndexingCommonTest {
}
}, IgniteCheckedException.class, "Duplicate index name");
}
+
+ /**
+ * Test class for sql queryable test key.
+ */
+ private static class TestKey {
+ /** Non-unique id. */
+ @QuerySqlField
+ int notUniqueId;
+ }
+
+ /**
+ * Test class for sql queryable test value.
+ */
+ private static class TestValue {
+ /** Field with nested queryable field. */
+ @QuerySqlField
+ TestValueField field;
+ }
+
+ /**
+ * Test class for nested sql queryable field.
+ */
+ private static class TestValueField {
+ /** Not unique id. */
+ @QuerySqlField
+ int notUniqueId;
+ }
+
+ /**
+ * Test duplicated nested annotations.
+ */
+ @Test
+ public void testNestedDuplicatedAnnotations() {
+ final CacheConfiguration<TestKey, TestValue> ccfg = new CacheConfiguration<TestKey, TestValue>().setName(CACHE_NAME);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() {
+ ccfg.setIndexedTypes(TestKey.class, TestValue.class);
+
+ return null;
+ }
+ }, CacheException.class, "Property with name 'notUniqueId' already exists");
+ }
}