Add the SQL mode NO_AUTO_VALUE_ON_ZERO to the MySQL database connection

Created on 5 July 2021, about 3 years ago
Updated 17 February 2024, 7 months ago

Problem/Motivation

MySQL by default does not allow row with an auto-increment value to insert the value zero.

Proposed resolution

Use the SQL mode NO_AUTO_VALUE_ON_ZERO by default for the MySQL database driver, which allows a field with an auto-increment value to have the value zero. We are already using the setting for inserting the anonymous user. We do this by temporary adding the setting to the SQL mode for MySQL.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

For MySQL the mode NO_AUTO_VALUE_ON_ZERO has been added to the database connection.

Original issue summary

We should really set NO_AUTO_VALUE_ON_ZERO by default for MySQL, so that we can stop working around MySQL sillyness with 0 in auto-increment columns. This partly blocking #838438: Test the upgrade path because in this issue we need to import a Drupal 6 database, and even if we have a workaround, it's not satisfactory.

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Database 

Last updated less than a minute ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇳🇱Netherlands daffie

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.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • First commit to issue fork.
Production build 0.71.5 2024