Skip to content

Commit 704c8de

Browse files
committed
Set default value of ITopicRepository.Delete(isRecursive) to false
Originally, `ITopicRepository.Delete()`'s `isRecursive` parameter was set to a default value of `false`, as it only makes sense to do a recursive delete if the user opts into it. Unfortunately, however, there was a long-standing bug where `Delete()` failed to validate whether or not there were children, and thus would _always_ do a recursive delete, regardless of whether or not `isRecursive` was set. Whoops. This was fixed in OnTopic 4.5.0 (a0cc21c). In order to avoid breaking backward compatibility, however, the default was changed to `true` so that it continued to operate as it had before (1773113); otherwise this would have been a breaking change. Having the default be more aggressive doesn't make much sense; users should opt in to the more invasive mode. As such, now that we're preparing for a major release, I'm reverting this back to its original default of `false`. Now, if a user attempts to `Delete(Topic)` without explicitly defining `isRecursive`, and that topic has children, an exception will be thrown, and the topic will not be deleted.
1 parent e6bfe58 commit 704c8de

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

OnTopic.Data.Sql/SqlTopicRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public override void Move(Topic topic, Topic target, Topic? sibling) {
546546
| METHOD: DELETE
547547
\-------------------------------------------------------------------------------------------------------------------------*/
548548
/// <inheritdoc />
549-
public override void Delete(Topic topic, bool isRecursive = true) {
549+
public override void Delete(Topic topic, bool isRecursive = false) {
550550

551551
/*------------------------------------------------------------------------------------------------------------------------
552552
| Delete from memory

OnTopic.TestDoubles/DummyTopicRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public DummyTopicRepository() : base() { }
5454
| METHOD: DELETE
5555
\-------------------------------------------------------------------------------------------------------------------------*/
5656
/// <inheritdoc />
57-
public override void Delete(Topic topic, bool isRecursive = true) => throw new NotImplementedException();
57+
public override void Delete(Topic topic, bool isRecursive = false) => throw new NotImplementedException();
5858

5959
} //Class
6060
} //Namespace

OnTopic.TestDoubles/StubTopicRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public override void Move(Topic topic, Topic target, Topic? sibling = null) {
157157
| METHOD: DELETE
158158
\-------------------------------------------------------------------------------------------------------------------------*/
159159
/// <inheritdoc />
160-
public override void Delete(Topic topic, bool isRecursive = true) => base.Delete(topic, isRecursive);
160+
public override void Delete(Topic topic, bool isRecursive = false) => base.Delete(topic, isRecursive);
161161

162162
/*==========================================================================================================================
163163
| METHOD: GET ATTRIBUTES (PROXY)

OnTopic/Repositories/ITopicRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ public interface ITopicRepository {
147147
/// <param name="topic">The topic object to delete.</param>
148148
/// <param name="isRecursive">
149149
/// Boolean indicator nothing whether to recurse through the topic's descendants and delete them as well. If set to false
150-
/// and the topic has children, including any nested topics, an exception will be thrown.
150+
/// and the topic has children, including any nested topics, an exception will be thrown. The default is false.
151151
/// </param>
152152
/// <requires description="The topic to delete must be provided." exception="T:System.ArgumentNullException">
153153
/// topic is not null
154154
/// </requires>
155155
/// <exception cref="ArgumentNullException">topic</exception>
156-
void Delete(Topic topic, bool isRecursive = true);
156+
void Delete(Topic topic, bool isRecursive = false);
157157

158158
} //Interface
159159
} //Namespace

0 commit comments

Comments
 (0)