Problem/Motivation

Where there is only 1 subfield of a data field, it is possible to delete it but then the field become unmanageable.

Steps to reproduce

Create a data field with a subfield.
Delete this data field.
Edit the field: in the "field settings" tab throws error 500 and also trying to delete the datafield throws error 500 with

Uncaught PHP Exception Drupal\Core\Database\DatabaseExceptionWrapper:
"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 1 OFFSET 0' at line 5: SELECT 1 AS "expression" FROM "product__field_test_" "t" WHERE LIMIT 1 OFFSET 0; Array ( )"
at /web/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php line 46

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Giuse69 created an issue. See original summary.

lazzyvn’s picture

It's true, I have never tested this case. Can you debug and create a patch?

giuse69’s picture

I am available for testing but I am not a Drupal developer, sorry....

  • lazzyvn committed 0843f47b on master
    Issue #3401395: Fatal error when removing last sub-field
    

  • lazzyvn committed 0843f47b on 1.x
    Issue #3401395: Fatal error when removing last sub-field
    
lazzyvn’s picture

Status: Active » Fixed

- when creating new field drupal by creating table with column field_name_value when we delete subfield it deletes this column so it must have at least one subfield, Fixed by removing delete button for last subfield in setting storage

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.