Add entity type to FieldException messages thrown in SqlContentEntityStorageSchema

Created on 24 August 2022, almost 3 years ago
Updated 11 April 2023, about 2 years ago

Problem/Motivation

The exceptions thrown by SqlContentEntityStorageSchema give the field name, but not the entity type.

This can be confusing when it's a common field name such as 'title' or 'type' which is causing the problem.

Steps to reproduce

Proposed resolution

Agree on new exception message

Option B
Illegal initial value definition on field 'new_base_field' on entity type 'entity_test_update': Both fields have to be stored in the shared entity tables.

Remaining tasks

Update patch with agreed change
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

10.1

Component
Entity 

Last updated about 13 hours ago

Created by

🇬🇧United Kingdom joachim

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.

  • 🇺🇸United States smustgrave

    Been a few weeks. Lets go with optionB!

  • Status changed to Needs review over 2 years ago
  • Status changed to RTBC over 2 years ago
  • 🇺🇸United States smustgrave

    This seems better to me.

  • Status changed to Needs work about 2 years ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
    +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
    @@ -2063,7 +2063,7 @@ protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $st
    -      throw new FieldException("Illegal field column names on {$storage_definition->getName()}");
    +      throw new FieldException("Illegal field column names on {$storage_definition->getName()} in {$storage_definition->getTargetEntityTypeId()} entity");
    
    @@ -2330,7 +2330,7 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor
    -      throw new FieldException("Illegal field column names on {$storage_definition->getName()}");
    +      throw new FieldException("Illegal field column names on '{$storage_definition->getName()}' on entity type '{$storage_definition->getTargetEntityTypeId()}'");
    

    I think we can improve this one further too, by letting the user know which column names are illegal.

    Also, it would be worth making them consistent whilst we're here (one has single quotes around the field name and entity type, the other does not).

    Thanks folks

  • 🇮🇳India rassoni Bangalore

    Addressed #16 Feedback.

    Also, it would be worth making them consistent whilst we're here (one has single quotes around the field name and entity type, the other does not).

    Not changing status #16 remaining part.

Production build 0.71.5 2024