[PR #6475] Fix invalid sql generated for CTI JOINs when INNER JOIN'ing with a WITH clause #9993

Open
opened 2026-01-22 16:06:05 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/6475

State: closed
Merged: No


See #6464 for a detailed example of the problem.

For a query like

$qb
            ->select('p', 'a')
            ->from(GH6464Post::class, 'p')
            ->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id')
            ->getQuery();

... where GH6464Author is a CTI entity, the sql generation currently generates two JOINs (correct) and attaches both join conditions to the latter JOIN. This works with MySQL and SQLite, however fails on PostgreSQL.

This patch

  • adds a functional test case that actually tries to run such a query
  • applies a fix to SqlWalker that makes it output a nested JOIN
  • adapts test cases in SelectSqlGenerationTest to reflect the change (and make those SQL statements valid -- on PostgreSQL)
**Original Pull Request:** https://github.com/doctrine/orm/pull/6475 **State:** closed **Merged:** No --- See #6464 for a detailed example of the problem. For a query like ```php $qb ->select('p', 'a') ->from(GH6464Post::class, 'p') ->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id') ->getQuery(); ``` ... where `GH6464Author` is a CTI entity, the sql generation currently generates two JOINs (correct) and attaches both join conditions to the latter JOIN. This works with MySQL and SQLite, however fails on PostgreSQL. This patch * adds a functional test case that actually tries to run such a query * applies a fix to `SqlWalker` that makes it output a nested JOIN * adapts test cases in `SelectSqlGenerationTest` to reflect the change (and make those SQL statements valid -- on PostgreSQL)
admin added the pull-request label 2026-01-22 16:06:05 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9993