Commit cbba817
committed
Merge branch 'feature/UpdateRelationships-synchronization' into develop
Updated `UpdateRelationships` to fully synchronize relationships
Previously, in order to update existing relationships, callers had to trigger `UpdateTopic`'s `@DeleteRelationships` flag—which would delete all relationships for that topic—and _then_ call `UpdateRelationships` with the final relationships set. This was wasteful, as often times the relationships will have overlap, or even be identical.
This issue is fixed with with the introduction of the `@DeleteUnmatched` parameter to the `UpdateRelationships` stored procedure (46ba436). By default, this parameter is set to `1` (enabled), though it can be optionally disabled if preferred, in which case `UpdateRelationships` will _add_ any missing relationships, but won't _delete_ any unmatched relationships. That might be useful for just appending new relationships, without worrying about passing current relationships. (I'd prefer the default to be `0` here, but that would break the public interface, so that change will need to wait until the next major version.)
Given that, we are also able to remove the `@DeleteRelationships` functionality from `UpdateTopic`. That said, since `@DeleteRelationships` is part of the public interface, we don't want to remove it as that would require that the `SqlTopicRepository` version be aligned with the database version—something we restrict to major releases, as part of semantic versioning. As such, we're keeping the `@DeleteRelationships` parameter, but removing the functionality (9b58a4b). If the database is up-to-date with this release, that will yield the same results as before. If the database isn't, it will still accept the `@DeleteRelationships` parameter, as expected, and behave as it used to.
Finally, the code from a previous update which avoided primary key constraint violations by deduplicating the insert was optimized to use a `LEFT JOIN` with the actual `Relationships` table instead of using `@Existing_TopicIDs` as a temporary storage location, as user-defined, table-valued types have proven to be quite inefficient (e725077).4 files changed
Lines changed: 30 additions & 42 deletions
File tree
- OnTopic.Data.Sql.Database
- Stored Procedures
- Utilities/Stored Procedures
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
| 90 | + | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
| 95 | + | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
| 100 | + | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
| 105 | + | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
Lines changed: 21 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 14 | | |
31 | 15 | | |
32 | 16 | | |
| |||
36 | 20 | | |
37 | 21 | | |
38 | 22 | | |
39 | | - | |
| 23 | + | |
40 | 24 | | |
41 | | - | |
| 25 | + | |
42 | 26 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
46 | 44 | | |
47 | 45 | | |
48 | 46 | | |
| |||
Lines changed: 0 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | 102 | | |
113 | 103 | | |
114 | 104 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
0 commit comments