Repository navigation
Description
DRAFT 24 (SDK, 2026-10-27) — filing now
Title: [Bug]: FulltextSearchBuilder.limit(0) is silently dropped (falsy check) and diverges from the ORM builder's correct is-not-None handling
Description
FulltextSearchBuilder._build_sql (sqlalchemy_ext/fulltext_search.py:~1600) renders:
limit_clause = f"LIMIT {self._limit_value}" if self._limit_value else ""
offset_clause = f"OFFSET {self._offset_value}" if self._offset_value else ""Both use truthiness, not is not None — so limit(0) (a legitimate value, e.g. pagination dry-run, count-it-yourself, UI zero-page) is silently dropped and the query runs unbounded:
b = builder.limit(0)
print(b.explain())
# SELECT ... FROM t WHERE MATCH(...) ← no LIMIT at all; limit(0) expected "LIMIT 0"Verified min-repro of the exact conditional (pure python) plus the method itself (def limit(self, count): self._limit_value = count — stores 0, then build drops it).
Same builder, adjacent finding (recording in the same issue since the fix is the same function): the search mode used by this builder defaults to NATURAL_LANGUAGE while the ORM-facing FulltextFilter defaults to BOOLEAN for the same must()-style calls — two full-text front doors with different implicit semantics; plus _where_conditions are raw-joined strings (unescaped family, one more site for the unified escaping fix).
Reproduction
from matrixone.sqlalchemy_ext.fulltext_search import FulltextSearchBuilder
b = FulltextSearchBuilder(client).table("docs").columns("body").add_term("alpha").limit(0)
sql = b.explain() # or _build_sql()
assert "LIMIT" not in sql # ← passes; expected "LIMIT 0"Impact
limit(0)returning the entire corpus is a correctness inversion: the caller asked for zero rows as a safe/explicit contract (tests, previews, "is the query valid" probes) and gets potentially millions.- Divergence within the same SDK:
MatrixOneSQLBuildergets this right (if self._limit_count is not None), so the behavior depends on which builder an application touches — the classic copy-drift defect this SDK keeps producing (compare [Bug]: three batch-insert engines disagree on missing/extra row columns #31391's three batch-insert engines, [Bug]: AsyncRestoreManager in async_client.py duplicates the obsolete FROM SNAPSHOT SQL #31377's duplicated restore manager). - The mode-default divergence (natural vs boolean) makes identical must()-looking queries rank differently across entry points.
Expected behavior
Use is not None for both clauses (LIMIT/OFFSET), aligning with sql_builder.py's existing correct pattern; unify the default search mode across the two fulltext front doors (or document the difference loudly); include the raw _where_conditions join in the escaping-family fix. Regression: explain() for limit(0), limit(5), limit(None), offset(0) asserting exact clauses.
Activity
fix(python): unify SDK query and analytics lifecycle contracts (#31774)
XuPeng-SH commentedon Oct 30, 2026
QA handoff for merged #31774 (main
bbfe55669a1440424914d45a283a1d0e36f722fa): please verify the reported public SDK contract and its failure/recovery controls for FulltextSearchBuilder.limit(0) is silently dropped. This isolated QA run inspected the issue and merged PR but did not run tests or a live MatrixOne service at this SHA because the existing resource guard left insufficient headroom. The PR's author-reported validation is separate evidence, not a result of this QA run.Ariznawlll commentedon Oct 30, 2026
结论
测试不通过。
LIMIT 0已保留,但 issue 同时要求的显式OFFSET 0在FulltextSearchBuilder输出中仍被省略;该值被省略时通常不改变返回行,但不满足 issue 中明确提出的 SQL 构造契约。关键证据
XuPeng-SH;其合并提交是官方main@4ca0d77748c1e5fdd03486492fc3ca82c9045288的祖先。本次独立导入该完整 SHA 的 Python SDK 源码,Python 3.12,无需 MatrixOne 服务即可复现原 issue 的 builder 输出。FulltextSearchBuilder(...).table('docs').columns(['body']).add_term('alpha').limit(5).offset(0).explain()重复 3 次均只包含LIMIT 5,缺少预期的OFFSET 0;正常对照limit(0)包含LIMIT 0,limit(5).offset(1)包含LIMIT 5 OFFSET 1,3/3 一致。当前源码 的 offset 分支仍使用真值判断。main@43c6d84741d60838c28d2b93ab8ad4b6f922a678的隔离 1 CN / 1 TN / 1 LogService 上,实际全文索引的 LIMIT 0/1/5 返回行数符合预期,3/3;该旧版服务结果不代表当前 main 服务已验证。待解决点
OFFSET 0的显式输出契约;issue 还提及默认搜索模式和其他 WHERE 边界,本轮未完成这些场景的验证。fix(python-sdk): unify SQL, transaction and driver boundaries (#31889)
XuPeng-SH commentedon Oct 30, 2026
新修复转 QA:#31889 已合入 main,合并提交
91dfab2132c4c4fcd3f9a115dbfa968b196b8b14。所有相关分页入口均使用is not None保留显式OFFSET0;默认模式差异与调用方raw WHERE责任有文档,复用MATCH模式渲染。
已核对 issue 正文、完整评论及当前合并源码/测试内容。历史失败按其原 SHA 保留;新修复直接覆盖上述残留,未发现适用于新修复的已验证反例或尚未完成的开发 follow-up。本轮仅源码/测试内容静态核对,没有运行 MatrixOne 服务或 SDK 回归;作者在 PR 内的运行结果是作者证据,不是本轮独立测试。转 Ariznawlll 继续验证,不代表验收通过。
QA 待验范围:LIMIT0/5/None与OFFSET0/1精确SQL及真实行数、各入口默认搜索模式、raw WHERE边界。
Ariznawlll commentedon Oct 31, 2026
结论
测试通过。两种全文入口的默认模式不同,已在 SDK 文档中说明;raw WHERE 仍由调用方负责构造。
关键证据
main@4f894474ad10e1b9dc338868145a118a71c1fa23,修复 fix(python-sdk): unify SQL, transaction and driver boundaries #31889 在祖先链。LIMIT 0/5/None和OFFSET 0/1的 SQL 与实际返回行数,显式 0 均保留;LIMIT 0 返回 0 行,未限制的匹配返回 2 行,OFFSET 1 返回 1 行,各 3/3。测试表原有三行不变,每轮清理测试库。FulltextSearchBuilder默认 natural language、boolean_match默认 Boolean,以及调用方提供的id = 1raw WHERE 对实际结果的作用;差异和 raw WHERE 责任见 SDKdocs/async-analytics-and-execution.md及docs/design/sdk-quality-extensions-wave2.md。issue_31403_fulltext_pagination.py(提交a6119756);该 PR 尚未合入,完整 suite 未运行。待解决点