You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Compatibility]: JSON constructors serialize GEOMETRY as raw WKB strings instead of GeoJSON objects #28060
JSON_OBJECT, JSON_ARRAY, and JSON_SET convert a MatrixOne GEOMETRY value into a JSON string containing its raw WKB bytes. The same geometry is correctly converted to a GeoJSON object by CAST(geometry AS JSON), and MySQL 8 JSON constructors also produce a GeoJSON object. The constructor result is therefore not a usable JSON representation of the geometry.
Environment
Branch: main
Commit: 95d04586eb80864499d0fde27aeb912b463ae4cd
Deployment: local single-CN MatrixOne
Steps to reproduce
CREATETABLEt (id INTPRIMARY KEY, g GEOMETRY);
INSERT INTO t VALUES (1, ST_GeomFromText('POINT(1 2)'));
SELECT
JSON_TYPE(JSON_EXTRACT(JSON_OBJECT('g', g), '$.g')),
JSON_TYPE(JSON_EXTRACT(JSON_ARRAY(g), '$[0]')),
JSON_TYPE(JSON_EXTRACT(JSON_SET('{}', '$.g', g), '$.g')),
JSON_UNQUOTE(JSON_EXTRACT(CAST(g AS JSON), '$.type'))
FROM t;
Actual behavior
MatrixOne returns:
STRING | STRING | STRING | Point
The members constructed by JSON_OBJECT/JSON_ARRAY/JSON_SET contain raw WKB bytes. CAST(g AS JSON) in the same row returns a GeoJSON object with type Point.
MySQL 8 returns a nested GeoJSON object through JSON_OBJECT, for example:
JSON constructors should use the same GeoJSON conversion as CAST(geometry AS JSON), yielding a JSON object rather than a WKB string.
Stability and controls
Reproducer: 3/3 on MatrixOne main for JSON_OBJECT, JSON_ARRAY, and JSON_SET.
JSON_VALID reports the constructor document as valid because the WKB is stored as a JSON string; this does not make the representation semantically correct.
Passing control: explicit CAST(g AS JSON) returns an object whose type is Point.
MySQL 8 control: 3/3 JSON constructor results are GeoJSON objects for the same POINT(1 2) input.
Code analysis
pkg/sql/plan/function/func_builtin_json.go handles types.T_geometry by returning string(v.GetBytesAt(row)) to JSON creation. The explicit cast implementation instead invokes the geometry-to-GeoJSON conversion path. Reusing that conversion for constructors would avoid the raw WKB string.
Regression coverage
After a fix, add deterministic constructor coverage for POINT through JSON_OBJECT, JSON_ARRAY, and JSON_SET, alongside a CAST(geometry AS JSON) equivalence check.
changed the title [-][Bug]: JSON constructors serialize GEOMETRY as raw WKB strings instead of GeoJSON objects[/-][+][Compatibility]: JSON constructors serialize GEOMETRY as raw WKB strings instead of GeoJSON objects[/+]on Sep 3, 2026
Automation checkpoint: merged PR #28093 is being validated against current upstream/main 6d44c50. This issue remains open in phase/testing; no terminal tester PASS has been recorded in the current handoff. Please report complete version, environment, scoped scenario results, and terminal PASS/FAIL evidence before any closure decision.
Activity
[-][Bug]: JSON constructors serialize GEOMETRY as raw WKB strings instead of GeoJSON objects[/-][+][Compatibility]: JSON constructors serialize GEOMETRY as raw WKB strings instead of GeoJSON objects[/+]fix(json): unify constructor value conversion (#28093)
VioletQwQ-0 commentedon Sep 8, 2026
【QA 交接|PR #28093 已合并】
关联合并:PR #28093(merge commit 8836fb4);当前 main=1cfec4c80134adc5640a3bbf1aef7aaa87a45282。
本次范围:JSON_OBJECT、JSON_ARRAY、JSON_SET 对 GEOMETRY 的 WKB-to-GeoJSON 转换,非法 WKB 仍必须报错;同时覆盖列值、NULL、预编译和重绑定路径。
合并后证据:PR required checks 无失败;本地 exact-main CGo 自测因缺少 cgo/libmo.dylib 阻塞,mo-tester 未安装,未宣称本地 PASS。
请在合并版本连续复验合法/非法 WKB、不同 geometry subtype、常量与列值、单 CN 与多 CN、重启/读回以及生成列/索引消费。PASS 标准是 GeoJSON 结构和错误语义与 MySQL 8 一致;FAIL 时请保留 SQL、main SHA、重复轮次和实际/期望结果。
VioletQwQ-0 commentedon Sep 8, 2026
补充 pin:远端 main 已推进到 9f87b62。请以该当前 main 复验;此前列出的合并提交、测试范围和 PASS/FAIL 标准保持不变。该更新不代表 QA PASS。
VioletQwQ-0 commentedon Sep 8, 2026
再次补充 pin:远端 main 已推进到 9cedf6e。请以该当前 main 复验;此前列出的合并提交、测试范围和 PASS/FAIL 标准保持不变。该更新不代表 QA PASS。
VioletQwQ-0 commentedon Sep 8, 2026
Automation checkpoint: merged PR #28093 is being validated against current upstream/main 6d44c50. This issue remains open in phase/testing; no terminal tester PASS has been recorded in the current handoff. Please report complete version, environment, scoped scenario results, and terminal PASS/FAIL evidence before any closure decision.
Ariznawlll commentedon Sep 9, 2026
测试版本
maina9d3b8b857c44f1249e682c91d4d62a914eb7d20原问题验证
验证空间 Point 在 JSON constructor 中生成正确 GeoJSON object,并在不同容器内保持一致。
Happy Path 覆盖
Unhappy Path 覆盖
以 object、array、set 三条序列化入口与直接 cast 控制路径交叉验证,确认空间对象不会被降级为普通字符串或在嵌套容器中变形。
白盒验证
不适用:以 GeoJSON 外部输出和容器内容验收。
回归测试
suites/14_issue_regression/t/issue_28056_28057_28058_28060_json_constructor_types.test。--record --repeat 3和非 record--repeat 3均通过;PR 共 21/21 用例、321/321 条语句成功。测试证据
三种 JSON 容器和直接空间控制路径均重复 3 次。
测试结论
测试通过。
fix(json): unify constructor value conversion (matrixorigin#28093)
fix(json): unify constructor value conversion (matrixorigin#28093)
fix(json): unify constructor value conversion (matrixorigin#28093)