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
Prisma's JOIN-based relation loading (preview feature relationJoins, relationLoadStrategy: 'join') builds nested derived tables that wrap rows with JSON_OBJECT(...) and aggregate them with JSON_ARRAYAGG(...) / CAST(... AS JSON). These queries fail on MatrixOne.
3.0.11: not supported: function or operator 'json_object' (and 'json_arrayagg').
4.0-dev (nightly-0bfda604): the building blocks all work standalone — JSON_OBJECT(...), JSON_ARRAYAGG(...), CAST('[]' AS JSON), COALESCE(JSON_ARRAYAGG(...), CAST('[]' AS JSON)) — but the full nested query still fails with a parser error near " JSON))". To-one relation loads work on 4.0-dev; to-many fail.
Generated SQL that fails (4.0-dev, to-many author → posts, trimmed)
Revalidated on 2026-08-03 with the current Prisma/MySQL path. The old sample containing an OUTER JOIN without ON/USING is invalid SQL and is not evidence for this issue.
Schema/data: Author(1, Ada) has two posts; Author(2, Grace) has none
Prisma's current documentation still describes the MySQL join strategy as a single database query using correlated subqueries and database-side JSON aggregation:
Prisma relationLoadStrategy: "query": PASS on MySQL and MatrixOne.
Prisma to-one relationLoadStrategy: "join": PASS on MySQL and MatrixOne.
Non-correlated nested JSON_OBJECT / JSON_ARRAYAGG: PASS on MatrixOne.
A simplified correlated JSON aggregate without a derived-table wrapper executes on MatrixOne for matching rows.
A derived table that references the outer row fails even with COUNT(*) and no JSON functions.
This isolates the current blocker to the planner's explicit rejection of a correlated derived table (pkg/sql/plan/query_builder.go, subCtx.isCorrelated -> NewNYI("correlated subquery in FROM clause")), not to the parser and not to the JSON functions.
There is one serial prerequisite. On current main, a simplified empty correlated aggregate still evaluates COALESCE(JSON_ARRAYAGG(...), '[]') as NULL instead of []. #25959 / draft PR #26510 (cd7396c368f61eff48dcaa1ef29d88e0dc7959ff, fresh CI currently running) addresses that independent empty-input semantic. Without it, removing the derived-table blocker alone would still produce an incorrect empty relation.
Add planner tests for supported and deliberately rejected shapes, plus a production BVT containing the complete Prisma SQL and present/empty/all-NULL relation cases.
Run real Prisma 7.9.1 E2E against MySQL 8 and the MatrixOne PR head, preserving to-one join and query strategy controls.
So the issue is confirmed on current Prisma and current MatrixOne main, but its valid current failure is correlated-derived-table planning rather than the historical invalid OUTER JOIN sample.
QA handoff for merged PR #26672.\n\n- PR head: 52f59dd\n- Merge commit: 224ec27\n- Main at handoff: f670446\n- Automated evidence: exact-head CI passed Ubuntu UT, SCA, coverage, Proxy Compose BVT, and pessimistic launch BVT. The merged PR also added the Prisma correlated-derived-table production BVT and planner coverage.\n\nRemaining QA: run Prisma Client and @prisma/adapter-mariadb 7.9.1 relationLoadStrategy: join against a deployed MatrixOne build containing the merge, using the documented to-many 0/1/many cases and controls for to-one join and relationLoadStrategy: query. Confirm the valid correlated-derived query returns the expected JSON relations without the former 20102 error.\n\nExpected PASS: the terminal Prisma to-many join results match MySQL for 0/1/many relations. On FAIL, include MatrixOne version/build, environment, exact query or fixture, terminal error/result, and logs or statement evidence. Keep this issue open until explicit tester PASS.
Activity
add BVT test for RIGHT JOIN without ON/USING (issue matrixorigin#24737)
fengttt commentedon Jul 8, 2026
MySQL also requires outer join to have an ON/USING clause. This is just a bad SQL.
4 remaining items
VioletQwQ-0 commentedon Aug 3, 2026
Revalidated on 2026-08-03 with the current Prisma/MySQL path. The old sample containing an
OUTER JOINwithoutON/USINGis invalid SQL and is not evidence for this issue.Current reproduction manifest
@prisma/adapter-mariadb:7.9.1(npm dist-tag latest=7.9.1)24.18.18.0.46main:d29b4758f88f0894feeca15f31412446c17cb9d3Author(1, Ada)has two posts;Author(2, Grace)has nonePrisma's current documentation still describes the MySQL
joinstrategy as a single database query using correlated subqueries and database-side JSON aggregation:The real Prisma 7.9.1 to-many request was:
It generated this valid MySQL SQL (formatted only; no
OUTER JOINis present):A/B result
MySQL 8.0.46: PASS
[ {"id":1,"name":"Ada","posts":[{"id":10,"title":"First","authorId":1},{"id":11,"title":"Second","authorId":1}]}, {"id":2,"name":"Grace","posts":[]} ]MatrixOne
d29b4758f: FAILMatrixOne's
system.statement_infocaptured the same prepared Prisma SQL as failed:Controls on the same exact heads:
relationLoadStrategy: "query": PASS on MySQL and MatrixOne.relationLoadStrategy: "join": PASS on MySQL and MatrixOne.JSON_OBJECT/JSON_ARRAYAGG: PASS on MatrixOne.COUNT(*)and no JSON functions.This isolates the current blocker to the planner's explicit rejection of a correlated derived table (
pkg/sql/plan/query_builder.go,subCtx.isCorrelated->NewNYI("correlated subquery in FROM clause")), not to the parser and not to the JSON functions.There is one serial prerequisite. On current
main, a simplified empty correlated aggregate still evaluatesCOALESCE(JSON_ARRAYAGG(...), '[]')asNULLinstead of[]. #25959 / draft PR #26510 (cd7396c368f61eff48dcaa1ef29d88e0dc7959ff, fresh CI currently running) addresses that independent empty-input semantic. Without it, removing the derived-table blocker alone would still produce an incorrect empty relation.Proposed repair sequence
LATERALsupport; the general capability remains tracked by Feature Not Supported: Correlated subquery in FROM clause not yet implemented #23084 / [Bug]: LATERAL and derived-table outer references are not supported like MySQL #25376.joinandquerystrategy controls.joinPASS evidence.So the issue is confirmed on current Prisma and current MatrixOne
main, but its valid current failure is correlated-derived-table planning rather than the historical invalidOUTER JOINsample.fix(plan): preserve empty correlated aggregate projections (#26510)
VioletQwQ-0 commentedon Aug 4, 2026
QA handoff for merged PR #26672.\n\n- PR head: 52f59dd\n- Merge commit: 224ec27\n- Main at handoff: f670446\n- Automated evidence: exact-head CI passed Ubuntu UT, SCA, coverage, Proxy Compose BVT, and pessimistic launch BVT. The merged PR also added the Prisma correlated-derived-table production BVT and planner coverage.\n\nRemaining QA: run Prisma Client and @prisma/adapter-mariadb 7.9.1 relationLoadStrategy: join against a deployed MatrixOne build containing the merge, using the documented to-many 0/1/many cases and controls for to-one join and relationLoadStrategy: query. Confirm the valid correlated-derived query returns the expected JSON relations without the former 20102 error.\n\nExpected PASS: the terminal Prisma to-many join results match MySQL for 0/1/many relations. On FAIL, include MatrixOne version/build, environment, exact query or fixture, terminal error/result, and logs or statement evidence. Keep this issue open until explicit tester PASS.
Ariznawlll commentedon Aug 10, 2026
测试版本
main3c7392a0f86b23712da71f31d7a9198a2c8591a9relationLoadStrategy: 'join'的相关派生表 SQL 验证;测试日期:2026-08-10。原问题验证
关系 join 查询连续执行 3 次,均成功返回作者及 posts JSON,不再出现 relation-join 查询失败。
Happy Path 覆盖
title IS NULL,验证 JSON NULL 保留。Unhappy Path 覆盖
[],不是 NULL 或缺失父行。白盒验证
不适用:使用 Prisma 形状的公共 SQL 黑盒验证。
回归测试
已加入 motr PR #89 的
suites/14_issue_regression/t/issue_24737_prisma_relation_join.test(commita6a50dfcf7053027dab5e9117fde7bdd7b5cdefb)。测试证据
MOTR 连续 3 轮:关联 5 个场景合计 15/15 成功、171 条断言成功。
测试结论
测试通过。
fix(parser): report missing outer join conditions (matrixorigin#25880)
fix(plan): preserve empty correlated aggregate projections (matrixori…
fix(parser): report missing outer join conditions (matrixorigin#25880)
fix(plan): preserve empty correlated aggregate projections (matrixori…
fix(parser): report missing outer join conditions (matrixorigin#25880)
fix(plan): preserve empty correlated aggregate projections (matrixori…