Bug #27057
closedCan'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.
100%
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 ...
Updated by Alexander Schnitzler about 12 years ago
- Status changed from New to Accepted
- Assignee set to Alexander Schnitzler
- Target version set to 1843
Can be reproduced, try to fix this.
Updated by Gerrit Code Review about 12 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16535
Updated by Gerrit Code Review about 12 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16535
Updated by Gerrit Code Review about 12 years ago
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16537
Updated by Alexander Schnitzler about 12 years ago
- Target version changed from 1843 to Extbase 6.0
Updated by Anonymous about 12 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset commit:36203cc17d46ac07088ddd17f21440c00a46a969.
Updated by Mathias Brodala over 11 years ago
This error still appears in the current stable release (6.1.1) with this simple setup:
Domain model
namespace TEST\RelationQueryTest\Domain\Model; class Element extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { /** * @var \string * @validate NotEmpty */ protected $title; /** * @var \TEST\RelationQueryTest\Domain\Model\Element */ protected $relatedElement; /* getters/setters ommitted */ }
Domain repository
namespace TEST\RelationQueryTest\Domain\Repository; class ElementRepository extends \TYPO3\CMS\Extbase\Persistence\Repository { /** * @param \string $title * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array */ public function findByRelatedElementTitle($title) { $query = $this->createQuery(); return $query->matching($query->equals('relatedElement.title', $title))->execute(); } }
TCA configuration
$TCA['tx_relationquerytest_domain_model_element'] = array( /* ctrl, interface, types omitted */ 'columns' => array( 'title' => array( 'exclude' => 0, 'label' => 'Title', 'config' => array( 'type' => 'input', 'size' => 30, 'eval' => 'trim,required' ), ), 'related_element' => array( 'exclude' => 0, 'label' => 'Related element', 'config' => array( 'type' => 'inline', 'foreign_table' => 'tx_relationquerytest_domain_model_element', 'minitems' => 0, 'maxitems' => 1, 'appearance' => array( 'collapseAll' => 0, 'levelLinksPosition' => 'top', 'showSynchronizationLink' => 1, 'showPossibleLocalizationRecords' => 1, 'showAllLocalizationLink' => 1 ), ), ), ), );
The error again:
#1247602160: Not unique table/alias: 'tx_relationquerytest_domain_model_element': SELECT COUNT(DISTINCT tx_relationquerytest_domain_model_element.uid) FROM tx_relationquerytest_domain_model_element LEFT JOIN tx_relationquerytest_domain_model_element ON tx_relationquerytest_domain_model_element.related_element=tx_relationquerytest_domain_model_element.uid WHERE tx_relationquerytest_domain_model_element.title = 'A' AND tx_relationquerytest_domain_model_element.deleted=0 AND tx_relationquerytest_domain_model_element.t3ver_state<=0 AND tx_relationquerytest_domain_model_element.pid<>-1 AND tx_relationquerytest_domain_model_element.hidden=0 AND tx_relationquerytest_domain_model_element.starttime<=1374245400 AND (tx_relationquerytest_domain_model_element.endtime=0 OR tx_relationquerytest_domain_model_element.endtime>1374245400 ) AND (tx_relationquerytest_domain_model_element.sys_language_uid IN (0,-1)) AND tx_relationquerytest_domain_model_element.pid IN (7)
There is no passthrough
in the TCA configuration anywhere as mentioned in the commit message. How can one fix this error?
Updated by Gerrit Code Review about 10 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Alexander Stehlik about 10 years ago
I stumbled over the same issue and as far as I can see the patch from Alex did not resolve it.
This can be easily reproduces with a functional test (see first patch in the review system).
@Mathias: does the patch from http://review.typo3.org/33956 resolve the issue for you?
Updated by Gerrit Code Review about 10 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Gerrit Code Review about 10 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Alexander Opitz about 10 years ago
- Project changed from 534 to TYPO3 Core
- Category changed from Extbase: Generic Persistence to Extbase
- Target version changed from Extbase 6.0 to 7.0
- TYPO3 Version set to 6.2
- Is Regression set to No
Updated by Gerrit Code Review almost 10 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Gerrit Code Review almost 10 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Mathias Schreiber almost 10 years ago
- Target version changed from 7.0 to 7.1 (Cleanup)
Updated by Gerrit Code Review over 9 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Benni Mack over 9 years ago
- Target version changed from 7.1 (Cleanup) to 7.4 (Backend)
Updated by Susanne Moog over 9 years ago
- Target version changed from 7.4 (Backend) to 7.5
Updated by Gerrit Code Review about 9 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Gerrit Code Review about 9 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Gerrit Code Review about 9 years ago
Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Stephan Großberndt about 9 years ago
- Target version set to 7 LTS
- TYPO3 Version changed from 6.2 to 7
Updated by Gerrit Code Review about 9 years ago
Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Gerrit Code Review about 9 years ago
Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33956
Updated by Alexander Stehlik about 9 years ago
- Status changed from Under Review to Resolved
Applied in changeset 755a948bea34d2269dc77720d37091bba5105a0b.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed