From 56f4f33899c681ff98b9938c734c79498ef6de41 Mon Sep 17 00:00:00 2001 From: sanguinedab <1398612413@qq.com> Date: Tue, 22 Oct 2024 15:12:41 +0800 Subject: [PATCH 1/3] Modify remove_filtered_policy method to support filtering of empty strings --- casbin_pymongo_adapter/adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/casbin_pymongo_adapter/adapter.py b/casbin_pymongo_adapter/adapter.py index 2ee8ae3..b7e23f7 100644 --- a/casbin_pymongo_adapter/adapter.py +++ b/casbin_pymongo_adapter/adapter.py @@ -165,7 +165,7 @@ 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) From 24443b9ede8dfba308331e3b87653701a96d7263 Mon Sep 17 00:00:00 2001 From: sanguinedab <68048125+sanguinedab@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:02:56 +0800 Subject: [PATCH 2/3] Update adapter.py fix 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 b7e23f7..1accc2d 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) if value != "" + f"v{index + field_index}": value + for index, value in enumerate(field_values) + if value != "" } query["ptype"] = ptype results = self._collection.delete_many(query) From 0ffb7818a02c2d9fba5040749a82ba8c024ebe5e Mon Sep 17 00:00:00 2001 From: sanguinedab <68048125+sanguinedab@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:41:00 +0800 Subject: [PATCH 3/3] fix adapter.py black format --- casbin_pymongo_adapter/adapter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/casbin_pymongo_adapter/adapter.py b/casbin_pymongo_adapter/adapter.py index 1accc2d..6829f5c 100644 --- a/casbin_pymongo_adapter/adapter.py +++ b/casbin_pymongo_adapter/adapter.py @@ -165,8 +165,8 @@ 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