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");
}
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");
}
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");
}