Problem/Motivation

The current implementation of identifier for Permanent Entities is great for doing things like

PermenentEntity::load('jupiter');

but this also makes the primary key a string. If you need to change the name of the entity you will need to also update this key in a lot of tables:

UPDATE permanent_entity SET id = 'NEW_NAME' WHERE id = 'OLD_NAME';
UPDATE permanent_entity_field_data SET id = 'NEW_NAME' WHERE id = 'OLD_NAME';
UPDATE permanent_entity_field_revision SET id = 'NEW_NAME' WHERE id = 'OLD_NAME';
UPDATE permanent_entity_revision SET id = 'NEW_NAME' WHERE id = 'OLD_NAME';
UPDATE permanent_entity_revision__field_random_field1 SET entity_id = 'NEW_NAME' WHERE entity_id = 'OLD_NAME';
UPDATE permanent_entity_revision__field_random_field2 SET entity_id = 'NEW_NAME' WHERE entity_id = 'OLD_NAME';
UPDATE permanent_entity_revision__field_random_field3 SET entity_id = 'NEW_NAME' WHERE entity_id = 'OLD_NAME';
UPDATE permanent_entity_revision__field_random_field4 SET entity_id = 'NEW_NAME' WHERE entity_id = 'OLD_NAME';
UPDATE permanent_entity_revision__field_random_field5 SET entity_id = 'NEW_NAME' WHERE entity_id = 'OLD_NAME';
UPDATE permanent_entity_revision__field_random_field6 SET entity_id = 'NEW_NAME' WHERE entity_id = 'OLD_NAME';

Proposed resolution

  • Refactor the module to have numeric identifiers.
  • Provide a new method loadByName to load permanent entities by machine name

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dagmar created an issue. See original summary.

dagmar’s picture

Assigned: Unassigned » dagmar

I will create a 2.x branch of this module to address this issue.