Skip to content

Bug: SqlTopicRepository.Load() treats deleted references as unresolved #46

@JeremyCaney

Description

@JeremyCaney

Similar to attributes (see #45), topic references can be null when returned from the database. This happens when a previous topic reference was deleted; the new version will use a null value. Currently, topics with these null topic references are being treated as unresolved references.

Impact

This has two impacts.

  1. When loading values as part of e.g. ITopicRepository.Refresh() or Rollback(), any existing in-memory topic reference values, if present, are not being deleted.

    Note: There may also be circumstances where this could result in those values being inadvertently persisted to the database—though, fortunately, this will generally be avoided by the fact that Save() doesn't include clean topic references when calling the UpdateReferences stored procedure.

  2. More importantly, because the Topic.References collection will be set to !IsFullyLoaded, any topic references that are deleted will not be removed from the database when calling UpdateReferences.

    Note: This is due to a safeguard which prevents collections that Load() was not able to fully load from deleting the orphaned references on Save().

Cause

The SetReferences() extension method treats a null reference as an unresolved reference. But while a reference could be null because it was unresolved, it could also be null because it was explicitly deleted. The SetReferences() extension method should be updated to differentiate between null values and unresolved references.

Metadata

Metadata

Assignees

Labels

Area: RepositoriesRelates to the `ITopicRepository` interface or one of its implementations.Priority: 1Severity 2: MajorStatus 5: CompleteTask is considered complete, and ready for deployment.Type: BugBehavior that is inconsistent with documented or expected behavior.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions