Replace Insert info by update in OTRemoteSql push method
@@ -116,16 +116,11 @@ public class OTRemoteSql<D> implements OTRemote<Integer, D> {
for (int i = 0; i < commits.size(); i++) {
OTCommit<Integer, D> commit = commits.get(i);
- try (PreparedStatement ps = connection.prepareStatement(sql("" +
- "INSERT INTO ot_revisions (scope, id, type, checkpoint) VALUES (?, ?, ?, ?) " +
- "ON DUPLICATE KEY UPDATE " +
- "scope = values(scope)," +
- "type = values(type)," +
- "checkpoint = values(checkpoint)"))) {
- ps.setString(1, scope);
- ps.setInt(2, commit.getId());
- ps.setString(3, (i == commits.size() - 1) ? "HEAD" : "INNER");
- ps.setString(4, commit.getCheckpoint() == null ? null : toJson(commit.getCheckpoint()));
+ try (PreparedStatement ps = connection.prepareStatement(sql(
+ "UPDATE ot_revisions SET `type`=?, `checkpoint`=? WHERE `id`=?"))) {
+ ps.setString(1, (i == commits.size() - 1) ? "HEAD" : "INNER");
+ ps.setString(2, commit.getCheckpoint() == null ? null : toJson(commit.getCheckpoint()));
+ ps.setInt(3, commit.getId());
ps.executeUpdate();
}
