use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.
the class SelectExpressionTest method substrFunc.
@Test
void substrFunc() {
Database database = testDatabase(new AnsiDialect());
Alias<WidgetRow> w = database.table(WidgetRow.class).as("w");
String sql = database.from(w).select(substr(w.column(WidgetRow::name), 4), "name").where(WidgetRow::manufacturerId).isEqualTo(2L).sql();
assertThat(sql, is("select substr(w.NAME, ?) as name " + "from SIESTA.WIDGET w " + "where w.MANUFACTURER_ID = ?"));
}
use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.
the class SelectExpressionTest method isIn.
@Test
void isIn() {
Database database = testDatabase(new AnsiDialect());
String sql = database.from(WidgetRow.class).where(WidgetRow::widgetId).isIn(123L, 456L).sql();
assertThat(sql, is("select WIDGET.WIDGET_ID as WIDGET_WIDGET_ID, " + "WIDGET.NAME as WIDGET_NAME, " + "WIDGET.MANUFACTURER_ID as WIDGET_MANUFACTURER_ID, " + "WIDGET.DESCRIPTION as WIDGET_DESCRIPTION " + "from SIESTA.WIDGET WIDGET " + "where WIDGET.WIDGET_ID in (?, ?)"));
}
use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.
the class SelectExpressionTest method isLikeEscape.
@Test
void isLikeEscape() {
Database database = testDatabase(new AnsiDialect());
String sql = database.from(WidgetRow.class).where(WidgetRow::name).isLike("abc@%%", "@").sql();
assertThat(sql, is("select WIDGET.WIDGET_ID as WIDGET_WIDGET_ID, " + "WIDGET.NAME as WIDGET_NAME, " + "WIDGET.MANUFACTURER_ID as WIDGET_MANUFACTURER_ID, " + "WIDGET.DESCRIPTION as WIDGET_DESCRIPTION " + "from SIESTA.WIDGET WIDGET " + "where WIDGET.NAME like ? escape '@'"));
}
use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.
the class SelectExpressionTest method andAndOrsInWhere.
@Test
void andAndOrsInWhere() {
Database database = testDatabase(new AnsiDialect());
Alias<ManufacturerRow> m = database.table(ManufacturerRow.class).as("m");
String sql = database.from(m).where(ManufacturerRow::name).isEqualTo("Fred").or(ManufacturerRow::checked).isNull().and(ManufacturerRow::manufacturerId).isGreaterThan(3L).sql();
assertThat(sql, is("select m.MANUFACTURER_ID as m_MANUFACTURER_ID, m.NAME as m_NAME, m.CHECKED as m_CHECKED " + "from SIESTA.MANUFACTURER m " + "where m.NAME = ? or m.CHECKED is null and m.MANUFACTURER_ID > ?"));
}
use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.
the class SelectExpressionTest method andExpression.
@Test
void andExpression() {
Database database = testDatabase(new AnsiDialect());
Alias<ManufacturerRow> m = database.table(ManufacturerRow.class).as("m");
String sql = database.from(m).where(ManufacturerRow::checked).isLessThan(LocalDate.now()).and(ManufacturerRow::name).isEqualTo("Fred").and(column(ManufacturerRow::name).isEqualTo("Bob").or(ManufacturerRow::checked).isNull()).and(ManufacturerRow::checked).isGreaterThan(LocalDate.now()).sql();
assertThat(sql, is("select m.MANUFACTURER_ID as m_MANUFACTURER_ID, m.NAME as m_NAME, m.CHECKED as m_CHECKED " + "from SIESTA.MANUFACTURER m " + "where m.CHECKED < cast(? as date) and m.NAME = ? and (m.NAME = ? or m.CHECKED is null) and m.CHECKED > cast(? as date)"));
}
Aggregations