From 37e0561bb678f11f291360a6eaf58121db6b7630 Mon Sep 17 00:00:00 2001 From: sanguinedab <68048125+sanguinedab@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:23:51 +0800 Subject: [PATCH] fix: modify remove_filtered_policy method to support filtering of empty strings (#12) * Modify remove_filtered_policy method to support filtering of empty strings * Update adapter.py fix format * fix adapter.py black format --- casbin_pymongo_adapter/adapter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/casbin_pymongo_adapter/adapter.py b/casbin_pymongo_adapter/adapter.py index 2ee8ae3..6829f5c 100644 --- a/casbin_pymongo_adapter/adapter.py +++ b/casbin_pymongo_adapter/adapter.py @@ -165,7 +165,9 @@ def remove_filtered_policy(self, sec, ptype, field_index, *field_values): if not (1 <= field_index + len(field_values) <= 6): return False query = { - f"v{index + field_index}": value for index, value in enumerate(field_values) + f"v{index + field_index}": value + for index, value in enumerate(field_values) + if value != "" } query["ptype"] = ptype results = self._collection.delete_many(query)