DDC-1529: Multiple FROM Entities and inheritance #1918

Closed
opened 2026-01-22 13:31:30 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 12, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user lutangar:

I got a single table inheritance on an object Content (Program, Article, etc...)

when try a simple :
{quote}
$query = $this->_em->createQuery('
SELECT a, p
FROM SG\CmsBundle\Entity\Article a, SG\ProgramBundle\Entity\Program p');
$query->getResult();
{quote}

The generated sql is :
{quote}
SELECT s0_.id AS id0, s0_.title AS title1, s0_.description AS description2, s0_.tags AS tags3, s0_.keywords AS keywords4, s0_.robots AS robots5, s0_.author_name AS author_name6, s0_.fb_description AS fb_description7, s0_.type AS type8, s0_.is_active AS is_active9, s0_.is_deleted AS is_deleted10, s0_.is_published AS is_published11, s0_.published_at AS published_at12, s0_.unpublished_at AS unpublished_at13, s0_.slug AS slug14, s0_.created_at AS created_at15, s0_.updated_at AS updated_at16, s0_.lft AS lft17, s0_.rgt AS rgt18, s0_.root AS root19, s0_.lvl AS lvl20, s1_.id AS id21, s1_.title AS title22, s1_.description AS description23, s1_.tags AS tags24, s1_.keywords AS keywords25, s1_.robots AS robots26, s1_.author_name AS author_name27, s1_.fb_description AS fb_description28, s1_.type AS type29, s1_.is_active AS is_active30, s1_.is_deleted AS is_deleted31, s1_.is_published AS is_published32, s1_.published_at AS published_at33, s1_.unpublished_at AS unpublished_at34, s1_.slug AS slug35, s1_.created_at AS created_at36, s1_.updated_at AS updated_at37, s1_.lft AS lft38, s1_.rgt AS rgt39, s1_.root AS root40, s1_.lvl AS lvl41, s0_.kind AS kind42, s0_.parent_id AS parent_id43, s0_.template_article_id AS template_article_id44, s0_.template_page_id AS template_page_id45, s0_.author_id AS author_id46, s1_.kind AS kind47, s1_.parent_id AS parent_id48, s1_.template_article_id AS template_article_id49, s1_.template_page_id AS template_page_id50, s1_.author_id AS author_id51 FROM sg_content s0_, sg_content s1_ WHERE (s0_.kind IN ('Article') AND AND s1_.kind IN ('Program'))
{quote}

The only problem is, we got an extra AND at the end of the query, the query should look smthin like this :
{quote}
SELECT ... WHERE (s0_.kind IN ('Article') AND s1_.kind IN ('Program'))
{quote}

Originally created by @doctrinebot on GitHub (Dec 12, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user lutangar: I got a single table inheritance on an object Content (Program, Article, etc...) when try a simple : {quote} $query = $this->_em->createQuery(' SELECT a, p FROM SG\CmsBundle\Entity\Article a, SG\ProgramBundle\Entity\Program p'); $query->getResult(); {quote} The generated sql is : {quote} SELECT s0_.id AS id0, s0_.title AS title1, s0_.description AS description2, s0_.tags AS tags3, s0_.keywords AS keywords4, s0_.robots AS robots5, s0_.author_name AS author_name6, s0_.fb_description AS fb_description7, s0_.type AS type8, s0_.is_active AS is_active9, s0_.is_deleted AS is_deleted10, s0_.is_published AS is_published11, s0_.published_at AS published_at12, s0_.unpublished_at AS unpublished_at13, s0_.slug AS slug14, s0_.created_at AS created_at15, s0_.updated_at AS updated_at16, s0_.lft AS lft17, s0_.rgt AS rgt18, s0_.root AS root19, s0_.lvl AS lvl20, s1_.id AS id21, s1_.title AS title22, s1_.description AS description23, s1_.tags AS tags24, s1_.keywords AS keywords25, s1_.robots AS robots26, s1_.author_name AS author_name27, s1_.fb_description AS fb_description28, s1_.type AS type29, s1_.is_active AS is_active30, s1_.is_deleted AS is_deleted31, s1_.is_published AS is_published32, s1_.published_at AS published_at33, s1_.unpublished_at AS unpublished_at34, s1_.slug AS slug35, s1_.created_at AS created_at36, s1_.updated_at AS updated_at37, s1_.lft AS lft38, s1_.rgt AS rgt39, s1_.root AS root40, s1_.lvl AS lvl41, s0_.kind AS kind42, s0_.parent_id AS parent_id43, s0_.template_article_id AS template_article_id44, s0_.template_page_id AS template_page_id45, s0_.author_id AS author_id46, s1_.kind AS kind47, s1_.parent_id AS parent_id48, s1_.template_article_id AS template_article_id49, s1_.template_page_id AS template_page_id50, s1_.author_id AS author_id51 FROM sg_content s0_, sg_content s1_ WHERE (s0_.kind IN ('Article') AND AND s1_.kind IN ('Program')) {quote} The only problem is, we got an extra AND at the end of the query, the query should look smthin like this : {quote} SELECT ... WHERE (s0_.kind IN ('Article') AND s1_.kind IN ('Program')) {quote}
admin added the Bug label 2026-01-22 13:31:32 +01:00
admin closed this issue 2026-01-22 13:31:35 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 19, 2012):

Comment created by @guilhermeblanco:

Invalid for 2.2. I couldn't track the exact commit this was fixed, so I'll keep fix version for 2.3.
Coverage commit reference: febfe35c23

@doctrinebot commented on GitHub (Jan 19, 2012): Comment created by @guilhermeblanco: Invalid for 2.2. I couldn't track the exact commit this was fixed, so I'll keep fix version for 2.3. Coverage commit reference: https://github.com/doctrine/doctrine2/commit/febfe35c2315a20534630aa9e5b9c72a0047f569
Author
Owner

@doctrinebot commented on GitHub (Jan 19, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jan 19, 2012): 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#1918