Bug #81334
closedSQL-Error inserting renderType=selectSingle via Extbase on PostgreSQL
0%
Description
Use a TCA definition defining a select with renderType=selectSingle like
return [ 'ctrl' => [ 'title' => 'tx_myext_table', 'label' => 'my_select_single' ], 'types' => [ '1' => ['showitem' => 'my_select_single'] ], 'columns' => [ 'my_select_single' => [ 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', 'items' => [ ['A', 0], ['B', 1], ['C', 2] ] ] ] ] ];
and a ext_tables.sql definition defining the value as integer
CREATE TABLE tx_myext_table ( uid int(10) unsigned NOT NULL auto_increment, pid int(10) unsigned NOT NULL DEFAULT '0', my_select_single tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (uid) );
Have an according Extbase Model like
class Table extends AbstractEntity { /** * @var int */ protected $mySelectSingle; /** * @return int $mySelectSingle */ public function getMySelectSingle() { return $this->mySelectSingle; } /** * @param int $mySelectSingle * @return void */ public function setMySelectSingle($mySelectSingle) { $this->mySelectSingle = $mySelectSingle; } }
When trying to insert a new Record like
$table = new Table(); $table->setMySelectSingle(1); $tableRepository->add($table);
and having a PostgreSQL database beneath this fails with
#1470230766: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: »« (More information)
because when persisting the Extbase object this property is seen as a CSV relation in TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory->setRelations
:
protected function setRelations(ColumnMap $columnMap, $columnConfiguration, $propertyMetaData) { if (isset($columnConfiguration)) { if (isset($columnConfiguration['MM'])) { $columnMap = $this->setManyToManyRelation($columnMap, $columnConfiguration); } elseif (isset($propertyMetaData['elementType'])) { $columnMap = $this->setOneToManyRelation($columnMap, $columnConfiguration); } elseif (isset($propertyMetaData['type']) && strpbrk($propertyMetaData['type'], '_\\') !== false) { $columnMap = $this->setOneToOneRelation($columnMap, $columnConfiguration); } elseif (isset($columnConfiguration['type']) && $columnConfiguration['type'] === 'select') { $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY); } else { $columnMap->setTypeOfRelation(ColumnMap::RELATION_NONE); } } else { $columnMap->setTypeOfRelation(ColumnMap::RELATION_NONE); } return $columnMap; }
because type=select always defines the relation to be of type ColumnMap::RELATION_HAS_MANY in
} elseif (isset($columnConfiguration['type']) && $columnConfiguration['type'] === 'select') { $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY);
Adding an additional check for renderType=selectSingle fixes this:
} elseif (isset($columnConfiguration['type']) && $columnConfiguration['type'] === 'select' && isset($columnConfiguration['renderType']) && $columnConfiguration['renderType'] === 'selectSingle') { $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_ONE); } elseif (isset($columnConfiguration['type']) && $columnConfiguration['type'] === 'select') { $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY);
Updated by Gerrit Code Review over 7 years ago
- Status changed from New 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 https://review.typo3.org/52935
Updated by Gerrit Code Review over 7 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52935
Updated by Susanne Moog about 7 years ago
- Related to Bug #78921: Copying records fails with SQL error without any message added
Updated by Gerrit Code Review almost 7 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52935
Updated by Gerrit Code Review almost 7 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52935
Updated by Christian Kuhn about 6 years ago
- Status changed from Under Review to Rejected
hey stephan. nothing happened on this patch for a long time and i'm unsure if it is still an issue. for the sake of a more clean review queue, i'll abandon the patch for now and reject the issue. please feel free to resurrect the patch if it is still an issue.
Updated by Stephan Großberndt about 6 years ago
- Status changed from Rejected to New
Updated by Christian Eßl over 4 years ago
- Related to Epic #90719: PostgreSQL related issues added
Updated by Georg Ringer 4 months ago
- Status changed from New to Closed
this has been solved already longer time ago
if ( isset($columnConfiguration['type'], $columnConfiguration['renderType']) && $columnConfiguration['type'] === 'select' && ( $columnConfiguration['renderType'] !== 'selectSingle' || (isset($columnConfiguration['maxitems']) && $columnConfiguration['maxitems'] > 1) ) ) { $columnMap->setTypeOfRelation(Relation::HAS_MANY); return $columnMap; }