过滤优化允许双下划线搜索内嵌字段

This commit is contained in:
chenzuoqing 2021-12-21 12:00:45 +08:00
parent 06c1d4f373
commit 447b8b265a
1 changed files with 3 additions and 1 deletions

View File

@ -170,7 +170,9 @@ class ListMixin(ModelViewBase):
# 遍历视图定义的过滤字段集合 # 遍历视图定义的过滤字段集合
for arg, operators in self.filter_fields: for arg, operators in self.filter_fields:
# 过滤参数不在字段列表中 # 过滤参数不在字段列表中
if arg not in all_fields: # 有可能是内嵌字段等,按双下划线切分查找
pre_field = arg.split("__")[0]
if pre_field not in all_fields:
continue continue
# get传递的参数值为空或不存在忽略 # get传递的参数值为空或不存在忽略
val = request.args.get(arg, "") val = request.args.get(arg, "")