Issue Bug Closed

#105310\TYPO3\CMS\Core\Database\Schema\Parser\Parser translates CHAR to VARCHAR

Alexander Schnitzler 10/15/24, 07:56 updated 12/02/25, 14:32

Description

Given the following ext_tables.sql

CREATE TABLE table (
  column CHAR(2),
);

the schema parser detects a char-type but it translates it into a doctrine/dbal type string without fixed set to true. So, this will be translated to

CREATE TABLE table (
  column VARCHAR(2),
);

This would be fixed if the constructor of \TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\CharDataType sets its fixed property to true.
Alternatively, fixed could be part of the options passed into the constructor.

Reviews 6

History 722

  1. Stefan Bürk commented <span data-processor="relativetime" data-value="2024-12-23T16:44:29+00:00" > 12/23/24, 16:44 </span>

    The problem with fixed CHAR is, that PostgreSQL behaves here
    differently than MariaDB, MySQL and SQLite.

    Postgres fills up the retrieved value with spaces to PAD the
    value to the fixed length, the others will not do this.

    Cross database queries like it have to be provided by TYPO3
    itself MUST handle this difference(s) correctly and should
    be avoid as much as possible using VARCHAR instead and have
    the same behaviour accross all supported TYPO3 database vendors.

  2. Stefan Bürk commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-01-07T12:50:09+00:00" > 01/07/25, 12:50 </span>

    Applied in changeset commit:ba10a6ed70de823c29dfe6c4cba71aa474c49390.