Clarify in docs that limited length keys apply to indexes only, enforce in code

Created on 19 September 2019, almost 6 years ago
Updated 20 January 2023, over 2 years ago

As discussed in #3068310: Composite primary key with specified index length fails the NOT NULL check , limited length keys are applicable only to indexes, not to primary and unique keys.

See #11 there:

A fundamental/conceptual question here: are we sure we want to support partial lenght columns in a unique key context here (primary/unique keys)? IMHO it seems weird you design a table with fields that you want to be kind of unique via PK, then to have a PK that would fatally fail when trying to insert records that lead to duplicate key, which can happen if your field varies in the part that is not part of the key -- how are we going to decide which is the 'right' key and record?

Recently, Doctrine DBAL have introduced partial length support to indexes https://github.com/doctrine/dbal/pull/2412, but have done so only for indexes, that allow duplicated keys - not for primary/unique keys.

It should be clarified in the docs that this is the case, and enforce in code that trying to create PKs or unique keys with limited length throws a SchemaException or similar.

📌 Task
Status

Needs work

Version

10.1

Component
Database 

Last updated 3 days ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇮🇹Italy mondrake 🇮🇹

Live updates comments and jobs are added and updated live.
  • Documentation

    Primarily changes documentation, not code. For Drupal core issues, select the Documentation component instead of using this tag. In general, component selection is preferred over tag selection.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

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.

Production build 0.71.5 2024