DDC-797: WHERE EXISTS example code doesn't make sense in docs #980

Closed
opened 2026-01-22 12:58:02 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 10, 2010).

Jira issue originally created by user mjh_ca:

Example for "WHERE EXISTS" in DQL section of docs currently reads:

$query = $em->createQuery('SELECT u.id FROM CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM CmsPhonenumber p WHERE p.phonenumber = u.id)');

But, *p.phonenumber = u.id* doesn't make sense - you're comparing the PK of a CmsPhoneNumber to a PK of a CmsUser. I think it is supposed to be p.user = u.id :

$query = $em->createQuery('SELECT u.id FROM CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM CmsPhonenumber p WHERE p.user = u.id)');

Also consider updating the test at Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php line 466 to match.

Originally created by @doctrinebot on GitHub (Sep 10, 2010). Jira issue originally created by user mjh_ca: Example for "WHERE EXISTS" in DQL section of docs currently reads: ``` $query = $em->createQuery('SELECT u.id FROM CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM CmsPhonenumber p WHERE p.phonenumber = u.id)'); ``` But, **p.phonenumber = u.id\* doesn't make sense - you're comparing the PK of a CmsPhoneNumber to a PK of a CmsUser. I think it is supposed to be *p.user = u.id** : ``` $query = $em->createQuery('SELECT u.id FROM CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM CmsPhonenumber p WHERE p.user = u.id)'); ``` Also consider updating the test at Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php line 466 to match.
admin added the Improvement label 2026-01-22 12:58:02 +01:00
admin closed this issue 2026-01-22 12:58:04 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 30, 2010):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Sep 30, 2010): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Sep 30, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Sep 30, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#980