Search in sources :

Example 46 with AnsiDialect

use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.

the class SelectExpressionTest method isNotNull.

@Test
void isNotNull() {
    Database database = testDatabase(new AnsiDialect());
    String sql = database.from(WidgetRow.class).where(WidgetRow::manufacturerId).isNotNull().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.MANUFACTURER_ID is not null"));
}
Also used : WidgetRow(com.cadenzauk.siesta.model.WidgetRow) AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Test(org.junit.jupiter.api.Test)

Example 47 with AnsiDialect

use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.

the class SelectExpressionTest method isNull.

@Test
void isNull() {
    Database database = testDatabase(new AnsiDialect());
    String sql = database.from(WidgetRow.class).where(WidgetRow::description).isNull().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.DESCRIPTION is null"));
}
Also used : WidgetRow(com.cadenzauk.siesta.model.WidgetRow) AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Test(org.junit.jupiter.api.Test)

Example 48 with AnsiDialect

use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.

the class SelectExpressionTest method isNotIn.

@Test
void isNotIn() {
    Database database = testDatabase(new AnsiDialect());
    String sql = database.from(WidgetRow.class).where(WidgetRow::widgetId).isNotIn(123L, 456L, 789L).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 not in (?, ?, ?)"));
}
Also used : WidgetRow(com.cadenzauk.siesta.model.WidgetRow) AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Test(org.junit.jupiter.api.Test)

Example 49 with AnsiDialect

use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.

the class SelectExpressionTest method isNotLikeEscape.

@Test
void isNotLikeEscape() {
    Database database = testDatabase(new AnsiDialect());
    String sql = database.from(WidgetRow.class).where(WidgetRow::name).isNotLike("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 not like ? escape '+'"));
}
Also used : WidgetRow(com.cadenzauk.siesta.model.WidgetRow) AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Test(org.junit.jupiter.api.Test)

Example 50 with AnsiDialect

use of com.cadenzauk.siesta.dialect.AnsiDialect in project siesta by cadenzauk.

the class SelectExpressionTest method isLike.

@Test
void isLike() {
    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 ?"));
}
Also used : WidgetRow(com.cadenzauk.siesta.model.WidgetRow) AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Test(org.junit.jupiter.api.Test)

Aggregations

AnsiDialect (com.cadenzauk.siesta.dialect.AnsiDialect)56 TestDatabase.testDatabase (com.cadenzauk.siesta.model.TestDatabase.testDatabase)36 Test (org.junit.jupiter.api.Test)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 MethodSource (org.junit.jupiter.params.provider.MethodSource)24 WidgetRow (com.cadenzauk.siesta.model.WidgetRow)23 Database (com.cadenzauk.siesta.Database)16 MockitoTest (com.cadenzauk.core.MockitoTest)14 SalespersonRow (com.cadenzauk.siesta.model.SalespersonRow)10 TestDatabase (com.cadenzauk.siesta.model.TestDatabase)10 ManufacturerRow (com.cadenzauk.siesta.model.ManufacturerRow)8 UncheckedAutoCloseable (com.cadenzauk.core.lang.UncheckedAutoCloseable)5 InWhereExpectingAnd (com.cadenzauk.siesta.grammar.select.InWhereExpectingAnd)4 Scope (com.cadenzauk.siesta.Scope)3 Timestamp (java.sql.Timestamp)3 RandomValues.randomLocalDate (com.cadenzauk.core.RandomValues.randomLocalDate)2 RandomValues.randomLocalDateTime (com.cadenzauk.core.RandomValues.randomLocalDateTime)2 InvalidJoinException (com.cadenzauk.siesta.grammar.InvalidJoinException)2 LocalDate (java.time.LocalDate)2 LocalDateTime (java.time.LocalDateTime)2