You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/27 15:40:24 UTC
incubator-ignite git commit: #ignite-947: Check the number of
parameters in sql query.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-947 [created] feb27c5b4
#ignite-947: Check the number of parameters in sql query.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/feb27c5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/feb27c5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/feb27c5b
Branch: refs/heads/ignite-947
Commit: feb27c5b4e11a4308d7768d7312b1edc5228e81c
Parents: 3a84c4b
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed May 27 15:42:31 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed May 27 16:37:14 2015 +0300
----------------------------------------------------------------------
.../query/h2/sql/GridSqlQuerySplitter.java | 4 ++++
.../query/h2/sql/BaseH2CompareQueryTest.java | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feb27c5b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
index 6c7e2e2..762d45c 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
@@ -288,6 +288,10 @@ public class GridSqlQuerySplitter {
while (target.size() < idx)
target.add(null);
+ if (params.length <= idx)
+ throw new IgniteException("Please provide all parameters for query. " +
+ "Cannot find " + idx + " parameter.");
+
Object param = params[idx];
if (idx == target.size())
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/feb27c5b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
index 7cdf0bc..018c672 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.query.h2.sql;
+import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.affinity.*;
import org.apache.ignite.cache.query.*;
@@ -180,6 +181,21 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest {
}
/**
+ * @throws Exception If failed.
+ */
+ public void testInvalidQuery() throws Exception {
+ final SqlFieldsQuery sql = new SqlFieldsQuery("SELECT firstName from Person where id <> ? and orgId <> ?");
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ pCache.query(sql.setArgs(3));
+
+ return null;
+ }
+ }, IgniteException.class, "Please provide all parameters for query.");
+ }
+
+ /**
* @throws Exception
*/
// TODO: IGNITE-705