Project

General

Profile

Actions

Bug #27057

closed

Can't query on properties of child objects of the same class

Added by Björn Steinbrink over 13 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Must have
Category:
Extbase
Target version:
Start date:
2011-05-26
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Given a domain model that has a connection to another object of the same class like this:

class Tx_Whatever_Domain_Model_Foo {
  /**
   * @var Tx_Whatever_Domain_Model_Foo
   */
   protected $parent;
}

And given this repository method:

class Tx_Whatever_Domain_Repository_FooRepository {
  public findByParentTitle($title) {
    $query = $this->createQuery();
    return $query->matching($query->equals('parent.title', $title))->execute();
  }
}

Running $repository->findByParentTitle('test');, extbase generates invalid SQL and crashes.

An error occured. Exception thrown:
Tx_Extbase_Persistence_Storage_Exception_SqlError
Error message: Not unique table/alias: 'tx_whatever_domain_model_foo':

SELECT DISTINCT tx_whatever_domain_model_foo.*
FROM tx_whatever_domain_model_foo
LEFT JOIN tx_whatever_domain_model_foo ON tx_whatever_domain_model_foo.parent=tx_whatever_domain_model_foo.uid
WHERE tx_whatever_domain_model_foo.parent = 'test' AND ...


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #62151: addUnionStatement does not handle multiple fields with same related tableClosed2014-10-10

Actions
Related to TYPO3 Core - Bug #58511: addUnionStatement does not respect MM_match_fieldsClosed2014-05-05

Actions
Has duplicate TYPO3 Core - Feature #55959: Joins on SubClassesClosed2014-02-13

Actions
Actions

Also available in: Atom PDF