Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked open and closed issues.
Searched for Python SDK / ORM / legacy Query / Query.execute / _execute / AttributeError, and inspected related reports. #30960 concerns modern query count/first semantics and async build state; #31210 concerns string-table result construction; #31195 concerns DML ORDER BY/LIMIT preservation. None reports this documented legacy class's missing execution delegate or its model-name incompatibility. The corresponding _execute PR search also found no matching report/fix.
Branch Name
main
Commit ID
861a2c4cb68961d8b6b01f18e0aa6ac52a3a505f
Also reproduced on the previous frozen main 83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3 and the published PyPI matrixone-python-sdk==0.1.16 wheel, not only an editable source checkout.
Other Environment Information
- Linux; Python 3.11.2.
- Current-main reproduction with SQLAlchemy 1.4.54 and 2.0.55; published-wheel reproduction with 2.0.55.
- The wheel was downloaded directly from
https://pypi.org/simple, without modifying it:matrixone_python_sdk-0.1.16-py3-none-any.whl, SHA2568a9b82bad22ce5940449614757c505f61c1a4b88a3df5e78137a3386566cb8d6. - No MatrixOne server is needed to reproduce these Python exceptions: they occur before calling
Client.execute. Behavioral controls used a real SQLite in-memory executor attached at the public client execution boundary, with actual row-state assertions.
Actual Behavior
The publicly exported and documented legacy matrixone.orm.Query cannot execute when directly constructed:
- With an ordinary SQLAlchemy mapped model, the legacy SQL builders read
model_class._table_nameand raiseAttributeError: type object 'Record' has no attribute '_table_name'. They do not resolve the standard__tablename__despite the class documenting SQLAlchemy-model support. - Supplying the legacy model-name alias allows SQL generation to complete, but every tested execution path then raises
AttributeError: 'Query' object has no attribute '_execute'.Querydoes not define this method and inherits only fromobject. The method on the separateBaseMatrixOneQueryclass cannot serve as its delegate.
This is an application-visible failure for callers importing and directly using Query. It is not a failure of the normal Client.query() factory, which returns MatrixOneQuery; that class inherits the valid execution delegate.
Observed results on current main and the published wheel:
| Direct legacy operation, with the model-name alias supplied | Result | Backend calls |
|---|---|---|
all() |
missing _execute AttributeError |
0 |
first() |
same | 0 |
count() |
same | 0 |
SELECT execute() |
same | 0 |
insert(...).execute() |
same | 0 |
update(...).execute() |
same | 0 |
delete() |
same | 0 |
The synthetic table remains unchanged after every failing call. This report demonstrates a deterministic client API failure; it does not claim a production incident or data corruption.
Expected Behavior
The retained public Query(model, client) API should resolve its advertised model types and dispatch SQL through the supplied client. Labeling the class “legacy” and recommending a newer class does not make its documented constructor an abstract or unsupported API.
If retaining direct legacy construction is no longer intended, the supported API contract, exports, documentation and migration behavior need an explicit decision rather than an internal AttributeError during execution.
Steps to Reproduce
In a clean environment:
python -m pip install matrixone-python-sdk==0.1.16 SQLAlchemy==2.0.55Run the following without a server. An unconnected real Client is sufficient because neither failure reaches connection validation or SQL dispatch:
from matrixone import Client
from matrixone.orm import Query
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import declarative_base
Base = declarative_base()
class Record(Base):
__tablename__ = "sdk_legacy_records"
id = Column(Integer, primary_key=True)
value = Column(String(32))
client = Client()
def probe(label, action):
try:
action()
except Exception as exc:
print(label, type(exc).__name__, str(exc))
probe("normal mapped model", lambda: Query(Record, client).all())
# Supply only the table-name convention required by the legacy SQL builder.
# This does not monkeypatch Query or add its missing execution method.
Record._table_name = Record.__tablename__
probe("SELECT", lambda: Query(Record, client).all())
probe("UPDATE", lambda: Query(Record, client).filter("id = ?", 1)
.update(value="updated").execute())
probe("DELETE", lambda: Query(Record, client).filter("id = ?", 1).delete())Actual output:
normal mapped model AttributeError type object 'Record' has no attribute '_table_name'
SELECT AttributeError 'Query' object has no attribute '_execute'
UPDATE AttributeError 'Query' object has no attribute '_execute'
DELETE AttributeError 'Query' object has no attribute '_execute'
A connected client encounters the same attribute lookup before its execute method can run.
Additional information
Why this is a reachable API defect
matrixone.orm.__all__explicitly exportsQuery.- The ORM API reference documents
matrixone.orm.Queryand its members. class Queryhas a public constructor and execution methods, is not an abstract base class, and describes itself as legacy with a recommendation to useMatrixOneQueryfor new code.- Its
all(),delete()andexecute()call the undefined delegate. - The real
BaseMatrixOneQuery._executebelongs to a separate inheritance tree.
Controls and test gap
- Against the same in-memory table,
Client.query(Record)read/update/delete controls dispatch and produce the expected results/row changes. The INSERT positive control uses rawClient.execute; the modern query class does not expose the legacy.insert()method, so the two builders should not be treated as interchangeable for every operation. - A diagnostic local subclass supplying only
_execute -> self.client.executemakes all seven legacy operations dispatch successfully when the model-name alias is present. This isolates the missing delegate; it is not a product patch or a workaround that fixes ordinary model-name resolution. - Independently tested ordinary mapped models without that alias: five legacy read/DML cases fail on
_table_namebefore dispatch, while theClient.query(model).all()control succeeds. - The existing
test_query_update.pyimportsBaseMatrixOneQueryandMatrixOneQuery, not legacyQuery. Its mocks therefore do not test direct legacy construction. No direct legacyQuery(...)regression coverage was found in the current SDK tests/examples.
Regression coverage should instantiate the exported legacy class directly, cover standard mapped models as well as the legacy table-name convention, and observe the client's execution callback without injecting Query._execute into the object under test.
Customer workaround
Use client.query(Model) / MatrixOneQuery for supported read/update/delete operations. For insertion, use a supported client API such as Client.execute(...); do not assume the modern builder has legacy Query.insert().
Activity
fix(python-sdk): unify query contracts and atomic manager operations (#…
XuPeng-SH commentedon Oct 26, 2026
Local SDK QA (2026-10-26): SDK source
28e8760905a7f39dba2ce436357ea75492f30512; isolated MatrixOne service binary83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3(SHA-2566bebe05311ae6438967a824641e3849fbbc9af298003177351794601edf14b4b). Passedtests/online/test_sdk_quality_contracts.py::test_legacy_query_native_executionand offline direct-legacy-query contracts. DirectQuery(model, client)callers executedcount, filter/first,all, and mapped physical-name/projection paths with exact row values; connection reuse succeeded.Ariznawlll commentedon Oct 27, 2026
测试版本
420786e21566e5b9d5875e7d6a7f3102fd0761af;修复 PR fix(python-sdk): unify query contracts and atomic manager operations #31262 已 MERGED,merge commit28e8760905a7f39dba2ce436357ea75492f30512已核实在该 main 祖先链。8bd0f1f4c60cd0590c68cdbb2cbca31fc9d39d071ec367ab56d5c49b4eec327e。原问题验证
直接构造文档中的
Query(model, client)而非只经client.query():count()为 3,filter(id=1).first().label='red';插入 id4、更新 v=9、读回、删除后 count 恢复 3。另用 Python 属性与物理列名不同的映射,按真实 id 查询得到 display=red。原先直接调用不能执行的路径连续 3 轮通过。Happy Path 覆盖
select('label','id')投影映射到(display,key)=('red',1),确认列映射和返回值正确。Unhappy Path 覆盖
白盒验证
核对已合入回归的 SDK 公开入口、SQL/返回值断言和修复后实际服务结果;未修改产品源码,未运行全量 SDK suite 或 race。
回归测试
#31262 已包含
clients/python/tests/online/test_sdk_quality_contracts.py::test_legacy_query_native_execution。Python SDK API 行为无法由纯 SQL MOTR 代替,未新增 MO 或 MOTR PR。#31262 六个离线 SDK CI job 成功;在线 CI SKIPPED,在线结果采用本地实测。测试证据
本地 JUnit:
/private/tmp/mo-six-qa-20261026/qa-night/sdk-contract-round-{1,2,3}.xml(每轮 tests=70、失败/错误/跳过均 0)及sdk-offline-round-{1,2,3}.xml(每轮 112、失败/错误/跳过均 0)。修复 PR:#31262 。测试结论
测试通过。