Allows fields to be stored by entity type instead of name.

Created on 17 March 2013, almost 12 years ago
Updated 23 January 2025, about 1 month ago

Problems / Motivations

Currently, if we want to have an entity with a field 'title', it is very difficult to do in practice (not technically) because it will create potential naming conflict if another modules require the machine name 'title' on its own entity type. The current solution is to prefix our field by the module's namespace, which is annoying and not really readable, we can improve this.

Each field instance is stored in a standardized table which name is field_data_{$field_name}. The partitioning is vertical due to the entity_type column. The separation of data recorded for an entity rather than another entity is done through this column. For this reason if we want to have a different $field_name in our custom entity this will be not possible: it will share the same table and the same settings.

Proposed resolution

Instead of partitioning vertically our data, we could partition it horizontally, creating a table by entity type instead of by field name.

The resolution involves the moving of the entity_type column out of the table, and creates a new table for each entities using this field. The new name of table data would be then field_data_{$entity_type}_{$field_name} for instance.

This would allow the creation of a 'title' field which would contain 255 characters for an entity type of node, and restricted to 64 characters for an entity type of user for instance. This is a use case among many other that I encounter in some modules i'm currently developing.

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

field system

Created by

πŸ‡«πŸ‡·France Sylvain Lecoy

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

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024