use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testStringConversion3.
// special test for both sides are String
@Test
public void testStringConversion3() {
// Expected left expression
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("pm3.g1.e1");
e1.setType(DataTypeManager.DefaultDataClasses.STRING);
// Expected right expression
// $NON-NLS-1$
Constant e2 = new Constant("2003-02-27");
// Expected criteria
CompareCriteria expected = new CompareCriteria();
expected.setLeftExpression(e1);
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(e2);
// Resolve the query and check against expected objects
// $NON-NLS-1$
CompareCriteria actual = (CompareCriteria) helpResolveCriteria("pm3.g1.e1='2003-02-27'");
// if (! actual.getLeftExpression().equals(expected.getLeftExpression())) {
// System.out.println("left exprs not equal");
// } else if (!actual.getRightExpression().equals(expected.getRightExpression())) {
// System.out.println("right exprs not equal");
// }
// $NON-NLS-1$
assertEquals("Did not match expected criteria", expected, actual);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestAccessNode method testShouldExecuteUpdate.
@Test
public void testShouldExecuteUpdate() throws Exception {
Update update = new Update();
// $NON-NLS-1$
update.setGroup(new GroupSymbol("test"));
// $NON-NLS-1$ //$NON-NLS-2$
update.addChange(new ElementSymbol("e1"), new Constant("1"));
assertTrue(RelationalNodeUtil.shouldExecute(update, false));
update.setChangeList(new SetClauseList());
assertFalse(RelationalNodeUtil.shouldExecute(update, false));
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestAccessNode method testOpen_Defect16059.
@Test
public void testOpen_Defect16059() throws Exception {
// $NON-NLS-1$
Query query = (Query) TestResolver.helpResolve("SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5 AND ? IS NULL", RealMetadataFactory.example1Cached());
IsNullCriteria nullCrit = (IsNullCriteria) ((CompoundCriteria) query.getCriteria()).getCriteria(1);
nullCrit.setExpression(new Constant(null));
// $NON-NLS-1$
helpTestOpen(query, "SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5", true);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestDependentCriteriaProcessor method testNegatedSetCriteria.
@Test
public void testNegatedSetCriteria() throws Exception {
DependentAccessNode dan = new DependentAccessNode(0);
// $NON-NLS-1$
SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new Constant(1), new Constant(2)));
sc.setAllConstants(true);
sc.negate();
DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
Criteria result = dcp.prepareCriteria();
assertEquals(sc, result);
assertFalse(dcp.hasNextCommand());
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestDependentCriteriaProcessor method testSetCriteria.
@Test
public void testSetCriteria() throws Exception {
DependentAccessNode dan = new DependentAccessNode(0);
// $NON-NLS-1$
SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new Constant(1), new Constant(2)));
sc.setAllConstants(true);
DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
Criteria result = dcp.prepareCriteria();
// $NON-NLS-1$
assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result);
assertTrue(dcp.hasNextCommand());
}
Aggregations