From bc1f0f7d6261e8c6bfc89bc1efbfdd868d2c3453 Mon Sep 17 00:00:00 2001
From: phantomjinx <p.g.richardson@phantomjinx.co.uk>
Date: Fri, 17 Jan 2014 14:03:31 +0000
Subject: [PATCH] TEIID-2808: Small fixes to unit tests and accompanying
 classes

Parser
 * Removes extraneous code
 * Makes the test expected objects consistent with actual objects

* Block
 * Mistake in equals method checking exceptionGroup against itself rather
   than other.exceptionGroup

* ElementSymbol
 * Type of element symbol not being checked in equals method
---
 engine/src/main/java/org/teiid/query/sql/proc/Block.java         | 3 +--
 .../src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java  | 5 +++++
 engine/src/test/java/org/teiid/query/parser/TestParser.java      | 9 +++------
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/engine/src/main/java/org/teiid/query/sql/proc/Block.java b/engine/src/main/java/org/teiid/query/sql/proc/Block.java
index edab76f..4ad860a 100644
--- a/engine/src/main/java/org/teiid/query/sql/proc/Block.java
+++ b/engine/src/main/java/org/teiid/query/sql/proc/Block.java
@@ -24,7 +24,6 @@ package org.teiid.query.sql.proc;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import org.teiid.core.util.EquivalenceUtil;
 import org.teiid.core.util.StringUtil;
 import org.teiid.query.sql.LanguageObject;
@@ -176,7 +175,7 @@ public class Block extends Statement implements Labeled {
         return this.atomic == other.atomic 
         && StringUtil.equalsIgnoreCase(label, other.label)
         && EquivalenceUtil.areEqual(getStatements(), other.getStatements())
-        && EquivalenceUtil.areEqual(exceptionGroup, exceptionGroup)
+        && EquivalenceUtil.areEqual(exceptionGroup, other.exceptionGroup)
         && EquivalenceUtil.areEqual(exceptionStatements, exceptionStatements);
     }    
 
diff --git a/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java b/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
index 29ae25a..55f54aa 100644
--- a/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
+++ b/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
@@ -22,6 +22,7 @@
 
 package org.teiid.query.sql.symbol;
 
+import org.teiid.core.util.EquivalenceUtil;
 import org.teiid.core.util.HashCodeUtil;
 import org.teiid.query.sql.LanguageVisitor;
 
@@ -102,6 +103,10 @@ public class ElementSymbol extends Symbol implements DerivedExpression {
     	if (other.groupSymbol == null) {
         	return super.equals(obj);
     	}
+    	
+    	if (! EquivalenceUtil.areEqual(type, other.type))
+    	    return false;
+
     	return this.groupSymbol.equals(other.groupSymbol) && this.getShortName().equals(other.getShortName());
     }
     
diff --git a/engine/src/test/java/org/teiid/query/parser/TestParser.java b/engine/src/test/java/org/teiid/query/parser/TestParser.java
index b78b17c..589a36b 100644
--- a/engine/src/test/java/org/teiid/query/parser/TestParser.java
+++ b/engine/src/test/java/org/teiid/query/parser/TestParser.java
@@ -3033,10 +3033,7 @@ public class TestParser {
         
         Select select = new Select();
         select.addSymbol(new ElementSymbol("x.a")); //$NON-NLS-1$
-        
-        Query query = new Query();
-        query.setSelect(select);
-        query.setFrom(from);
+
         helpTest("exec proc1('param1')", "EXEC proc1('param1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
@@ -5132,7 +5129,7 @@ public class TestParser {
         Query query = new Query();
         query.setSelect(new Select(Arrays.asList(new MultipleElementSymbol())));
         ArrayTable tt = new ArrayTable();
-        tt.setArrayValue(new Constant(null, DataTypeManager.DefaultDataClasses.OBJECT));
+        tt.setArrayValue(new Constant(null, DataTypeManager.DefaultDataClasses.NULL));
         List<TableFunctionReference.ProjectedColumn> columns = new ArrayList<TableFunctionReference.ProjectedColumn>();
         columns.add(new TableFunctionReference.ProjectedColumn("x", "string"));
         columns.add(new TableFunctionReference.ProjectedColumn("y", "date"));
@@ -5237,7 +5234,7 @@ public class TestParser {
     	AssignmentStatement assigStmt =	new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1))); //$NON-NLS-1$
     	RaiseStatement errStmt =	new RaiseStatement(new Constant("My Error")); //$NON-NLS-1$
     	Block b = new Block();
-    	b.setExceptionGroup("g");
+    	b.setExceptionGroup("e");
     	b.addStatement(cmdStmt);
     	b.addStatement(assigStmt);
     	b.addStatement(errStmt, true);
-- 
1.8.3.1

