-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Id's not null #15131
Id's not null #15131
Conversation
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement/Records/Migrations.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Outdated
Show resolved
Hide resolved
{ | ||
contentItem.ContentItemVersionId = _idGenerator.GenerateUniqueId(contentItem); | ||
contentItem.Published = true; | ||
contentItem.Latest = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't rely on a ContentItemVersionId not set on the ContentItem to define if Latest or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried the cloning events after this change? Or the code path in drivers that check for IsNew
? I have a weird feeling that is was there for a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other example:
public async Task<ContentValidateResult> RestoreAsync(ContentItem contentItem)
{
// Prepare record for restore.
// So that a new record will be created.
contentItem.Id = 0;
// So that a new version id will be generated.
contentItem.ContentItemVersionId = "";
contentItem.Latest = contentItem.Published = false;
which is fine as long as there is a unit test for this method than ensures that your changes are still fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I had the same thought. Remembered that all we do is set the ContentItemVersionId to String.Empty in some use cases which should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloning worked else the unit tests would have failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore seems to have issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For CloningAsync and ClonedAsync the only difference is that now the ContentItemVersionId will be different than null. Should not be affecting our current implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I'm not sure about is the IsNew code path in drivers. Right now, I'm assuming that some unit test would have already failed.
It is probably missing a new UpdateTo for each modules Migration to alter their database. Though, it may not work if ContentItemVersionId's are null in that database. I would rather push this as a breaking change. I can change my mind on this but we don't know the many custom modules out there that relies on the ContentItemVersionId. |
src/OrchardCore/OrchardCore.ContentManagement/Records/Migrations.cs
Outdated
Show resolved
Hide resolved
{ | ||
contentItem.ContentItemVersionId = _idGenerator.GenerateUniqueId(contentItem); | ||
contentItem.Published = true; | ||
contentItem.Latest = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried the cloning events after this change? Or the code path in drivers that check for IsNew
? I have a weird feeling that is was there for a reason.
src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you all want to get back to this?
Also, while this is technically a breaking change, should it break anything in practice? Since null data is already wrong and shouldn't exist for these columns.
@@ -12,11 +12,11 @@ public class Migrations : DataMigration | |||
public async Task<int> CreateAsync() | |||
{ | |||
await SchemaBuilder.CreateMapIndexTableAsync<AuditTrailEventIndex>(table => table | |||
.Column<string>(nameof(AuditTrailEventIndex.EventId), column => column.WithLength(26)) | |||
.Column<string>(nameof(AuditTrailEventIndex.EventId), column => column.NotNull().WithLength(26)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates for all of these changes in this PR are also needed.
Yes, the breaking change is that you can't set a db column to non-null if there are null values in it. Basically, we would need to repopulate all the non-null uuid's by doing SQL Queries to self heal the DB before doing a schema update. |
I see so there can be null values, actually. OK, then indeed with some migrations this can be made non-breaking (or at least automatic, and only breaking if you rely on nullability on a lower level). |
@Piedone This PR is one of those breaking changes that may be necessary for QOL in OC at some point. I can't push more time on it right now but it should definitely be merged as part of making OC more robust. |
It would be great, but it needs additional work to make it mergeable: #15131 (comment). |
It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up. |
Closing this pull request because it has been stale for very long. If you think this is still relevant, feel free to reopen it. |
Related with #14786
Relevates that the ContentItemVersionId can be NULL which I think needs to be fixed.
Well at least our tests fails if we set this to NotNull. So basically when we create a new content item it should probably set a new UID all the time.
Notes
DefaultContentManager.RestoreAsync doesn't have any unit tests.