From 22588c52a92ec8fa8142fe30da8edb7e270a58a8 Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 17 Jul 2023 15:05:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20json=20field=20valu?= =?UTF-8?q?e=20=E5=8F=AF=E8=83=BD=E4=B8=BA=20None=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/db/fields.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/common/db/fields.py b/apps/common/db/fields.py index d1695c19d..aff54c75a 100644 --- a/apps/common/db/fields.py +++ b/apps/common/db/fields.py @@ -459,7 +459,7 @@ class JSONManyToManyDescriptor: custom_q = Q() for rule in attr_rules: - value = getattr(obj, rule['name'], '') + value = getattr(obj, rule['name'], None) or '' rule_value = rule.get('value', '') rule_match = rule.get('match', 'exact') @@ -474,7 +474,7 @@ class JSONManyToManyDescriptor: elif rule_match == 'exact': res &= value == rule_value or rule_value == '*' elif rule_match == 'contains': - res &= rule_value in value + res &= (rule_value in value) elif rule_match == 'startswith': res &= str(value).startswith(str(rule_value)) elif rule_match == 'endswith':