Project

General

Profile

Actions

Bug #81334

open

SQL-Error inserting renderType=selectSingle via Extbase on PostgreSQL

Added by Stephan Großberndt almost 7 years ago. Updated over 5 years ago.

Status:
New
Priority:
Must have
Category:
Extbase
Target version:
-
Start date:
2017-05-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

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);

Related issues 2 (2 open0 closed)

Related to TYPO3 Core - Bug #78921: Copying records fails with SQL error without any messageNew2016-12-08

Actions
Related to TYPO3 Core - Epic #90719: PostgreSQL related issuesAccepted2020-03-10

Actions
Actions #1

Updated by Stephan Großberndt almost 7 years ago

  • Description updated (diff)
Actions #2

Updated by Gerrit Code Review almost 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

Actions #3

Updated by Gerrit Code Review almost 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

Actions #4

Updated by Susanne Moog over 6 years ago

  • Related to Bug #78921: Copying records fails with SQL error without any message added
Actions #5

Updated by Gerrit Code Review about 6 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

Actions #6

Updated by Gerrit Code Review about 6 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

Actions #7

Updated by Christian Kuhn over 5 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.

Actions #8

Updated by Stephan Großberndt over 5 years ago

  • Status changed from Rejected to New
Actions #9

Updated by Christian Eßl about 4 years ago

  • Related to Epic #90719: PostgreSQL related issues added
Actions

Also available in: Atom PDF