use of com.developmentontheedge.sql.format.ContextApplier in project be5 by DevelopmentOnTheEdge.
the class SubQueryTest method testVarsInFieldReference.
@Test
public void testVarsInFieldReference() {
AstStart start = SqlQuery.parse("SELECT ID, '<sql limit=\"2\">SELECT field.<var:reference/> FROM table.<var:name/></sql>' FROM table");
ContextApplier contextApplier = new ContextApplier(new BasicQueryContext.Builder().build());
contextApplier.applyContext(start);
String key = contextApplier.subQueryKeys().findFirst().get();
Map<String, String> vars = new HashMap<String, String>();
vars.put("reference", "ref");
vars.put("name", "name");
AstBeSqlSubQuery subQuery = contextApplier.applyVars(key, vars::get);
assertEquals("SELECT field.ref FROM table.name LIMIT 2", subQuery.getQuery().format());
}
Aggregations