Skip to content

Models: PropertyType constructor sets the DataTypeKey if IDataType has identity#20301

Merged
AndyButland merged 3 commits intoumbraco:mainfrom
psot:v16/bugfix/20296-propertytype-ctor-set-datatypekey
Sep 30, 2025
Merged

Models: PropertyType constructor sets the DataTypeKey if IDataType has identity#20301
AndyButland merged 3 commits intoumbraco:mainfrom
psot:v16/bugfix/20296-propertytype-ctor-set-datatypekey

Conversation

@psot
Copy link
Contributor

@psot psot commented Sep 29, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #20296

Description

  • I added code to set the DataTypeKey on PropertyType constructor if the IDataType provided has identity, as it did for DataTypeId.
  • If the DataTypeKey was not explicitly set after the PropertyType construction, this resulted in a constraint violation when saving the ContentType, and it could be easily overlooked.
  • I also documented the DataTypeKey property on IPropertyType
  • (closes DataTypeKey not set with PropertyType constructor when passing an IDataType #20296)

@github-actions
Copy link

Hi there @psot, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for this @psot - all looks good to me. I just pushed some updates to the unit tests to reflect these changes, and will merge in once the build checks are complete.

@AndyButland AndyButland changed the title PropertyType constructor sets the DataTypeKey if IDataType has identity Models: PropertyType constructor sets the DataTypeKey if IDataType has identity Sep 30, 2025
@AndyButland AndyButland enabled auto-merge (squash) September 30, 2025 04:47
@AndyButland AndyButland merged commit 65393ff into umbraco:main Sep 30, 2025
24 of 25 checks passed
@psot
Copy link
Contributor Author

psot commented Sep 30, 2025

Thanks @AndyButland I did test it locally but didn't commit any of it, wasn't sure if you wanted and I'm not very familiar with any conventions used in tests so I skipped it. Next time. 😊

@AndyButland
Copy link
Contributor

Don't worry - was all good. I just realised we already had some tests around this, so it made sense to assert this change too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataTypeKey not set with PropertyType constructor when passing an IDataType

2 participants