#1581 - ENH: Add query.asUpdate() ... to convert a query into an UpdateQuery (typically with query beans)

This commit is contained in:
rob bygrave
2018-12-19 14:45:33 +13:00
parent 8fc6c4c648
commit 138b587ff7
7 changed files with 106 additions and 2 deletions
@@ -75,6 +75,29 @@ public class UpdateQueryTest extends BaseTestCase {
assertThat(ormQueryMetrics.get(0).getLabel()).isEqualTo("updateAll");
}
@Test
public void query_asUpdate() {
ResetBasicData.reset();
LoggedSqlCollector.start();
int rows = server().find(Customer.class)
.where()
.gt("id", 1000)
.asUpdate()
.setRaw("status = status")
.setLabel("asUpdate")
.update();
List<String> sql = LoggedSqlCollector.stop();
assertThat(sql).hasSize(1);
assertThat(rows).isEqualTo(0);
assertThat(sql.get(0)).contains("update o_customer set status = status where id > ?");
}
@Test
public void update_withTransactionBatch() {