@Test public void testFunctionNativeQuery() throws SQLException { String ddl = "create foreign table t (x integer, y integer); create foreign function bsl (arg1 integer, arg2 integer) returns integer OPTIONS (\"teiid_rel:native-query\" '$1 << $2');"; helpTestVisitor(ddl, "select bsl(x, y) from t", "SELECT t.x << t.y FROM t", true); helpTestVisitor(ddl, "select bsl(x, y) from t where x = 1 + 1", "SELECT t.x << t.y FROM t WHERE t.x = ?", true); TranslatedCommand tc = helpTestVisitor(ddl, "select bsl(1, y) from t where x = y", "SELECT ? << t.y FROM t WHERE t.x = t.y", true); JDBCQueryExecution qe = new JDBCQueryExecution(null, null, Mockito.mock(ExecutionContext.class), TRANSLATOR); PreparedStatement ps = Mockito.mock(PreparedStatement.class); qe.bind(ps, tc.getPreparedValues(), null); Mockito.verify(ps, Mockito.times(1)).setObject(1, 1, Types.INTEGER); }
List getPreparedValues() { return this.preparedValues; }
SQLConversionVisitor extends SQLStringVisitor implements SQLStringVisitor.Substitutor { List getPreparedValues() { return this.preparedValues; } }
SQLConversionVisitor extends SQLStringVisitor implements SQLStringVisitor.Substitutor { List getPreparedValues() { return this.preparedValues; } SQLConversionVisitor(JDBCExecutionFactory ef); }
SQLConversionVisitor extends SQLStringVisitor implements SQLStringVisitor.Substitutor { List getPreparedValues() { return this.preparedValues; } SQLConversionVisitor(JDBCExecutionFactory ef); @Override void append(LanguageObject obj); void visit(Call obj); void visit(Function obj); @Override void visit(Parameter obj); void visit(Literal obj); @Override void visit(In obj); @Override void visit(Like obj); @Override void visit(Comparison obj); @Override void visit(ExpressionValueSource obj); @Override void visit(SetClause obj); @Override void visit(DerivedColumn obj); @Override void visit(SearchedCase obj); void setExecutionContext(ExecutionContext context); boolean isPrepared(); void setPrepared(boolean prepared); boolean isUsingBinding(); @Override void substitute(Argument arg, StringBuilder builder, int index); @Override void visit(GroupBy obj); }
SQLConversionVisitor extends SQLStringVisitor implements SQLStringVisitor.Substitutor { List getPreparedValues() { return this.preparedValues; } SQLConversionVisitor(JDBCExecutionFactory ef); @Override void append(LanguageObject obj); void visit(Call obj); void visit(Function obj); @Override void visit(Parameter obj); void visit(Literal obj); @Override void visit(In obj); @Override void visit(Like obj); @Override void visit(Comparison obj); @Override void visit(ExpressionValueSource obj); @Override void visit(SetClause obj); @Override void visit(DerivedColumn obj); @Override void visit(SearchedCase obj); void setExecutionContext(ExecutionContext context); boolean isPrepared(); void setPrepared(boolean prepared); boolean isUsingBinding(); @Override void substitute(Argument arg, StringBuilder builder, int index); @Override void visit(GroupBy obj); static final String TEIID_NON_PREPARED; }