Repository navigation
Description
由 LW 授权的 ChatGPT Personal 智能体提交。
Is there an existing issue for the same bug?
- Searched open and closed issues/PRs for build_select_query, zero limit and Python limit=0. Server-side prepared/recursive LIMIT fixes concern different owners; no matching SDK convenience-function fix was found.
Branch Name
main (no exact upstream dev exists; main fallback is explicitly authorized).
Commit ID
Other Environment Information
Python 3.12.14, SQLAlchemy 1.4.54; deterministic native SQLite DBAPI execution of SQL generated by the actual public SDK builder. No production service/data was accessed.
Actual Behavior
build_select_query(table_name="t", limit=0) omits LIMIT entirely because its convenience wrapper tests truthiness. The underlying MatrixOneSQLBuilder.limit(0).build() correctly keeps LIMIT 0. A caller requesting no rows therefore receives an unrestricted query, potentially fetching the entire matching dataset.
Expected Behavior
Only None omits the LIMIT clause. Explicit zero must generate LIMIT 0, returning an empty result. Positive limits and both parameter-substitution/binding modes must keep their existing behavior.
Steps to Reproduce
Create a disposable SQLite table with IDs 1,2,3. Build a SELECT of id with WHERE id >= ? (parameter 2), ORDER BY id and limit=0; execute the generated SQL through native DBAPI in each parameter mode. Actual result is [(2,), (3,)], expected [].
The committed-candidate regression covers None/0/1/5 in both modes. Against original production: 2 failed / 6 passed; fixed owning file: 38 passed. Full SDK offline: 1268 passed +86 subtests. Independent reviewer reproduced both original failures and fixed results and explicitly Approved the complete two-file delta.
Additional information
Candidate scope: 2 files, +26/-1. The one-line guard restores the existing builder contract; no server, dependency, schema, API signature or generated source change. This is SQL generation validation, not live MatrixOne or full hosted CI certification. Packaging/hosted checks are recorded separately when complete.
Authenticated subject MatrixAdventurer and its own fork MatrixAdventurer/matrixone (parent matrixorigin/matrixone, push permission) were freshly verified. Planned fork feature branch: fix/python-select-zero-limit-20261022. Branch/commit/PR operations and read-only verification are by the signed execution subject; no upstream/default branch push, automatic merge, deployment or issue closure.
由 LW 授权的 ChatGPT Personal 智能体提交。
Activity
fix(python-sdk): preserve explicit zero SELECT limits (#30825)
Ariznawlll commentedon Oct 22, 2026
测试版本
3ad9adbb4ce6c9f8e421917233cc6f6d40ab5f25。测试前及结束核对官方 main 相同;隔离 checkout 无源码修改,并验证实际导入 sql_builder.py 来自该 checkout。b90e839af241184d14ac819ddc894e9dee097262已验证在上述 main 祖先链。不是对未合入候选进行验收。原问题验证
使用实际公开 API build_select_query,建三行 id=1/2/3,WHERE id >= ? 绑定2,ORDER BY id,在参数替换及保留绑定两种模式下执行生成 SQL。limit=None 返回2/3,limit=0 明确生成 LIMIT 0 且返回空集,limit=1 返回2,limit=2/5 返回2/3。
扩展矩阵在两个解释器上各3/3通过;正常 MOTR runner 另重复3次,最终 total=3 / success=3 / failed=0 / skipped=0,2.12s。不是仅检查生成字符串。
读取修复提交父版本的真实 sql_builder.py(不改工作树)执行同一 oracle,被拒绝;两个旧 zero-limit 模式均遗漏 LIMIT,而旧底层 MatrixOneSQLBuilder.limit(0) 控制保留 LIMIT 0。该对照明确区分修复前缺陷与本次修复结果,不作为修复失败。
Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
读取一行 None 判断修复及已有执行型回归。已有 owning file
clients/python/tests/offline/test_vector_operations.py每轮38项,连续3轮全通过。最新 main 的整个 SDK offline suite 实跑 1272 passed、86 subtests passed,2条既有 deprecation warning,2.76s;未以研发此前的1268计数代替本次执行。Go/race 不适用:本项是顺序执行、无后台任务或共享状态的 Python SQL 生成路径,没有服务器代码变更。没有新增 MO PR。
回归测试
新增独立 MOTR PR #260,head
859586ea4a0caa3ec7d37ae55b330fbce7bab82d,基于官方 MOTR main13a6aad987e93be1883daa54f08a63d4cc5fe5a2,未追加 #247。当前 OPEN/draft,未声称已合入。固定版本 SDK 场景 包含确定性 out 与配置文档;4项新增 oracle 测试拒绝旧版遗漏 LIMIT 0 和错误正数截断。MOTR 全量离线框架 432项通过,28.908s;这不是432项在线产品验收。完整14_issue_regression产品suite、在线MO/集成suite未执行。
独立查询 修复 PR CI 39750941783 的 job/step:6个 Python/SQLAlchemy offline job及CI Required成功,online跳过。该CI属于候选head
e46e614dd1ac84c0aa0384395c434b7dc1aaa9e5,不是最新main或新MOTR分支CI。本次 MOTR CI 39799016339 检查时 queued,尚无通过结论;未手动触发昂贵CI。测试证据
本地目录
/tmp/mo-sdk-30824-4VhA8o/:verify.log、sdk-owning-3.log、sdk-offline.log、motr-final.log、motr-offline.log,及上述固定版本回归代码。日志未冒充已上传artifact。结论仅覆盖上述 main SDK 原问题及列明边界,不代表4.2发布线、在线MO或完整集成CI。测试结论
测试通过。