Skip to content

Commit a1c15ba

Browse files
committed
Extended VersionHistoryIndex to pull versions from all sources
In theory, `Attributes` should be the most authoritative place for accessing the `VersionHistory` since the OnTopic Editor will, at minimum, write a `LastModified` and `LastModifiedBy` attribute for every `Save()`. If a topic is saved programmatically, or an implementation disables the `LastModified` attributes, however, then this won't necessarily be the case. This is especially a concern now that `Relationships` and `TopicReferences` are both versioned. We don't want updates that don't impact `Attributes` to be excluded from the `VersionHistoryIndex`—and, thus, not available for `Rollback()` in the OnTopic Editor. This update to the `VersionHistoryIndex` addresses this by pulling versions not just from `Attributes`, but also from `ExtendedAttributes`, `Relationships`, and `TopicReferences`. This resolves #78.
1 parent eb0615f commit a1c15ba

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

OnTopic.Data.Sql.Database/Views/VersionHistoryIndex.sql

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,31 @@ AS (
1818
PARTITION BY TopicID
1919
ORDER BY Version DESC
2020
)
21-
FROM [dbo].[Attributes]
22-
GROUP BY TopicID,
21+
FROM (
22+
SELECT TopicID,
2323
Version
24+
FROM [dbo].[Attributes]
25+
GROUP BY TopicID,
26+
Version
27+
UNION
28+
SELECT TopicID,
29+
Version
30+
FROM [dbo].[ExtendedAttributes]
31+
GROUP BY TopicID,
32+
Version
33+
UNION
34+
SELECT Source_TopicID AS TopicID,
35+
Version
36+
FROM [dbo].[TopicReferences]
37+
GROUP BY Source_TopicID,
38+
Version
39+
UNION
40+
SELECT Source_TopicID AS TopicID,
41+
Version
42+
FROM [dbo].[Relationships]
43+
GROUP BY Source_TopicID,
44+
Version
45+
) AS VersionList
2446
)
2547
SELECT Versions.TopicId,
2648
Version

0 commit comments

Comments
 (0)