use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.
the class TestProcessor method setParameterValues.
public static void setParameterValues(List<?> values, Command command, CommandContext context) {
VariableContext vc = new VariableContext();
Iterator<?> valIter = values.iterator();
for (Reference ref : ReferenceCollectorVisitor.getReferences(command)) {
if (!ref.isPositional()) {
continue;
}
// $NON-NLS-1$
vc.setGlobalValue(ref.getContextSymbol(), valIter.next());
}
context.setVariableContext(vc);
}
use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.
the class TestResolver method testUpdateSetClauseReferenceType.
@Test
public void testUpdateSetClauseReferenceType() {
// $NON-NLS-1$
String sql = "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = ?;";
Update update = (Update) helpResolve(sql, RealMetadataFactory.example1Cached());
Expression ref = update.getChangeList().getClauses().get(1).getValue();
assertTrue(ref instanceof Reference);
assertNotNull(ref.getType());
}
use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.
the class TestFunctionResolving method testResolveConvertReference.
@Test
public void testResolveConvertReference() throws Exception {
// $NON-NLS-1$
Function function = new Function("convert", new Expression[] { new Reference(0), new Constant(DataTypeManager.DefaultDataTypes.BOOLEAN) });
ResolverVisitor.resolveLanguageObject(function, RealMetadataFactory.example1Cached());
assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getType());
assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getArgs()[0].getType());
}
use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.
the class TestLimitParsing method testLimitWithReferences3.
@Test
public void testLimitWithReferences3() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
// $NON-NLS-1$
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Reference(0), new Reference(1)));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a limit ?,?", "SELECT * FROM a LIMIT ?, ?", query);
}
use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.
the class TestLimitParsing method testLimitWithReferences2.
@Test
public void testLimitWithReferences2() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
// $NON-NLS-1$
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Constant(new Integer(50)), new Reference(0)));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a limit 50,?", "SELECT * FROM a LIMIT 50, ?", query);
}
Aggregations