From d06f72f7f92453a7a30d8af63102f04e52cd534f Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Mon, 2 Aug 2010 17:44:20 +0000 Subject: [PATCH] FEATURE: Start of union support; parsing isn't tested yet. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@981640 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/ofbiz/entity/sql/EntityPlanner.java | 17 ++- framework/sql/src/org/ofbiz/sql/Parser.jj | 55 +++++++- .../sql/src/org/ofbiz/sql/SQLSelect.java | 88 +++---------- .../sql/src/org/ofbiz/sql/SelectGroup.java | 120 ++++++++++++++++++ framework/sql/src/org/ofbiz/sql/Unioned.java | 63 +++++++++ .../src/org/ofbiz/sql/test/GoodParseAll.sql | 8 +- 6 files changed, 268 insertions(+), 83 deletions(-) create mode 100644 framework/sql/src/org/ofbiz/sql/SelectGroup.java create mode 100644 framework/sql/src/org/ofbiz/sql/Unioned.java diff --git a/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java b/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java index e81c3855d1..ead4733e1d 100644 --- a/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java +++ b/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java @@ -42,6 +42,7 @@ import org.ofbiz.sql.NumberValue; import org.ofbiz.sql.OrderByItem; import org.ofbiz.sql.Planner; import org.ofbiz.sql.Relation; +import org.ofbiz.sql.SelectGroup; import org.ofbiz.sql.SQLDelete; import org.ofbiz.sql.SQLInsert; import org.ofbiz.sql.SQLSelect; @@ -51,6 +52,7 @@ import org.ofbiz.sql.StaticValue; import org.ofbiz.sql.StringValue; import org.ofbiz.sql.Table; import org.ofbiz.sql.TableName; +import org.ofbiz.sql.Unioned; import org.ofbiz.sql.Value; public class EntityPlanner extends Planner { @@ -68,20 +70,25 @@ public class EntityPlanner extends Planner groupBy = selectStatement.getGroupBy(); + List groupBy = selectGroup.getGroupBy(); if (groupBy == null) { groupBy = Collections.emptyList(); } - for (FieldDef fieldDef: selectStatement.getFieldDefs()) { + for (FieldDef fieldDef: selectGroup.getFieldDefs()) { addFieldDef(dve, groupBy, fieldDef.getAlias(), fieldDef); } List orderBy; @@ -93,7 +100,7 @@ public class EntityPlanner extends Planner | | -// | + | + | + | + | | | | @@ -299,7 +302,51 @@ private SQLView View(): { name=NamePart() sqlSelect=Select() { return new SQLView(name, sqlSelect); } } +private SelectGroup SelectGroup(): { + boolean isDistinct = false; + List groupBy = null; + Map fieldDefs = FastMap.newInstance(); + List fieldAlls = FastList.newInstance(); + Set fieldAllAliases = FastSet.newInstance(); + Table table; + Condition whereCondition = null, havingCondition = null; +} { +