Skip to content

fix(python): group additional fulltext WHERE predicates - #32019

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix-fulltext-where-grouping-32018
Nov 2, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix-fulltext-where-grouping-32018

Conversation

@MatrixAdventurer

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Fixes #32018

What this PR does / why we need it:

An additional condition such as category = 'a' OR category = 'b' was concatenated directly after MATCH with AND. SQL precedence then allowed category b rows to bypass the search predicate; chained conditions could also bypass one another.

Wrap each additional predicate in parentheses in both FulltextQueryBuilder.as_sql() and FulltextSearchBuilder._build_sql(). The resulting expression is MATCH(...) AND (condition1) AND (condition2).

Add eight regression/control cases covering both public builders, an OR condition alone, OR in the first or last chained condition, and no additional conditions. Tests execute the generated Boolean SQL in SQLite with only MATCH replaced by a precomputed score column; they verify grouping independently of fulltext scoring. No live MatrixOne server validation is claimed.

Validation on base d24f446 (Python 3.12, SQLAlchemy 2.1.6):

  • Before: six regression failures and two passing controls.
  • After: full offline suite passed, 2953 tests plus 103 subtests.
  • Black, fatal Flake8 checks (E9,F63,F7,F82), and git diff --check passed.

Production delta: two changed lines; queries without additional predicates retain their SQL.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Nov 2, 2026
@XuPeng-SH

XuPeng-SH commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: f81426bbc2ee925ace2af087d84828c43f645c1f

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: f81426bbc2ee925ace2af087d84828c43f645c1f

Assessment: approve

Both builders correctly group additional predicates, preventing OR conditions from bypassing MATCH or other filters. No actionable findings.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Reviewed the complete delta, public consumers, linked issue and all discussion entries.

  • Reused eight successful current-head SDK offline CI jobs; verified their selection includes the new regression tests.

  • Local syntax, Boolean-oracle, source-identity and discussion-coverage checks passed; receipt: checks/1793607510914380272-2.json.

  • Saved review plan, discussion assessment and validation evidence; source remains unchanged.

Limitations:

  • No local SDK pytest rerun or live MatrixOne scoring validation. Raw CI logs were not supplied.

@mergify mergify Bot added the queued label Nov 2, 2026
@mergify

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as c9b9177 at 09:54 UTC

1 h 35 min in the queue, 3 min of it CI.

So far

  • ✅ Entered the queue Mon 2 Nov, 08:20 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 09:54 · c9b9177 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Python fulltext builders do not group additional OR predicates

2 participants