/** Ensures that views are named with v_ even without metadata */ @Test public void testViewAliasing() throws Exception { String sql = "select y.e1 from (select pm1.g1.e1 from pm1.g1) y"; // $NON-NLS-1$ Query command = (Query) QueryParser.getQueryParser().parseCommand(sql); ((ElementSymbol) command.getSelect().getSymbol(0)) .setGroupSymbol(new GroupSymbol("y")); // $NON-NLS-1$ command.acceptVisitor(new AliasGenerator(true)); assertEquals( "SELECT v_0.c_0 FROM (SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0) AS v_0", command.toString()); // $NON-NLS-1$ }
@Override public void visit(Query obj) { preVisitVisitor(obj); visitNodes(obj.getWith()); visitNode(obj.getSelect()); visitNode(obj.getInto()); visitNode(obj.getFrom()); visitNode(obj.getCriteria()); visitNode(obj.getGroupBy()); visitNode(obj.getHaving()); visitNode(obj.getOrderBy()); visitNode(obj.getLimit()); visitNode(obj.getOption()); postVisitVisitor(obj); }