Skip to content

Commit

Permalink
fix: removeFilteredNamedGroupingPolicy "" filtered (#62)
Browse files Browse the repository at this point in the history
* fix: removeFilteredNamedGroupingPolicy "" filtered

* refactor: removeFilteredPolicy

* refactor: removeFilteredPolicy again

* fix: update node-version

* refactor: removeFilteredPolicy 2
  • Loading branch information
PokIsemaine authored May 19, 2023
1 parent c0435fe commit 47c2b81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/casbin/adapter/JDBCBaseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 47c2b81

Please sign in to comment.