SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

Created on 18 June 2022, about 3 years ago
Updated 28 May 2025, 4 months ago

Problem/Motivation

Hi,

I have a content type TEST with multivalued field - Exercises - it is a reference to paragraph called Exercise. The Exercise paragraph has several fields, one of them - called Exercise content - is made of the h5p module.

While creating Test I always add 10 exercises. It used to work perfect. Now after adding an exercise and saving node - 1st, 2nd, sometimes also 3rd exercise, it is ok but after saving subsequent exercises, it returns error upon saving the node.

Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1344-4-preloaded' for key 'PRIMARY': INSERT INTO "h5p_content_libraries" ("content_id", "library_id", "dependency_type", "drop_css", "weight") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 1344 [:db_insert_placeholder_1] => 4 [:db_insert_placeholder_2] => preloaded [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 4 ) in Drupal\Core\Database\Driver\mysql\ExceptionHandler->handleExecutionException() (line 50 of core/lib/Drupal/Core/Database/Driver/mysql/ExceptionHandler.php).

I'm not developer, I don't know where the problem is and how to solve it.

Thanks for help!

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

2.0

Component

Code

Created by

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.

  • 🇮🇳India pragna

    Hello,

    I am facing same issue when editing content of h5p.

    Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '190-18-editor' for key 'h5p_content_libraries.PRIMARY': INSERT INTO "h5p_content_libraries" ("content_id", "library_id", "dependency_type", "drop_css", "weight") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 190 [:db_insert_placeholder_1] => 18 [:db_insert_placeholder_2] => editor [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 8 ) in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 45 of /home/deploy/public_html/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php).

  • 🇮🇳India pragna

    Hi @martyma,

    I created a patch to solve this issue. Please check attached patch file.

    Thank you,
    Pragna

  • 🇺🇸United States illeace

    Are either of you able to test if the issue still exists in 2.0.0-alpha6? If so, do you have a simple case that reproduces the error? I've tried to recreate the problem and haven't been able to so far.

Production build 0.71.5 2024