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

Id's not null #15131

Closed
wants to merge 13 commits into from
Closed

Id's not null #15131

wants to merge 13 commits into from

Conversation

Skrypt
Copy link
Contributor

@Skrypt Skrypt commented Jan 19, 2024

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.

Copy link
Member

@kevinchalet kevinchalet left a comment

Choose a reason for hiding this comment

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

👍🏻

{
contentItem.ContentItemVersionId = _idGenerator.GenerateUniqueId(contentItem);
contentItem.Published = true;
contentItem.Latest = true;
Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will try.

Copy link
Member

@sebastienros sebastienros Jan 30, 2024

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.

Copy link
Contributor Author

@Skrypt Skrypt Jan 30, 2024

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restore fixed

Copy link
Contributor Author

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.

Copy link
Contributor Author

@Skrypt Skrypt Jan 31, 2024

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.

@Skrypt Skrypt marked this pull request as ready for review January 30, 2024 06:09
@Skrypt
Copy link
Contributor Author

Skrypt commented Jan 30, 2024

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.

@Skrypt Skrypt added the breaking change 💥 Issues or pull requests that introduces breaking change(s) label Jan 30, 2024
@Skrypt Skrypt self-assigned this Jan 30, 2024
{
contentItem.ContentItemVersionId = _idGenerator.GenerateUniqueId(contentItem);
contentItem.Published = true;
contentItem.Latest = true;
Copy link
Member

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.

Copy link
Member

@Piedone Piedone left a 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))
Copy link
Member

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.

@Skrypt
Copy link
Contributor Author

Skrypt commented Mar 22, 2024

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.

@Piedone
Copy link
Member

Piedone commented Mar 22, 2024

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).

@Skrypt
Copy link
Contributor Author

Skrypt commented Apr 22, 2024

@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.

@Piedone
Copy link
Member

Piedone commented Apr 22, 2024

It would be great, but it needs additional work to make it mergeable: #15131 (comment).

Copy link
Contributor

github-actions bot commented Jul 2, 2024

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.

@github-actions github-actions bot added the stale label Jul 2, 2024
Copy link
Contributor

Closing this pull request because it has been stale for very long. If you think this is still relevant, feel free to reopen it.

@github-actions github-actions bot closed this Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change 💥 Issues or pull requests that introduces breaking change(s) don't merge stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants