Commit 2151a08
committed
Support deleting arbitrary attributes
Arbitrary attributes represent a bit of a challenge when it comes to deleting indexed attributes. These deletions are currently handled based on the output of `GetUnmatchedAttributes()` in the `TopicRepositoryBase`. This method returns an `IEnumerable<AttributeDescriptor>`, as it's normally looking for `ContentTypeDescriptor.AttributeDescriptors` that don't correspond to any `AttributeValue`s on the current `Topic`. Arbitrary attributes, however, don't have a corresponding `AttributeDescriptor` by definition (that's what makes them arbitrary).
To mitigate this, while maintaining backward compatibility with `GetUnmatchedAttributes()`, we need to introduce a small hack. The `GetUnmatchedAttributes()` will now also look for arbitrary attributes—i.e., attributes without a corresponding `AttributeDescriptor`—whose value is either `null` or empty, and it will include them in its results alongside other types of unmatched attributes. It will do this by constructing an _ad hoc_ `AttribtueDescriptor` (or, more specifically, a `TextAttribute`). This allows it to relay this finding to downstream callers.
The upshot of this is that `Save()` will not be able to delete arbitrary attribute values—i.e., arbitrary attributes that previously had a value, but then had it deleted. This prevents a scenario where, otherwise, arbitrary values could be saved (c3c01ef) and read, but couldn't be deleted, thus lingering in the database, and potentially polluting the application data since they'll show back up after the application resets.
As part of this, I've introduced a new unit test to validate the core functionality.
This supports Programmatic Support for Arbitrary Attributes (#19)1 parent c3c01ef commit 2151a08
2 files changed
Lines changed: 45 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
172 | 200 | | |
173 | 201 | | |
174 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
544 | | - | |
| 544 | + | |
545 | 545 | | |
546 | | - | |
| 546 | + | |
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
| |||
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
577 | 592 | | |
578 | 593 | | |
579 | 594 | | |
| |||
0 commit comments