* Tests whether replacing the select columns in limit/offset
* treatment works (double column names must be aliased)
*/
public void testSelectColumnsForLimitOffset()
{
UniqueList input = new UniqueList();
input.add("c1");
input.add("c2");
input.add("c1 a1");
input.add("c1 a2");
input.add("t.c1 a4");
// A list with no duplicates must remain unchanged
Query query = new Query();
query.getSelectClause().addAll(input);
new OracleAdapter().generateLimits(query, 0, 1);
assertEquals(input, query.getSelectClause());
// double column names must be aliased
query = new Query();
input.set(1, "t.c1");
query.getSelectClause().addAll(input);
new OracleAdapter().generateLimits(query, 0, 1);
UniqueList expected = new UniqueList(input);
expected.set(1, "t.c1 a0");
assertEquals(expected, query.getSelectClause());
// a column name which is the same as an alias name must be replaced
query = new Query();
input.set(1, "c2");
input.set(0, "t.a1");
query.getSelectClause().addAll(input);
new OracleAdapter().generateLimits(query, 0, 1);
expected = new UniqueList(input);
expected.set(0, "t.a1 a0");
assertEquals(query.getSelectClause(), expected);
// triple column names must be made unique
query = new Query();
input.set(1, "t2.a1");
query.getSelectClause().addAll(input);
new OracleAdapter().generateLimits(query, 0, 1);
expected = new UniqueList(input);
expected.set(0, "t.a1 a0");
expected.set(1, "t2.a1 a3");
assertEquals(expected, query.getSelectClause());
}