Skip to content

fix(parser): allow LEFT/RIGHT/FULL JOIN without ON/USING clause - #24772

Closed
ULookup wants to merge 9 commits into
matrixorigin:mainfrom
ULookup:fix/issue-24737-prisma-relation-joins
Closed

ULookup wants to merge 9 commits into
matrixorigin:mainfrom
ULookup:fix/issue-24737-prisma-relation-joins

Conversation

@ULookup

@ULookup ULookup commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24737

What this PR does / why we need it:

Fixes a SQL parser bug where LEFT/RIGHT/FULL JOIN without ON/USING clause fails to parse when followed by WHERE or other clauses. The fix changes the outer_join grammar production from mandatory join_condition to optional join_condition_opt, matching the behavior already used for INNER JOIN.

This unblocks Prisma ORM's relationLoadStrategy: 'join' preview featur for to-many relations, which generates LEFT JOIN without ON and uses the outer WHERE for filtering.

Change `join_condition` to `join_condition_opt` in the outer_join grammar
production so LEFT/RIGHT/FULL JOIN works without an explicit ON/USING
clause, matching INNER JOIN behavior and MySQL compatibility.

Fixes matrixorigin#24737
@ULookup
ULookup requested a review from iamlinjunhong as a code owner June 2, 2026 06:29
@ULookup
ULookup requested a review from a user June 2, 2026 06:29
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

LEFT JOIN without ON was already covered; add RIGHT JOIN variant
to verify all outer join types parse correctly without ON/USING.
@aunjgr

aunjgr commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

行为需要再判断一下,我先加个WIP

@fengttt fengttt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JOIN without ON/USING should be a cross product.

OUTER JOIN should require ON/USING clause, as per MySQL document. https://dev.mysql.com/doc/refman/9.7/en/join.html

So please revert the left/right/full outer join cases. Should raise an error, with a good error message (outer join requires ON/USING clause)

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator

Superseded by merged PR #25880. The final takeover keeps ON/USING mandatory for LEFT/RIGHT/FULL OUTER JOIN and returns an explicit parser error, while preserving valid conditionless inner/cross join forms.

This branch was successfully deployed

No deployments
ci — 458166f4 Deployed Jul 20, 2026 by VioletQwQ-0 via Matrixone Utils CI / Coverage #41440
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/wip kind/bug Something isn't working size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Prisma relationJoins (relationLoadStrategy:'join') queries fail (v3.0.11 & 4.0-dev)

5 participants