Bug #102298
closedSQL JOIN in inherited SuggestWizardReceiver leeds to SQL Exception
100%
Description
the "SuggestWizardDefaultReceiver" is inteded to be inherited from other Implementation of Ajax Suggest Receiver (s. https://github.com/TYPO3/typo3/blob/main/typo3/sysext/backend/Classes/Form/Wizard/SuggestWizardDefaultReceiver.php#L33)
if we extend it and add a JOIN to an other table it leeds to an SQL Exception
(1/3) Doctrine\DBAL\Exception\NonUniqueFieldNameException An exception occurred while executing 'SELECT COUNT(`uid`) FROM `mmn_person_function_unit` INNER JOIN `domain_model_person` `person` ON `person`.`uid` = mmn_person_function_unit.person_uid WHERE (`mmn_person_function_unit`.`foreign_uid` = ?) AND (`person`.`sortingname` LIKE ? ESCAPE '\\') AND (`person`.`sys_language_uid` LIKE ? ESCAPE '\\') AND (`person`.`deleted` = 0) LIMIT 50' with params [1809, "%karl%", 0]: Column 'uid' in field list is ambiguous
class MyRelationReceiver extends SuggestWizardDefaultReceiver protected function prepareSelectStatement() { $expressionBuilder = $this->queryBuilder->expr(); $this->queryBuilder->resetQueryParts(); $this->queryBuilder ->join( $this->table, 'domain_model_person', 'person', $expressionBuilder->eq('person.uid', $this->table . '.person_uid') ) ->where( $expressionBuilder->eq($this->table . '.foreign_uid', $this->queryBuilder->createNamedParameter((int)$this->params['uid'], \PDO::PARAM_INT)), $expressionBuilder->like('person.sortingname', $this->queryBuilder->createNamedParameter('%' . $this->params['value'] . '%')) ); }
and TCA
'<my-field>' => [ 'label' => 'My Relation', 'config' => [ 'type' => 'group', 'allowed' => 'mmn_person_function_unit', 'foreign_table' => 'mmn_person_function_unit', 'suggestOptions' => [ 'default' => [ 'receiverClass' => <MyRelationReceiver>, ], ], ], ],
the "select()" and "count()" in the "queryTable" Method should prefix fields with "table"
this affects all TYPO3 Versions (11,12,13)
Updated by Gerrit Code Review 6 months ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81637
Updated by Gerrit Code Review 6 months ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81637
Updated by Anonymous 6 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 5c3ad376875e1c1cfa81053e378968bb0fde3935.
Updated by Gerrit Code Review 6 months ago
- Status changed from Resolved to Under Review
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81650
Updated by Gerrit Code Review 6 months ago
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81651
Updated by Anonymous 6 months ago
- Status changed from Under Review to Resolved
Applied in changeset b5fe05c8edd1386d650825d1a7a616ef52a5512e.