OnTopicCMS/OnTopic-Library

Bug: `SqlTopicRepository`: Implicitly `IsDirty()` topics not being saved

Closed this issue · 1 comments

If a Topic contains an AttributeRecord that is marked as IsExtendedAttribute, but which corresponds to a AttributeDescriptor that is not marked as IsExtendedAttribute—or vice versa!—then it is treated as IsDirty() implicitly by the TopicRepository.GetAttributes() method, even if the AttributeRecord is otherwise clean. This is important as it allows attributes that have been toggled between indexed and extended storage to be updated during Save(). This functionality is well-established and covered by extensive unit tests.

Unfortunately, this rule is not being honored by the SqlTopicRepository implementation, which does not have good unit test coverage due to the challenges of mocking the SQL interfaces (e.g., SqlConnection, SqlCommand, &c.). Looking at the code for Save(), it appears that this rule is being honored when evaluating indexed attributes that have been moved to extended attributes, but not the other direction.

This was resolved in 4e9ec50. This is not validated by unit tests, since the main SqlTopicRepository is not yet covered due to complexities of mocking SqlConnection, SqlCommand, &c. (This remains the one hole in our unit testing coverage—though the base logic, stored procedures, and extension methods themselves remain well covered.)