Entity Type not updating after changing the Type definition of an Entity

I decided to change an Entity Type name after having already having created a few Entities under an old Type name. I then cloned a bunch of the old Entities to create new test items and everything became very confused and buggy after that!
(for example, the new fields show in Entity editor but those fields can’t be updated because the new values are set to “null” in the CustomData JSON. You end up in a broken state. The only way to resolve is delete the Entities and recreate them)

It now makes sense why you shouldn’t change the Entity Type after first creating the Entity but the configurator should either:

  1. Prevent you from changing the Entity Type after it is first created.
    (easy way to handle it)
    OR
  2. Make the appropriate changes in the db to maintain referential integrity of those records if you update it’s type (unfortunately this is complex operation because Custom Fields and their values would need to be handled appropriately - any mismatching Custom Fields should probably be deleted (but warn the user first).
    p.s. Checking the CustomData in SSMS shows it did try to handle the change, but the word “null” is written to the JSON value where it should have been set to empty value “”.

Example: [{“Name”:“MyFieldName”,“Value”:null}]
Instead of: [{“Name”:“MyFieldName”,“Value”:""}]

(i also noticed a change to Custom Field schema of a Entity Type causes field data to be orphaned.
Example: if you delete the Custom Field named “MyFieldName” above, that old name:value pair is left in the JSON.
perhaps another bug report for that? it doesn’t break anything but leaves old junk in the CustomData field)

This all very minor compared to other serious bugs recently reported but worth mentioning somewhere.

2 Likes

I’ve noticed this before. TBH it’s been convenient it does that on a couple occasions when a client has accidentally deleted custom fields, the data wasn’t lost. However I agree it ideally should remove the orphaned data.

Emre always thought we shouldn’t delete data. Maybe he was attempting that philosophy on it. Some things, even though he knew it may break something, he allowed us to do it anyway. Some things he didn’t.

1 Like