ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [07/42] incubator-ignite git commit: ignite-698 - fixed
Date Fri, 10 Apr 2015 17:47:37 GMT
ignite-698 - fixed


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8389cd06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8389cd06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8389cd06

Branch: refs/heads/ignite-721
Commit: 8389cd0646820c9d4ef25363c64810434ee8fc2d
Parents: 3765f5d
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Thu Apr 9 19:10:53 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Thu Apr 9 19:10:53 2015 +0300

----------------------------------------------------------------------
 .../processors/query/h2/IgniteH2Indexing.java   | 16 +++++++++++++++-
 .../query/h2/sql/BaseH2CompareQueryTest.java    | 20 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8389cd06/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 719ee4a..c99b01c 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -831,11 +831,25 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     private String generateQuery(String qry, TableDescriptor tbl) throws IgniteCheckedException
{
         assert tbl != null;
 
+        final String qry0 = qry;
+
         String t = tbl.fullTableName();
 
         String from = " ";
 
-        String upper = qry.trim().toUpperCase();
+        qry = qry.trim();
+        String upper = qry.toUpperCase();
+
+        if (upper.startsWith("SELECT")) {
+            qry = qry.substring(6).trim();
+
+            if (!qry.startsWith("*"))
+                throw new IgniteCheckedException("Only queries starting with 'SELECT *' are
supported or " +
+                    "use SqlFieldsQuery instead: " + qry0);
+
+            qry = qry.substring(1).trim();
+            upper = qry.toUpperCase();
+        }
 
         if (!upper.startsWith("FROM"))
             from = " FROM " + t +

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8389cd06/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 7f07069..a715e6f 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
@@ -19,13 +19,17 @@ package org.apache.ignite.internal.processors.query.h2.sql;
 
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.testframework.*;
 
+import javax.cache.*;
 import java.io.*;
 import java.sql.*;
 import java.sql.Date;
 import java.util.*;
+import java.util.concurrent.*;
 
 /**
  * Base set of queries to compare query results from h2 database instance and mixed ignite
caches (replicated and partitioned)
@@ -160,6 +164,22 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest
{
     }
 
     /**
+     *
+     */
+    public void testSelectStar() {
+        assertEquals(1, pCache.query(new SqlQuery<AffinityKey<?>,Person>(
+            Person.class, "\t\r\n  select  \n*\t from Person limit 1")).getAll().size());
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                pCache.query(new SqlQuery(Person.class, "SELECT firstName from PERSON"));
+
+                return null;
+            }
+        }, CacheException.class, null);
+    }
+
+    /**
      * @throws Exception
      */
     // TODO: IGNITE-705


Mime
View raw message