Commit 180526e
committed
Merge branch 'feature/ITopicRepository.Load-parentTopic' into develop
According to the `ITopicRepository.Load()` signature, a topic can be loaded from anywhere within the topic graph. And, indeed, that works just fine assuming one is querying e.g. the `CachedTopicRepository`, which has access to the entire tree.
If one queries a data store—e.g., via the `SqlTopicRepository`—however, that can result in an incomplete topic being returned, since it won't be able to find topic references and relationships which occur outside the `Load()` scope. That can then cause problems if the topic is then saved, as those orphaned references may get overwritten.
(Note: In practice, this usually only affects `Load(topicId, version)` since most applications use the `CachedTopicRepository`. And since relationships and references aren't currently versioned, this doesn't have an impact on `Rollback()` either. Nevertheless, it remains a hole in the design that could yield unexpected bugs, if not data loss.)
In order to resolve this, the `ITopicRepository.Load()` signature has been extended to accept an optional `referenceTopic`. When present, this prepopulates the list of topics with those already in memory. This ensures that a topic being loaded has access to the rest of the graph, at least insofar as the current application is aware of it.
Further, this optionally allows `ITopicRepository` instances to update existing instances of topics, instead of loading new object references referring to the same entity, which can cause additional problems. As part of that, the `SqlTopicRepository`'s `SqlDataReader` extensions now accept a `markDirty` parameter to control whether or not topics, collections, and values are marked dirty when loaded. This allows `Rollback()` to use the `Load(referenceTopic, version)` directly since, unlike `Load()`, it _should_ mark modified attributes as `IsDirty`.
Finally, a number of bugs were resolved as part of this update. For example, the `GetTopicVersion` stored procedure wasn't correctly returning either the core attributes (since they were moved to the `Topics` table), nor the `Version` column for the `Attributes` or `ExtendedAttributes` table.File tree
18 files changed
+239
-186
lines changed- OnTopic.AspNetCore.Mvc/Components
- OnTopic.Data.Caching
- OnTopic.Data.Sql.Database/Stored Procedures
- OnTopic.Data.Sql
- OnTopic.TestDoubles
- OnTopic.Tests
- OnTopic
- Attributes
- Collections
- Mapping
- Hierarchical
- Reverse
- Querying
- References
- Repositories
18 files changed
+239
-186
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
Lines changed: 12 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 19 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
52 | 26 | | |
53 | 27 | | |
54 | 28 | | |
| |||
58 | 32 | | |
59 | 33 | | |
60 | 34 | | |
| 35 | + | |
61 | 36 | | |
62 | 37 | | |
63 | 38 | | |
| |||
69 | 44 | | |
70 | 45 | | |
71 | 46 | | |
72 | | - | |
| 47 | + | |
| 48 | + | |
73 | 49 | | |
74 | 50 | | |
75 | 51 | | |
| |||
80 | 56 | | |
81 | 57 | | |
82 | 58 | | |
| 59 | + | |
83 | 60 | | |
84 | 61 | | |
85 | 62 | | |
| |||
89 | 66 | | |
90 | 67 | | |
91 | 68 | | |
92 | | - | |
| 69 | + | |
| 70 | + | |
93 | 71 | | |
94 | 72 | | |
95 | 73 | | |
| |||
0 commit comments