Merge pull request #10726 from jumpserver/pr@dev@perf_json_field_re_error

perf: 优化 json field re 报错问题
pull/10727/head
老广 1 year ago committed by GitHub
commit c6e19a2989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -378,9 +378,16 @@ class RelatedManager:
if match == 'ip_in':
q = cls.get_ip_in_q(name, val)
elif match in ("exact", "contains", "startswith", "endswith", "regex", "gte", "lte", "gt", "lt"):
elif match in ("exact", "contains", "startswith", "endswith", "gte", "lte", "gt", "lt"):
lookup = "{}__{}".format(name, match)
q = Q(**{lookup: val})
elif match == 'regex':
try:
re.compile(val)
lookup = "{}__{}".format(name, match)
q = Q(**{lookup: val})
except re.error:
q = ~Q()
elif match == "not":
q = ~Q(**{name: val})
elif match in ['m2m', 'in']:

Loading…
Cancel
Save