Merge "BatchUpdate: Always bump rowVersion when dirty"
This commit is contained in:
@@ -589,26 +589,23 @@ public class BatchUpdate implements AutoCloseable {
|
||||
for (Op op : e.getValue()) {
|
||||
dirty |= op.updateChange(ctx);
|
||||
}
|
||||
ctx.getChange().setLastUpdatedOn(ctx.getWhen());
|
||||
Iterable<Change> changes = Collections.singleton(ctx.getChange());
|
||||
if (!dirty) {
|
||||
return;
|
||||
}
|
||||
if (newChanges.containsKey(id)) {
|
||||
db.changes().insert(changes);
|
||||
db.changes().insert(bumpLastUpdatedOn(ctx));
|
||||
} else if (ctx.saved) {
|
||||
db.changes().update(changes);
|
||||
db.changes().update(bumpLastUpdatedOn(ctx));
|
||||
} else if (ctx.deleted) {
|
||||
db.changes().delete(changes);
|
||||
}
|
||||
if (dirty) {
|
||||
db.commit();
|
||||
db.changes().delete(bumpLastUpdatedOn(ctx));
|
||||
} else {
|
||||
db.changes().update(bumpRowVersionNotLastUpdatedOn(ctx));
|
||||
}
|
||||
db.commit();
|
||||
} finally {
|
||||
db.rollback();
|
||||
}
|
||||
|
||||
if (!dirty) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx.deleted) {
|
||||
if (notesMigration.writeChanges()) {
|
||||
new ChangeDelete(plcUtil, getRepository(), ctx.getNotes()).delete();
|
||||
@@ -636,6 +633,17 @@ public class BatchUpdate implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
private static Iterable<Change> bumpLastUpdatedOn(ChangeContext ctx) {
|
||||
Change c = ctx.getChange();
|
||||
c.setLastUpdatedOn(ctx.getWhen());
|
||||
return Collections.singleton(c);
|
||||
}
|
||||
|
||||
private static Iterable<Change> bumpRowVersionNotLastUpdatedOn(
|
||||
ChangeContext ctx) {
|
||||
return Collections.singleton(ctx.getChange());
|
||||
}
|
||||
|
||||
private ChangeContext newChangeContext(Change.Id id) throws Exception {
|
||||
Change c = newChanges.get(id);
|
||||
if (c == null) {
|
||||
|
||||
Reference in New Issue
Block a user