feat(backend): 新增 rule_types / like_util / sql_builder + step9 重构支持条件树
自定义规则 v2 后端核心:把单条 LIKE 升级为递归条件树。
- web/core/rule_types.py(新)
- classify_field(data_type) → text/numeric/date/unknown
- COMPARATORS_BY_CLASS / DEFAULT_COMPARATOR / INPUT_HINT_BY_CLASS
- 文本 2 算子(contains / not_contains);数值 3 算子(gt / lt / eq);日期 2 算子(date_before / date_after)
- web/core/like_util.py(新)
- escape_like(s) + ESCAPE_CHAR = '!'(跨 DB 一致,避开达梦 [CODE:-6106])
- 从 step9 内嵌函数上提,从此模块 import
- web/core/sql_builder.py(新)
- build_where(node, bind, column_quoted, db_type) 递归编译 group 树
- _placeholder(db_type) MySQL %s / 达梦+Oracle ?
- 顶层 compile_rule(group, column_quoted, db_type) → (clause, params)
- web/core/step_impl/step9_custom_rules.py
- 主循环重写:每条规则编译 group 树 → 跑 SQL → LIMIT 200 命中
- _normalize_rule 自动包旧 payload {rule_type, user_input} → 新 group 树,兼容旧调用
- 摘要字段补齐:total_rules / executed_rules / skipped_empty_keyword / skipped_no_valid_leaf / failed_rules / total_matched_rows / violations / fields_checked
Showing
web/core/like_util.py
0 → 100644
web/core/rule_types.py
0 → 100644
web/core/sql_builder.py
0 → 100644
This diff is collapsed.
Please register or sign in to comment