Arrays.toString(schemas[0].getTableByName("CUSTOMERS").getColumns()));
}
public void testQueryRewriterQuoteAliases() throws Exception {
JdbcDataContext dc = new JdbcDataContext(_connection, new TableType[] { TableType.TABLE, TableType.VIEW }, null);
IQueryRewriter queryRewriter = dc.getQueryRewriter();
assertSame(DefaultQueryRewriter.class, queryRewriter.getClass());
Schema schema = dc.getSchemaByName("APP");
Table customersTable = schema.getTableByName("CUSTOMERS");
Query q = dc.query().from(customersTable).as("cus-tomers").select("CUSTOMERNAME").as("c|o|d|e").toQuery();
assertEquals(25000, dc.getFetchSizeCalculator().getFetchSize(q));
q.setMaxRows(5);
assertEquals("SELECT cus-tomers.\"CUSTOMERNAME\" AS c|o|d|e FROM APP.\"CUSTOMERS\" cus-tomers", q.toString());
String queryString = queryRewriter.rewriteQuery(q);
assertEquals("SELECT \"cus-tomers\".\"CUSTOMERNAME\" AS \"c|o|d|e\" FROM APP.\"CUSTOMERS\" \"cus-tomers\"",
queryString);
// We have to test that no additional quoting characters are added every
// time we run the rewriting
queryString = queryRewriter.rewriteQuery(q);
queryString = queryRewriter.rewriteQuery(q);
assertEquals("SELECT \"cus-tomers\".\"CUSTOMERNAME\" AS \"c|o|d|e\" FROM APP.\"CUSTOMERS\" \"cus-tomers\"",
queryString);
// Test that the original query is still the same (ie. it has been
// cloned for execution)