diff --git a/.github/workflows/maven-ci.yml b/.github/workflows/maven-ci.yml index 6242056..bfba7ab 100644 --- a/.github/workflows/maven-ci.yml +++ b/.github/workflows/maven-ci.yml @@ -71,7 +71,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: 16 + node-version: 18 - name: Sematic Release run: | diff --git a/src/main/java/org/casbin/adapter/JDBCBaseAdapter.java b/src/main/java/org/casbin/adapter/JDBCBaseAdapter.java index 45acb58..008a6cd 100644 --- a/src/main/java/org/casbin/adapter/JDBCBaseAdapter.java +++ b/src/main/java/org/casbin/adapter/JDBCBaseAdapter.java @@ -473,14 +473,16 @@ public void removeFilteredPolicy(String sec, String ptype, int fieldIndex, Strin } String sql = renderActualSql("DELETE FROM casbin_rule WHERE ptype = ?"); int columnIndex = fieldIndex; - for (int i = 0; i < values.size(); i++) { + for (int i = 0; i < values.size(); i++, columnIndex++) { + if (Objects.equals(values.get(i), "")) continue; sql = String.format("%s%s%s%s", sql, " AND v", columnIndex, " = ?"); - columnIndex++; } try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setString(1, ptype); - for (int j = 0; j < values.size(); j++) { - ps.setString(j + 2, values.get(j)); + int index = 2; + for (String value : values) { + if (Objects.equals(value, "")) continue; + ps.setString(index++, value); } int rows = ps.executeUpdate(); if (rows < 1 && removePolicyFailed) {