Search in sources :

Example 1 with Delete

use of org.springframework.data.relational.core.sql.Delete in project spring-data-jdbc by spring-projects.

the class DeleteRendererUnitTests method shouldRenderWithCondition.

// DATAJDBC-335
@Test
public void shouldRenderWithCondition() {
    Table table = Table.create("bar");
    Delete delete = // 
    Delete.builder().from(table).where(// 
    table.column("foo").isEqualTo(table.column("baz"))).and(table.column("doe").isNull()).build();
    assertThat(SqlRenderer.toString(delete)).isEqualTo("DELETE FROM bar WHERE bar.foo = bar.baz AND bar.doe IS NULL");
}
Also used : Delete(org.springframework.data.relational.core.sql.Delete) Table(org.springframework.data.relational.core.sql.Table) Test(org.junit.jupiter.api.Test)

Example 2 with Delete

use of org.springframework.data.relational.core.sql.Delete in project spring-data-jdbc by spring-projects.

the class DeleteRendererUnitTests method shouldRenderWithoutWhere.

// DATAJDBC-335
@Test
public void shouldRenderWithoutWhere() {
    Table bar = SQL.table("bar");
    Delete delete = Delete.builder().from(bar).build();
    assertThat(SqlRenderer.toString(delete)).isEqualTo("DELETE FROM bar");
}
Also used : Delete(org.springframework.data.relational.core.sql.Delete) Table(org.springframework.data.relational.core.sql.Table) Test(org.junit.jupiter.api.Test)

Example 3 with Delete

use of org.springframework.data.relational.core.sql.Delete in project spring-data-jdbc by spring-projects.

the class DeleteRendererUnitTests method shouldConsiderTableAlias.

// DATAJDBC-335
@Test
public void shouldConsiderTableAlias() {
    Table table = Table.create("bar").as("my_bar");
    Delete delete = // 
    Delete.builder().from(table).where(// 
    table.column("foo").isEqualTo(table.column("baz"))).build();
    assertThat(SqlRenderer.toString(delete)).isEqualTo("DELETE FROM bar my_bar WHERE my_bar.foo = my_bar.baz");
}
Also used : Delete(org.springframework.data.relational.core.sql.Delete) Table(org.springframework.data.relational.core.sql.Table) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 Delete (org.springframework.data.relational.core.sql.Delete)3 Table (org.springframework.data.relational.core.sql.Table)3