ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [16/33] incubator-ignite git commit: ignite-1015 - HAVING alias fix
Date Thu, 23 Jul 2015 10:03:00 GMT
ignite-1015 - HAVING alias fix


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

Branch: refs/heads/ignite-gg-10561
Commit: cbdc6143a7df7a7c39c11ef073c64de300414360
Parents: 1486aea
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Wed Jul 22 06:09:33 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Wed Jul 22 06:09:33 2015 +0300

----------------------------------------------------------------------
 .../processors/query/h2/sql/GridSqlSelect.java  | 25 +++++++++++++-------
 1 file changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cbdc6143/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
index 84b0031..08304aa 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
@@ -84,19 +84,17 @@ public class GridSqlSelect extends GridSqlQuery {
             buff.resetCount();
 
             for (int grpCol : grpCols) {
-                GridSqlElement expression = allExprs.get(grpCol);
-
                 buff.appendExceptFirst(", ");
 
-                if (expression instanceof GridSqlAlias)
-                    buff.append(StringUtils.unEnclose((expression.child().getSQL())));
-                else
-                    buff.append(StringUtils.unEnclose(expression.getSQL()));
+                addAlias(buff, allExprs.get(grpCol));
             }
         }
 
-        if (havingCol >= 0)
-            buff.append("\nHAVING ").append(StringUtils.unEnclose(allExprs.get(havingCol).getSQL()));
+        if (havingCol >= 0) {
+            buff.append("\nHAVING ");
+
+            addAlias(buff, allExprs.get(havingCol));
+        }
 
         getSortLimitSQL(buff);
 
@@ -104,6 +102,17 @@ public class GridSqlSelect extends GridSqlQuery {
     }
 
     /**
+     * @param buff Statement builder.
+     * @param expression Alias expression.
+     */
+    private static void addAlias(StatementBuilder buff, GridSqlElement expression) {
+        if (expression instanceof GridSqlAlias)
+            expression = expression.child();
+
+        buff.append(StringUtils.unEnclose(expression.getSQL()));
+    }
+
+    /**
      * @param visibleOnly If only visible expressions needed.
      * @return Select phrase expressions.
      */


Mime
View raw message