Hi all,
since we have updated to 3.4.3 we have this strange issue.
Our requirement is that after a collection was dropped e.g. by a administrator a new one should be created and the data should be reloaded by our software.
But after dropping a custom collection the SDK seems not to realize that the collection does not exist anymore. Instead if we add new values they are added to the standard collection silently.
Before we got this working by catching the exception during insertion and then checking if the collection does not exist. Now it seems that it hides this error from us, so we can not react on it.
Here is a test that reproduces the issue:
[Test]
[Explicit]
public async Task SetValueAsync_ReproduceDefaultCollectionHandling_CollectionAndElementAdded()
{
// arrange
string collectionName = "Custom";
string id = "ID1";
string content = "content";
var clusterOptions = new ClusterOptions();
clusterOptions.UserName = "aaa";
clusterOptions.Password = "bbbb";
var cluster = await Cluster.ConnectAsync("couchbase://localhost", clusterOptions);
await cluster.WaitUntilReadyAsync(new TimeSpan(0, 0, 30));
var bucket = await cluster.BucketAsync("test");
IScope scope = await bucket.DefaultScopeAsync();
var collection = await scope.CollectionAsync(collectionName);
await scope.Bucket.Collections.CreateCollectionAsync(new CollectionSpec(scope.Name, collectionName));
await collection.InsertAsync(id, content);
// verify it was added properly
var result = await collection.TryGetAsync(id);
result.ContentAs<string>().Should().Be(content);
// verify its not in the default collection
var defaultCollection = await scope.CollectionAsync("_default");
result = await defaultCollection.TryGetAsync(id);
result.Exists.Should().BeFalse();
// remove the custom collection
var spec = new CollectionSpec(scope.Name, collectionName);
await scope.Bucket.Collections.DropCollectionAsync(spec);
await Task.Delay(1000); // fun fact if we don't wait the data still exists... -> bug?
// add again but no collection exists
await collection.InsertAsync(id, content);
// it simulates that its coming out of our custom collection
result = await collection.TryGetAsync(id);
result.ContentAs<string>().Should().Be(content);
result = await defaultCollection.TryGetAsync(id);
result.Exists.Should().BeFalse(); // this fails because the data was inserted to _default !!!
}