Forbid limited length primary and unique keys, allow only in indexes

Created on 19 September 2019, about 5 years ago
Updated 6 October 2023, about 1 year ago

Problem/Motivation

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.

Proposed resolution

  • Deprecate createion of PKs or unique keys with limited length in 10.2 then throw a SchemaException or similar in 11.
  • Update database API docs accordingly.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Database 

Last updated 2 days ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇮🇹Italy mondrake 🇮🇹

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.

Production build 0.71.5 2024