Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translatable: Field name length exceeds field length in translations table when using Embeddable #2733

Open
johanib opened this issue Dec 7, 2023 · 0 comments

Comments

@johanib
Copy link

johanib commented Dec 7, 2023

Environment

Symfony 6.2

Package

show

$ composer show --latest gedmo/doctrine-extensions
/srv/app # composer show --latest gedmo/doctrine-extensions
name     : gedmo/doctrine-extensions
descrip. : Doctrine behavioral extensions
keywords : Blameable, behaviors, doctrine, extensions, gedmo, loggable, nestedset, odm, orm, sluggable, sortable, timestampable, translatable, tree, uploadable
versions : * v3.13.0
latest   : v3.14.0
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : http://gediminasm.org/
source   : [git] https://github.com/doctrine-extensions/DoctrineExtensions.git 291d0c527d2dc9ee07b888c9a4e2a179893f08ab
dist     : [zip] https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/291d0c527d2dc9ee07b888c9a4e2a179893f08ab 291d0c527d2dc9ee07b888c9a4e2a179893f08ab
path     : /srv/app/vendor/gedmo/doctrine-extensions
names    : gedmo/doctrine-extensions

support
email : gediminas.morkevicius@gmail.com
issues : https://github.com/doctrine-extensions/DoctrineExtensions/issues
source : https://github.com/doctrine-extensions/DoctrineExtensions/tree/v3.13.0
wiki : https://github.com/Atlantic18/DoctrineExtensions/tree/main/doc

autoload
psr-4
Gedmo\ => src/

requires
behat/transliterator ^1.2
doctrine/annotations ^1.13 || ^2.0
doctrine/collections ^1.2 || ^2.0
doctrine/common ^2.13 || ^3.0
doctrine/event-manager ^1.2 || ^2.0
doctrine/persistence ^2.2 || ^3.0
php ^7.2 || ^8.0
psr/cache ^1 || ^2 || ^3
symfony/cache ^4.4 || ^5.3 || ^6.0
symfony/deprecation-contracts ^2.1 || ^3.0

requires (dev)
doctrine/cache ^1.11 || ^2.0
doctrine/dbal ^2.13.1 || ^3.2
doctrine/doctrine-bundle ^2.3
doctrine/mongodb-odm ^2.3
doctrine/orm ^2.10.2
friendsofphp/php-cs-fixer ^3.4.0 <3.10
nesbot/carbon ^2.55
phpstan/phpstan ^1.10.2
phpstan/phpstan-doctrine ^1.0
phpstan/phpstan-phpunit ^1.0
phpunit/phpunit ^8.5 || ^9.5
rector/rector ^0.15.20
symfony/console ^4.4 || ^5.3 || ^6.0
symfony/phpunit-bridge ^6.0
symfony/yaml ^4.4 || ^5.3 || ^6.0

suggests
doctrine/mongodb-odm to use the extensions with the MongoDB ODM
doctrine/orm to use the extensions with the ORM

conflicts
doctrine/dbal <2.13.1 || ^3.0 <3.2
doctrine/mongodb-odm <2.3
doctrine/orm <2.10.2 || 2.16.0 || 2.16.1
sebastian/comparator <2.0

Doctrine packages

show

$ composer show --latest 'doctrine/*'
Direct dependencies required in composer.json:
doctrine/coding-standard            12.0.0 12.0.0 The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.
doctrine/doctrine-bundle            2.11.0 2.11.1 Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle   3.4.4  3.5.1  Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle 3.2.4  3.3.0  Symfony DoctrineMigrationsBundle
doctrine/orm                        2.17.1 2.17.1 Object-Relational-Mapper for PHP

Transitive dependencies not required in composer.json:
doctrine/annotations                2.0.1  2.0.1  Docblock Annotations Parser
doctrine/cache                      2.2.0  2.2.0  PHP Doctrine Cache library is a popular cache implementation that supports many different drivers ...
doctrine/collections                2.1.4  2.1.4  PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                     3.4.3  3.4.3  PHP Doctrine Common project is a library that provides additional functionality that other Doctrin...
doctrine/data-fixtures              1.6.7  1.7.0  Data Fixtures for all Doctrine Object Managers
doctrine/dbal                       3.7.2  3.7.2  Powerful PHP database abstraction layer (DBAL) with many features for database schema introspectio...
doctrine/deprecations               1.1.2  1.1.2  A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable ...
doctrine/event-manager              2.0.0  2.0.0  The Doctrine Event Manager is a simple PHP event system that was built to be used with the various...
doctrine/inflector                  2.0.8  2.0.8  PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upp...
doctrine/instantiator               2.0.0  2.0.0  A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                      2.1.0  3.0.0  PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                 3.7.0  3.7.2  PHP Doctrine Migrations project offer additional functionality on top of the database abstraction ...
doctrine/persistence                3.2.0  3.2.0  The Doctrine Persistence project is a set of shared interfaces and functionality that the differen...
doctrine/sql-formatter              1.1.3  1.1.3  a PHP SQL highlighting library

PHP version

PHP 8.2.11

Subject

The translations extension seems to support using Embeddables.
However, making a embedded field translatable will try to save field like this:
embeddableName.embeddableFieldName
The issue is that the \Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation class currently uses a varchar(32) on the field column.
When using embeddables, the field names can quickly become much longer than 32 chars. (51 chars in my case).
If this happens, when saving data, Symfony will throw the error: 1406 Data too long for column 'field'

So to better support Translatable Embeddable I think the default column length should be increased.

Steps to reproduce

  • Make an entity with an Embeddable with
  • Make a field in the Embeddable translatable
  • Make sure the name of the embebbable and the translatable field name combined are longer than 32 chars.
  • Try to save the translated field

Expected results

No errors

Actual results

Symfony\Component\Messenger\Exception\HandlerFailedException:
Handling "App\Message\Command\UpdateMyEntity" failed: An exception occurred while executing a query: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field' at row 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant