#27057Can't query on properties of child objects of the same class
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 ...