mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1581 - ENH: Add query.asUpdate() ... to convert a query into an UpdateQuery (typically with query beans)
This commit is contained in:
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user