use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.
the class SelectProjectionTest method projectColumns.
@Test
void projectColumns() {
Database database = TestDatabase.testDatabase(new AnsiDialect());
Alias<WidgetRow> w = database.table(WidgetRow.class).as("w");
database.from(w).select(WidgetRow::name, "n1").comma(WidgetRow::description, "d1").comma(WidgetRow::manufacturerId, "m1").comma("w", WidgetRow::name, "n2").comma("w", WidgetRow::description, "d2").comma("w", WidgetRow::manufacturerId, "m2").comma(w, WidgetRow::name, "n3").comma(w, WidgetRow::description, "d3").comma(w, WidgetRow::manufacturerId, "m3").where(WidgetRow::name).isEqualTo("Bob").list(transaction);
verify(transaction).query(sql.capture(), args.capture(), rowMapper.capture());
assertThat(sql.getValue(), is("select " + "w.NAME as n1, w.DESCRIPTION as d1, w.MANUFACTURER_ID as m1, " + "w.NAME as n2, w.DESCRIPTION as d2, w.MANUFACTURER_ID as m2, " + "w.NAME as n3, w.DESCRIPTION as d3, w.MANUFACTURER_ID as m3 " + "from SIESTA.WIDGET w " + "where w.NAME = ?"));
assertThat(args.getValue(), arrayWithSize(1));
assertThat(args.getValue()[0], is("Bob"));
}
Aggregations