Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Existing instances are not updated if property (True/false) with default true is added to existing documenttype #9649

Closed
waldvmar opened this issue Jan 13, 2021 · 3 comments

Comments

@waldvmar
Copy link

If I add a new property of type True/false with Default value True to an existing documenttype and there are already existing instances of this documenttype, the value of that property on those existing instances is not set to the default value true in the database. So it's required to get all instances of this documenttype, set the value and save and publish it then again.

Umbraco version

I am seeing this issue on Umbraco version: 8

Reproduction

If you're filing a bug, please describe how to reproduce it. Include as much
relevant information as possible, such as:

Bug summary

If I add a new property of type True/false with Default value True to an existing documenttype and there are already existing instances of this documenttype, the value of that property on those existing instances is not set to the default value true in the database. So it's required to get all instances of this documenttype, set the value and save and publish it then again.

Specifics

Steps to reproduce

  • create a documenttype with some properties
  • create an instance of this documenttype in the content section and save and publish it
  • add a property of type True/False with Default-Value True to the documenttype above
  • check the instance of this documenttype if the value of this property is set and if it's set to True (it will be false in the database, but it will look like if it's set to true in the node in content section)
  • Save and publish the existing instance again (Now the value of the property should be set to True in the database)

Expected result

If a property of type True/False with Default-Value True is added to an existing documenttype, all instances of this type should be updated with the new property and the value True.

Actual result

  • The Default value of the new property is not set on existing instances
@waldvmar waldvmar changed the title Existing instances are not updated if property (True/false) with default true is added Existing instances are not updated if property (True/false) with default true is added to existing documenttype Jan 13, 2021
@nathanwoulfe
Copy link
Contributor

Hey @waldvmar please excuse my brevity, I'm in my phone so typing is slooooow.

Long story short, this is the expected behaviour. There are other issues here explaining it in better detail, but it's along the lines of the default value belonging to the data type, not to all properties of that type. When the node is rendered in the backoffice, the property will have the default value set from the data type, hence why it's necessary to save and publish to see the property value updated in the database.

@nul800sebastiaan might be able to link us to the other discussions, and also expand on my explanation.

@waldvmar
Copy link
Author

waldvmar commented Jan 15, 2021

Hej @nathanwoulfe

Okay, I see the case. But wouldn't it be nice to extend the true/false datatype with a property where it can be enabled that if a property of that datatype is added to a documenttype that the existing content instances of that documenttype are getting updated?

The use case is the following:
The end customers are use that property names are written positive like "Slideranimation enable" or even better just "Slideranimation". If the default is true and it's positive the switch button will be filled out and the round circle is on the right side by default and if they disable it, the switch button also looks disabled. That way no further explanation is required. But if the switch button is off by default, the propery name would need to be "Slideranimation disable". If the customer set this switch button to on than it will be filled out, but the Slideranimation would be disabled. It can be very confusing for them as it's the opposite how they are used that switch toggles work...

@nul800sebastiaan
Copy link
Member

Any datatype that has a default value will never update any content in case you change the default value.

This is done for a few reasons, first, this could be a very heavy database operation, depending on the amount of content already using this datatype.

We also can't determine if that is what you wanted to happen, maybe your business rule is that from now on the new default value should be used. So changing the behavior now would be a functional breaking change.

We do want to change this behavior, but it is not an easy change, we've made a proposal over here: #7859

While this doesn't directly address your feature request here, it is now linked to that issue so this can be taken into consideration as well.

In your case, right now, you are left with two options: either go in manually and save & publish all required items again or write a bit of code to set and publish the required values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants