Skip to content

Commit 27d9bfe

Browse files
committed
Merge branch 'bugfix/compounding-relationships' into develop
Clear relationship list between `PersistRelations()` loops With **OnTopic Library 4.0.0**, we introduced a `DataTable` for passing relationships to the `PersisRelations` stored procedure. To reduce the overhead of configuration, this `DataTable` is defined once, and reused for each relationship for a `Topic`. Unfortunately, however, we weren't _`Clear()`ing_ that `DataTable` after each `Topic.Relationships` was saved. That likely means that if a topic had multiple relationships, then the relationships from each previous relationship were included in subsequent relationships. Ooops!! We haven't _noticed_ any instances of that. And that's likely because we almost always only have one relationship on any given content type. The one exception to this is the `Related` and `RelatedContent` relationships which are part of the `Page` content type, and are used to associate related content to each page. Fortunately, neither the `Related` or `RelatedContent` relationships are currently used—and they're the last relationships in by `RelationshipKey` name for all implementations of **OnTopic**. As a result, it's likely that this bug _only_ affected those relationships, and thus continued to go unnoticed. Regardless, having this resolved will avoid potential confusion—or worse!—in the future if/when any implementors choose to add and use multiple relationships on any single content type descriptor.
2 parents 913b68d + d50d389 commit 27d9bfe

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

OnTopic.Data.Sql/SqlTopicRepository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,9 @@ private static string PersistRelations(Topic topic, SqlConnection connection, bo
689689

690690
command.ExecuteNonQuery();
691691

692+
// Clear rows
693+
targetIds.Clear();
694+
692695
}
693696

694697
}

0 commit comments

Comments
 (0)