Repository navigation
Description
Description
The MatrixOne Python SDK's SQLAlchemy dialect silently compiles mysql.BIGINT(unsigned=True) as signed BIGINT. Tables created through the SDK therefore reject legal unsigned values above 2^63-1, although native MatrixOne SQL and MySQL accept them. The requested type and actual schema disagree without a DDL error.
Environment
- MatrixOne
main5fe08a3307e246e1ab9951ab690b50557af0f509; isolated SQL service reports8.0.30-MatrixOne-v1.3.0. - Python SDK
0.1.16at that source revision; Python3.11.14, SQLAlchemy2.0.55, PyMySQL1.2.3. - Independent control: MySQL
8.3.0.
Steps to Reproduce
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from matrixone import Client
client = Client(sql_log_mode="off")
client.connect(host="127.0.0.1", port=36601,
database="qa_sdk_types_20261026", ssl_mode="disabled", on_connect=[])
table = sa.Table("sdk_unsigned_repro", sa.MetaData(),
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("u", mysql.BIGINT(unsigned=True)))
print(sa.schema.CreateTable(table).compile(dialect=client._engine.dialect))
with client._engine.begin() as conn:
table.create(conn)
client.execute("INSERT INTO sdk_unsigned_repro VALUES (1,9223372036854775808)")Actual Behavior
- SDK DDL prints
u BIGINT;information_schema.columns.COLUMN_TYPEisbigint. Inserting9223372036854775808rejects with1690 data out of range: data type int64.
Expected Behavior
- Standard SQLAlchemy MySQL dialect prints
u BIGINT UNSIGNED. - Native MatrixOne
CREATE TABLE ... u BIGINT UNSIGNEDhasCOLUMN_TYPE='bigint unsigned'and reads back9223372036854775808exactly. MySQL 8.3 preserves the same value.
Stability and Unhappy Path
- 3/3 independent fresh SDK/native table pairs reproduce the metadata and boundary discrepancy.
- A signed-range insert
(id=2,u=7)succeeds in the SDK-created table. A duplicate-key insert(id=2,u=8)is rejected without modifying that row; subsequentSELECT 1succeeds, and SDK pool checked-out count returns to zero. - The rejected
2^63insert leaves the SDK-created table empty until the normal control insert. This is a schema-generation failure, not a failed-INSERT atomicity bug.
Evidence
Self-checking 3/3 probe with exact DDL, metadata, error, row and pool output: /private/tmp/mo-sdk-types-20261026/unsigned_bigint_3x.py. Search of MatrixOne open/closed issues for Python SDK unsigned and SQLAlchemy BIGINT UNSIGNED found no matching bug; mysql-compatibility-contract/README.md does not document a Python SDK unsigned limitation.
Code Analysis
clients/python/matrixone/sqlalchemy_ext/dialect.py:282-284 defines MatrixOneTypeCompiler.visit_BIGINT to return constant "BIGINT", ignoring type_.unsigned (SQLAlchemy 2.0 path). Do not infer DECIMAL UNSIGNED correctness from this case: native MO currently accepts negative values for that spelling in this isolated build, so this report is deliberately limited to BIGINT.
Regression
Add an SDK online test constructing mysql.BIGINT(unsigned=True), asserting generated DDL and COLUMN_TYPE='bigint unsigned', then inserting/reading 9223372036854775808 exactly. Include signed BIGINT as a negative-range control and a failed duplicate write followed by connection reuse. Existing clients/python/tests/online/test_sqlalchemy_bool_reflection.py checks that reflection retains type.unsigned but does not assert that SDK-generated DDL preserves the unsigned modifier.
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_type_metadata_and_values: SQLAlchemyBIGINT(unsigned=True)DDL reported unsigned in information_schema and round-tripped2**64-1exactly. A rejected incomplete insert preserved the existing row;SELECT 1succeeded afterward. This is focused live SDK DDL/value evidence.Ariznawlll commentedon Oct 26, 2026
测试版本
main;完整 commit:59bad9e8aea4314af30fd25ce53267df5140c8fa。修复 PR #31262 已 MERGED,merge commit28e8760905a7f39dba2ce436357ea75492f30512已核实在此 main 祖先链。mo-serviceSHA-256af1930d6b0fd6d387be01d55635a0ea5dc5f225440234ff942cddebb511078b2,SQL 端口 47011,git_version()=59bad9e8ae;Python 3.12、SQLAlchemy 2.0.55、PyMySQL 1.2.3。测试日期:2026-10-27。原问题验证
3 个全新数据库分别用 SDK SQLAlchemy
mysql.BIGINT(unsigned=True)建表,并用原生 SQLBIGINT UNSIGNED建对照表。两表SHOW CREATE TABLE均含bigint unsigned,information_schema.columns.COLUMN_TYPE='bigint unsigned';插入/读回原失败边界9223372036854775808(2^63)均为该精确整数,3/3。SDK 不再悄然创建 signed BIGINT。Happy Path 覆盖
18446744073709551615(2^64−1)及普通正数 7,值/类型一致,3/3。test_type_metadata_and_values独立重跑 3/3;当前 main 的 SDK 在线质量合同文件 17 项通过(SQLAlchemy 2.0.55;2.1.6 也 17 项通过)。Unhappy Path 覆盖
id=2再次插入,3/3 均返回 1062;原三行的2^63、2^64−1、7 未改变,随后SELECT 1正常。白盒验证
本问题属于 SDK 生成 SQL DDL 的公开客户端路径,并非 Go 内部竞态;未运行 Go UT/race。通过实际 DDL、元数据和两个越过 signed 上界的读回值交叉验证。
回归测试
复用已合入 PR #31262 的 SDK 在线
test_type_metadata_and_values。本轮未新增 MO PR 或 MOTR #278 用例:纯 SQL 无法证明 SDK 是否保留unsigned=True。PR 的 Python SDK offline 6 个矩阵任务及 CI Required 成功;online CI 被路由跳过,已在隔离服务补测。未运行完整 MatrixOne BVT/MOTR/CI。测试证据
/private/tmp/mo-six-qa-20261026/qa-night/probe_31203_31205.py,3/3 输出含两种边界整数、bigint unsigned、1062 和CLEANED。测试结论
测试通过。
Ariznawlll commentedon Oct 29, 2026
结论
测试不通过。原 issue 的 SQLAlchemy unsigned 之外,简化
Client.create_table(..., {'v':'bigint unsigned'})仍创建 signed BIGINT,建议同一修复验收一并覆盖此入口,不另提重复 issue。关键证据
main@c6683bd2f531dcaa80e153c0924dac619c49dc9d,SDK 同提交;本地隔离 1 LogService / 1 TN / 1 CN,git_version()=c6683bd2f5。information_schema.columns.COLUMN_TYPE为bigint,插入9223372036854775808报1690data type int64,表仍为空:CREATE TABLE native_uint(id INT PRIMARY KEY,v BIGINT UNSIGNED)正常插入并精确读回9223372036854775808;错误后SELECT 1正常。3/3。Client.create_table()把'bigint'与'bigint unsigned'合并调用add_bigint_column(),后者构造不带 unsigned 的BigInteger。这次不是先前 dialectvisit_BIGINT的同一函数,但属于原报告中声明 unsigned 未保留的同一用户可见验收边界。待解决点
2^63边界和拒绝后的完整行集;本次没有重新打开 issue 或修改标签。