Tests fail on websites with a table prefix

Created on 29 September 2014, over 10 years ago
Updated 28 May 2024, 12 months ago

\Drupal\Core\Entity\Sql\DefaultTableMapping::generateFieldTableName currently allows for 16 character table limits, however this is used in its entirety by simpletest. This has the effect that any table prefix can cause tests to fail.

Steps to reproduce:

Make a clean Drupal 8 install filling in any table prefix during installation.
Enable the testing module and run the DRUPAL\SYSTEM\TESTS\ENTITY\ENTITYTRANSLATIONTEST.

Possible solution:

Pass the allowed maximum table name length (DBMS's limit minus the table prefix) to the conrstuctor of \Drupal\Core\Entity\Sql\DefaultTableMapping. Use that instead of the hardcoded "48".

Since we currently can't retrieve the maximum table name length of the DBMS, just hardcode that to 62 (Postgres' limit, which is two bytes lower than MySQL's and should therefore have priority).
#2346953: Add a method for retrieving the maximum table name (or other identifier) length would help further with this, making it possible to set the limit dependent on the DBMS.

Workaround:

1. Don't use a table prefix during development.
2. Don't run tests when you're in production (d'oh, and see 1.)

🐛 Bug report
Status

Closed: outdated

Version

11.0 🔥

Component
PHPUnit 

Last updated about 1 hour ago

Created by

🇳🇱Netherlands kingdutch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    I tested this on Drupal 11.x with a prefix of 27 characters and tests ran just find. I ran the migration Upgrade7 test which makes lots of tables, some potentially long. Based on that this has been fixed sometime in the past 10 years.

    Closing as outdated.

Production build 0.71.5 2024