use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testExecNamedParamsReversed.
/**
* try entering params out of order
*/
@Test
public void testExecNamedParamsReversed() {
// $NON-NLS-1$
Object[] expectedParameterExpressions = new Object[] { new Constant("xyz"), new Constant(new Integer(5)) };
// $NON-NLS-1$
helpResolveExec("EXEC pm1.sq3(in2 = 5, \"in\" = 'xyz')", expectedParameterExpressions);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testStringConversion1.
@Test
public void testStringConversion1() {
// Expected left expression
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("pm3.g1.e2");
e1.setType(DataTypeManager.DefaultDataClasses.DATE);
// Expected right expression
Class srcType = DataTypeManager.DefaultDataClasses.STRING;
String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
// $NON-NLS-1$
Expression expression = new Constant("2003-02-27");
FunctionLibrary library = RealMetadataFactory.SFM.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });
Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
conversion.setType(DataTypeManager.getDataTypeClass(tgtTypeName));
conversion.setFunctionDescriptor(fd);
conversion.makeImplicit();
// Expected criteria
CompareCriteria expected = new CompareCriteria();
expected.setLeftExpression(e1);
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(conversion);
// Resolve the query and check against expected objects
// $NON-NLS-1$
CompareCriteria actual = (CompareCriteria) helpResolveCriteria("pm3.g1.e2='2003-02-27'");
// $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 TestResolver method testExecNamedParams.
@Test
public void testExecNamedParams() {
// $NON-NLS-1$
Object[] expectedParameterExpressions = new Object[] { new Constant("xyz"), new Constant(new Integer(5)) };
// $NON-NLS-1$
helpResolveExec("EXEC pm1.sq3(\"in\" = 'xyz', in2 = 5)", expectedParameterExpressions);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testExecNamedParamsOmitRequiredParamWithDefaultValue.
/**
* test omitting a required parameter that has a default value
*/
@Test
public void testExecNamedParamsOmitRequiredParamWithDefaultValue() {
// $NON-NLS-1$ //$NON-NLS-2$
Object[] expectedParameterExpressions = new Object[] { new Constant("xyz"), new Constant(new Integer(666)), new Constant("YYZ") };
// $NON-NLS-1$
StoredProcedure sp = helpResolveExec("EXEC pm1.sq3b(\"in\" = 'xyz', in2 = 666)", expectedParameterExpressions);
assertEquals("EXEC pm1.sq3b(\"in\" => 'xyz', in2 => 666)", sp.toString());
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testExecNamedParamsOptionalParamWithDefaultsCaseInsensitive.
@Test
public void testExecNamedParamsOptionalParamWithDefaultsCaseInsensitive() {
Object[] expectedParameterExpressions = helpGetStoredProcDefaultValues();
// override the default value for the first parameter
// $NON-NLS-1$
expectedParameterExpressions[0] = new Constant("xyz");
// $NON-NLS-1$
helpResolveExec("EXEC pm1.sqDefaults(iNsTrInG = 'xyz')", expectedParameterExpressions);
}
Aggregations