Skip to content

Commit

Permalink
fix rollback database query (#2591)
Browse files Browse the repository at this point in the history
  • Loading branch information
SirYwell committed Mar 2, 2024
1 parent 3a9bbb7 commit f5dfe3a
Showing 1 changed file with 15 additions and 10 deletions.
Expand Up @@ -159,18 +159,23 @@ public Iterable<Supplier<RollbackOptimizedHistory>> getEdits(
Future<Integer> future = call(() -> {
try {
int count = 0;
String stmtStr;
String stmtStr = """
SELECT * FROM `%sedits`
WHERE `time` > ?
AND `x2` >= ?
AND `x1` <= ?
AND `z2` >= ?
AND `z1` <= ?
AND `y2` >= ?
AND `y1` <= ?
""";
if (uuid != null) {
stmtStr += "\n AND `player`= ?";
}
if (ascending) {
if (uuid == null) {
stmtStr = "SELECT * FROM`%sedits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND " +
"`y2`>=? AND `y1`<=? ORDER BY `time` , `id`";
} else {
stmtStr = "SELECT * FROM`%sedits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND " +
"`y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
}
stmtStr += "\n ORDER BY `time` ASC, `id` ASC";
} else {
stmtStr = "SELECT * FROM`%sedits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND " +
"`y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
stmtStr += "\n ORDER BY `time` DESC, `id` DESC";
}
try (PreparedStatement stmt = connection.prepareStatement(stmtStr.formatted(this.prefix))) {
stmt.setInt(1, (int) (minTime / 1000));
Expand Down

0 comments on commit f5dfe3a

Please sign in to comment.