mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Fix bulk update command failing on SQL based storages when tracking operation stats with multiple constraints (#2699)
This commit is contained in:
parent
7854de8991
commit
5d0c578da1
@ -103,6 +103,17 @@ public final class BulkUpdate {
|
|||||||
// (DELETE FROM or UPDATE)
|
// (DELETE FROM or UPDATE)
|
||||||
this.action.appendSql(builder);
|
this.action.appendSql(builder);
|
||||||
|
|
||||||
|
return appendConstraintsAsSql(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the constraints of this {@link BulkUpdate} to the provided statement builder in SQL syntax
|
||||||
|
*
|
||||||
|
* @param builder the statement builder to append the constraints to
|
||||||
|
* @return the same statement builder provided as input
|
||||||
|
*/
|
||||||
|
public PreparedStatementBuilder appendConstraintsAsSql(PreparedStatementBuilder builder) {
|
||||||
|
|
||||||
// if there are no constraints, just return without a WHERE clause
|
// if there are no constraints, just return without a WHERE clause
|
||||||
if (this.queries.isEmpty()) {
|
if (this.queries.isEmpty()) {
|
||||||
return builder;
|
return builder;
|
||||||
|
@ -261,10 +261,7 @@ public class SqlStorage implements StorageImplementation {
|
|||||||
if (bulkUpdate.isTrackingStatistics()) {
|
if (bulkUpdate.isTrackingStatistics()) {
|
||||||
PreparedStatementBuilder builder = new PreparedStatementBuilder();
|
PreparedStatementBuilder builder = new PreparedStatementBuilder();
|
||||||
builder.append(USER_PERMISSIONS_SELECT_DISTINCT);
|
builder.append(USER_PERMISSIONS_SELECT_DISTINCT);
|
||||||
if (!bulkUpdate.getQueries().isEmpty()) {
|
bulkUpdate.appendConstraintsAsSql(builder);
|
||||||
builder.append(" WHERE ");
|
|
||||||
bulkUpdate.getQueries().forEach(query -> query.appendSql(builder));
|
|
||||||
}
|
|
||||||
|
|
||||||
try (PreparedStatement lookup = builder.build(c, this.statementProcessor)) {
|
try (PreparedStatement lookup = builder.build(c, this.statementProcessor)) {
|
||||||
try (ResultSet rs = lookup.executeQuery()) {
|
try (ResultSet rs = lookup.executeQuery()) {
|
||||||
@ -291,10 +288,7 @@ public class SqlStorage implements StorageImplementation {
|
|||||||
if (bulkUpdate.isTrackingStatistics()) {
|
if (bulkUpdate.isTrackingStatistics()) {
|
||||||
PreparedStatementBuilder builder = new PreparedStatementBuilder();
|
PreparedStatementBuilder builder = new PreparedStatementBuilder();
|
||||||
builder.append(GROUP_PERMISSIONS_SELECT_ALL);
|
builder.append(GROUP_PERMISSIONS_SELECT_ALL);
|
||||||
if (!bulkUpdate.getQueries().isEmpty()) {
|
bulkUpdate.appendConstraintsAsSql(builder);
|
||||||
builder.append(" WHERE ");
|
|
||||||
bulkUpdate.getQueries().forEach(query -> query.appendSql(builder));
|
|
||||||
}
|
|
||||||
|
|
||||||
try (PreparedStatement lookup = builder.build(c, this.statementProcessor)) {
|
try (PreparedStatement lookup = builder.build(c, this.statementProcessor)) {
|
||||||
try (ResultSet rs = lookup.executeQuery()) {
|
try (ResultSet rs = lookup.executeQuery()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user