Skip to content

Commit 3002d98

Browse files
committed
Incorporated new excludeLastModified parameter into Save()
The `SqlTopicRepository.Save()` method is now updated to use the new `excludeLastModified` parameter of `TopicRepositoryBase.GetAttributes()` (562945c). This maintains its existing functionality of excluding the byline (`LastModifiedBy`) and dateline (`LastModified`) in case no other attributes have been modified, while _also_ supporting the new `IsExtendedAttributeMismatch()` functionality of `TopicRepository.Base.GetAttributes()` (a3d4798), which treats attributes as `IsDirty` if their configured storage location (`AttributeDescriptor.IsExtendedAttribute`) has changed since the attribute has last changed. This complete the bug fix for extended attribute mismatches—an unfortunately complex solution to an edge case.
1 parent 562945c commit 3002d98

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

OnTopic.Data.Sql/SqlTopicRepository.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,22 +289,26 @@ public override int Save([NotNull]Topic topic, bool isRecursive = false, bool is
289289
/*------------------------------------------------------------------------------------------------------------------------
290290
| Add indexed attributes that are dirty
291291
\-----------------------------------------------------------------------------------------------------------------------*/
292-
//Exclude indexed attributes if the only dirty attributes are `LastModified` and/or `LastModifiedBy`, as these are
293-
//automatically generated and don't represent genuine changes to the topic.
294-
if (topic.Attributes.IsDirty(true)) {
295292

296-
var indexedAttributes = GetAttributes(topic, false, true);
293+
//Only include `LastModified` and/or `LastModifiedBy` if other attributes in the collection are `IsDirty`, as these are
294+
//automatically generated and don't represent genuine changes to the topic.
295+
var excludeLastModified = !topic.Attributes.IsDirty(excludeLastModified: true);
297296

298-
foreach (var attributeValue in indexedAttributes) {
297+
var indexedAttributes = GetAttributes(
298+
topic : topic,
299+
isExtendedAttribute : false,
300+
isDirty : true,
301+
excludeLastModified : excludeLastModified
302+
);
299303

300-
var record = attributes.NewRow();
301-
record["AttributeKey"] = attributeValue.Key;
302-
record["AttributeValue"]= attributeValue.Value;
303-
attributeValue.IsDirty = false;
304+
foreach (var attributeValue in indexedAttributes) {
304305

305-
attributes.Rows.Add(record);
306+
var record = attributes.NewRow();
307+
record["AttributeKey"] = attributeValue.Key;
308+
record["AttributeValue"]= attributeValue.Value;
309+
attributeValue.IsDirty = false;
306310

307-
}
311+
attributes.Rows.Add(record);
308312

309313
}
310314

@@ -313,7 +317,7 @@ public override int Save([NotNull]Topic topic, bool isRecursive = false, bool is
313317
\-----------------------------------------------------------------------------------------------------------------------*/
314318
extendedAttributes.Append("<attributes>");
315319

316-
foreach (var attributeValue in GetAttributes(topic, true, null)) {
320+
foreach (var attributeValue in GetAttributes(topic, isExtendedAttribute:true)) {
317321

318322
extendedAttributes.Append(
319323
"<attribute key=\"" + attributeValue.Key + "\"><![CDATA[" + attributeValue.Value + "]]></attribute>"

0 commit comments

Comments
 (0)