use of org.teiid.language.Literal in project teiid by teiid.
the class TestSybaseConvertModifier method testTimestampToTime.
@Test
public void testTimestampToTime() throws Exception {
Literal c = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(89, 2, 3, 7, 8, 12, 99999), Timestamp.class);
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { c, // $NON-NLS-1$
LANG_FACTORY.createLiteral("time", String.class) }, java.sql.Time.class);
// $NON-NLS-1$
helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, CAST('1989-03-03 07:08:12.0' AS DATETIME), 8) AS datetime)");
}
use of org.teiid.language.Literal in project teiid by teiid.
the class TestLog10FunctionModifier method testModifier.
public void testModifier() {
Literal arg = LANG_FACTORY.createLiteral(new Double(5.2), Double.class);
// $NON-NLS-1$
Function func = LANG_FACTORY.createFunction("log10", Arrays.asList(arg), Double.class);
Log10FunctionModifier modifier = new Log10FunctionModifier(LANG_FACTORY);
modifier.translate(func);
// $NON-NLS-1$
assertEquals("log", func.getName());
assertEquals(Double.class, func.getType());
List<Expression> outArgs = func.getParameters();
assertEquals(2, outArgs.size());
assertEquals(arg, outArgs.get(1));
assertTrue(outArgs.get(1) instanceof Literal);
Literal newArg = (Literal) outArgs.get(0);
assertEquals(Integer.class, newArg.getType());
assertEquals(new Integer(10), newArg.getValue());
// $NON-NLS-1$
assertEquals("log(10, 5.2)", SQLStringVisitor.getSQLString(func));
}
use of org.teiid.language.Literal in project teiid by teiid.
the class TestMonthOrDayNameFunctionModifier method test1.
public void test1() throws Exception {
Literal arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 10000000), Timestamp.class);
helpTestMod(// $NON-NLS-1$
arg1, // $NON-NLS-1$
"Month", // $NON-NLS-1$
"rtrim(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'Month'))");
}
use of org.teiid.language.Literal in project teiid by teiid.
the class TestMonthOrDayNameFunctionModifier method test3.
public void test3() throws Exception {
Literal arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 10000000), Timestamp.class);
helpTestMod(// $NON-NLS-1$
arg1, // $NON-NLS-1$
"Day", // $NON-NLS-1$
"rtrim(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'Day'))");
}
use of org.teiid.language.Literal in project teiid by teiid.
the class TestOracleTranslator method testCharType.
@Test
public void testCharType() throws Exception {
CommandBuilder commandBuilder = new CommandBuilder(getOracleSpecificMetadata());
Command command = commandBuilder.getCommand("select id from smalla where description = 'a' and ndescription in ('b', 'c')");
for (Literal l : CollectorVisitor.collectObjects(Literal.class, command)) {
l.setBindEligible(true);
}
Connection connection = Mockito.mock(Connection.class);
PreparedStatement ps = Mockito.mock(PreparedStatement.class);
// $NON-NLS-1$
Mockito.stub(connection.prepareStatement("SELECT SmallishA.ID FROM SmallishA WHERE SmallishA.description = ? AND SmallishA.ndescription IN (?, ?)")).toReturn(ps);
OracleExecutionFactory ef = new OracleExecutionFactory();
ef.start();
JDBCQueryExecution e = new JDBCQueryExecution(command, connection, new FakeExecutionContextImpl(), ef);
e.execute();
Mockito.verify(ps, Mockito.times(1)).setObject(1, "a", OracleExecutionFactory.FIXED_CHAR_TYPE);
Mockito.verify(ps, Mockito.times(1)).setObject(2, "b", OracleExecutionFactory.FIXED_CHAR_TYPE);
}
Aggregations