Fixed 12787 with syntax error in generated MySql json path expression (#12929)

### What problem does this PR solve?

Fixed 12787 with syntax error in generated MySql json path expression
https://github.com/infiniflow/ragflow/issues/12787 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

#### What was fixed:
- Changed line 237 in ob_conn.py from value_str = get_value_str(value)
if value else "" to value_str = get_value_str(value)
- This fixes the bug where falsy but valid values (0, False, "", [], {})
were being converted to empty strings, causing invalid SQL syntax
#### What was tested:
- Comprehensive unit tests covering all edge cases
- Regression tests specifically for the bug scenario

---------

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
Paul Y Hui
2026-02-03 09:50:14 +08:00
committed by GitHub
parent 59d7f3f456
commit f028f74883
2 changed files with 318 additions and 1 deletions

View File

@ -236,7 +236,7 @@ def get_metadata_filter_expression(metadata_filtering_conditions: dict) -> str:
continue
expr = f"JSON_EXTRACT(metadata, '$.{name}')"
value_str = get_value_str(value) if value else ""
value_str = get_value_str(value)
# Convert comparison operator to MySQL JSON path syntax
if comparison_operator == "is":