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.
-
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.
-
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.
Similar to attributes (see #45), topic references can be
nullwhen returned from the database. This happens when a previous topic reference was deleted; the new version will use anullvalue. Currently, topics with thesenulltopic references are being treated as unresolved references.Impact
This has two impacts.
When loading values as part of e.g.
ITopicRepository.Refresh()orRollback(), any existing in-memory topic reference values, if present, are not being deleted.More importantly, because the
Topic.Referencescollection will be set to!IsFullyLoaded, any topic references that are deleted will not be removed from the database when callingUpdateReferences.Cause
The
SetReferences()extension method treats anullreference as an unresolved reference. But while a reference could benullbecause it was unresolved, it could also benullbecause it was explicitly deleted. TheSetReferences()extension method should be updated to differentiate betweennullvalues and unresolved references.