use of org.springframework.data.relational.core.sql.Update in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldRenderUpdateWithLiteral.
// DATAJDBC-335
@Test
public void shouldRenderUpdateWithLiteral() {
Table table = SQL.table("mytable");
Column column = table.column("foo");
Update update = StatementBuilder.update(table).set(column.set(SQL.literalOf(20))).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = 20");
}
use of org.springframework.data.relational.core.sql.Update in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldRenderSimpleUpdate.
// DATAJDBC-335
@Test
public void shouldRenderSimpleUpdate() {
Table table = SQL.table("mytable");
Column column = table.column("foo");
Update update = StatementBuilder.update(table).set(column.set(SQL.bindMarker())).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = ?");
}
use of org.springframework.data.relational.core.sql.Update in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldRenderMultipleColumnUpdate.
// DATAJDBC-335
@Test
public void shouldRenderMultipleColumnUpdate() {
Table table = SQL.table("mytable");
Column foo = table.column("foo");
Column bar = table.column("bar");
Update update = //
StatementBuilder.update(table).set(foo.set(SQL.bindMarker()), //
bar.set(SQL.bindMarker())).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = ?, bar = ?");
}
use of org.springframework.data.relational.core.sql.Update in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldCreateUpdateWIthCondition.
// DATAJDBC-335
@Test
public void shouldCreateUpdateWIthCondition() {
Table table = SQL.table("mytable");
Column column = table.column("foo");
Update update = StatementBuilder.update(table).set(column.set(SQL.bindMarker())).where(column.isNull()).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = ? WHERE mytable.foo IS NULL");
}