Project

General

Profile

Actions

Bug #87537

closed

Exception: Unknown column 'uid' in 'field list'

Added by Stefan Froemken almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
Start date:
2019-01-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hello Core-Team,

I'm using TYPO3 9.5.4 and I just have installed maps2 4.2.7 which also creates table tt_address with one column "tx_maps2_uid". After that I have installed tt_address withour problems.

When I click list-module I get following error:

Doctrine\DBAL\Exception\InvalidFieldNameException
An exception occurred while executing 'SELECT `uid` FROM `tt_address` WHERE (`tt_address`.`pid` = ?) AND ((`tt_address`.`deleted` = 0) AND ((`tt_address`.`t3ver_wsid` = 0) OR (`tt_address`.`t3ver_state` <= 0)))' with params [0]: Unknown column 'uid' in 'field list'

With Adminer I have a look into structure of tt_address:

Column:
tx_maps2_uid
pid
tstamp
crdate
cruser_id

As you can see column "uid" is missing.

Nice greetings

Stefan

Actions #1

Updated by Stefan Froemken almost 6 years ago

I have catched following Exception while xdebug:

An exception occurred while executing 'ALTER TABLE `tt_address` ADD `uid` INT AUTO_INCREMENT NOT NULL':
Incorrect table definition; there can be only one auto column and it must be defined as a key
Actions #2

Updated by Stefan Froemken almost 6 years ago

Seems that PRIMARY KEY is missing in TYPO3 generated Query:

Query TYPO3: (breaks)
ALTER TABLE `tt_address` ADD `uid` INT AUTO_INCREMENT NOT NULL

Query Adminer: (works)
ALTER TABLE `tt_address` ADD `uid` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
ALTER TABLE `tt_address` ADD `uid` int NOT NULL AUTO_INCREMENT PRIMARY KEY;

Actions #3

Updated by Stefan Froemken almost 6 years ago

OK dear. The row "ALTER TABLE `tt_address` ADD `uid` INT AUTO_INCREMENT NOT NULL" can only work within a CREATE TABLE statement like:

CREATE TABLE `tt_address` (
`tx_maps2_uid` INT NOT NULL,
`uid` INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY `uid`(`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

But not if table tt_address already exists (maps2) without an UID column.

I would prefer you to add PRIMARY KEY to all UID ALTER statements.

Stefan

For now I will try to add column UID in ext_tables.sql of maps2.

Actions #4

Updated by Stefan Froemken almost 6 years ago

Ok... I have found a solution for me. I have added following part in to maps2 Override:

    // ctrl-part has to be present, so TYPO3s DefaultTcaSchema::getPrioritizedFieldNames will create uid and pid
    if (!is_array($GLOBALS['TCA']['tt_address']['ctrl'])) {
        $GLOBALS['TCA']['tt_address']['ctrl'] = [];
    }

This is needed to get a valid table with auto_increment and primary key, as auto_increment can currently NOT be added, if table already exists and does not have UID column.

Actions #5

Updated by Stefan Froemken almost 6 years ago

  • Status changed from New to Resolved
Actions #6

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF