Author: shawkins
Date: 2011-05-27 16:07:57 -0400 (Fri, 27 May 2011)
New Revision: 3202
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
Log:
TEIID-1613 fix for insert resolving
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-05-26
15:47:40 UTC (rev 3201)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-05-27
20:07:57 UTC (rev 3202)
@@ -135,7 +135,7 @@
List<Reference> references = new
ArrayList<Reference>(insert.getVariables().size());
for (int i = 0; i < insert.getVariables().size(); i++) {
Reference ref = new Reference(i);
- ref.setType(((ElementSymbol)insert.getVariables().get(i)).getType());
+ ref.setType(insert.getVariables().get(i).getType());
references.add(ref);
}
insert.setValues(references);
@@ -198,7 +198,7 @@
//TODO: a special case here is a projected literal
throw new
QueryResolverException(QueryPlugin.Util.getString("InsertResolver.cant_convert_query_type",
new Object[] {expression, expression.getType().getName(), element,
element.getType().getName()})); //$NON-NLS-1$
}
- } else if (element.getType() == null && expression.getType() != null
&& !usingQuery) {
+ } else if (element.getType() == null && expression.getType() != null)
{
element.setType(expression.getType());
newValues.add(expression);
} else {
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-05-26
15:47:40 UTC (rev 3201)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-05-27
20:07:57 UTC (rev 3202)
@@ -2618,6 +2618,11 @@
helpResolveException(sql, "Cannot convert insert query expression projected
symbol '3' of type java.lang.Integer to insert column 'pm1.g1.e3' of type
java.lang.Boolean"); //$NON-NLS-1$
}
+ @Test public void testInsertWithQueryImplicitWithColumns() {
+ String sql = "Insert into #X (x) select 1 as x"; //$NON-NLS-1$
+ helpResolve(sql); //$NON-NLS-1$
+ }
+
@Test public void testInsertWithQueryImplicitWithoutColumns() {
String sql = "Insert into #X select 1 as x, 2 as y, 3 as z";
//$NON-NLS-1$
helpResolve(sql); //$NON-NLS-1$
Show replies by date