Skip to content

Commit 34084fd

Browse files
committed
Merge branch 'bugfix/DeleteOrphanedLastModifiedAttributes' into release/5.1.0
Previously, the `DeleteOrphanedLastModifiedAttributes` only accounted for `LastModified`, not `LastModifiedBy`—and, as such, would not get tripped if both the `LastModified` _and_ `LastModifiedBy` attributes were updated at the same time, even if no other attributes were updated. Further, it didn't account for `TopicReferences` or `Relationships`—which, as of OnTopic 5.0.0, are also versioned. As a result, this would yield a false positive if the `LastModified` and `LastModifiedBy` attributes accompanied a change that only otherwise affected topic associations. The resolves #88.
2 parents b7a89bf + 752a826 commit 34084fd

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

OnTopic.Data.Sql.Database/Utilities/Stored Procedures/DeleteOrphanedLastModifiedAttributes.sql

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,21 @@ FROM Attributes
3737
LEFT JOIN Attributes Unmatched
3838
ON Attributes.TopicID = Unmatched.TopicID
3939
AND Attributes.Version = Unmatched.Version
40-
AND Attributes.AttributeKey != Unmatched.AttributeKey
40+
AND Unmatched.AttributeKey NOT LIKE 'LastModified%'
4141
LEFT JOIN ExtendedAttributes UnmatchedExtended
4242
ON Attributes.TopicID = UnmatchedExtended.TopicID
4343
AND Attributes.Version = UnmatchedExtended.Version
44+
LEFT JOIN Relationships UnmatchedRelationships
45+
ON Attributes.TopicID = UnmatchedRelationships.Source_TopicID
46+
AND Attributes.Version = UnmatchedRelationships.Version
47+
LEFT JOIN TopicReferences UnmatchedReferences
48+
ON Attributes.TopicID = UnmatchedReferences.Source_TopicID
49+
AND Attributes.Version = UnmatchedReferences.Version
4450
WHERE Unmatched.AttributeKey IS NULL
4551
AND UnmatchedExtended.TopicID IS NULL
46-
AND Attributes.AttributeKey = 'LastModified'
52+
AND UnmatchedRelationships.Source_TopicID IS NULL
53+
AND UnmatchedReferences.Source_TopicID IS NULL
54+
AND Attributes.AttributeKey LIKE 'LastModified%'
4755

4856
--------------------------------------------------------------------------------------------------------------------------------
4957
-- CHECK FINAL VALUES

0 commit comments

Comments
 (0)