Skip to content

Commit 961533b

Browse files
committed
Little tweaks to the eject for dirty sessions
1 parent cc7fbd5 commit 961533b

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/Marten/Internal/Sessions/DocumentSessionBase.Deletes.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public void Delete<T>(T entity) where T : notnull
2727
_workTracker.Add(deletion);
2828

2929
documentStorage.Eject(this, entity);
30-
ChangeTrackers.RemoveAll(x => ReferenceEquals(entity, x.Document));
30+
31+
ChangeTrackers.RemoveAll(x => x.Document is T t && documentStorage.IdentityFor(entity).Equals(documentStorage.IdentityFor(t)));
3132
}
3233

3334
public void Delete<T>(int id) where T : notnull

src/DocumentDbTests/SessionMechanics/reset_all_data_usage_ihost.cs renamed to src/StressTests/reset_all_data_usage_ihost.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
using System.Threading;
12
using System.Threading.Tasks;
23
using Marten;
4+
using Marten.Schema;
5+
using Marten.Testing.Documents;
36
using Marten.Testing.Harness;
47
using Microsoft.Extensions.Hosting;
58
using Xunit;
@@ -35,7 +38,7 @@ public async Task can_reset_all_data_on_ihost()
3538
opts.Logger(new TestOutputMartenLogger(_output));
3639
}
3740
)
38-
.InitializeWith(new reset_all_data_usage.Users());
41+
.InitializeWith(new Users());
3942
}
4043
)
4144
.StartAsync();
@@ -61,7 +64,7 @@ public async Task can_reset_all_data_on_ihost_for_specific_marten_database()
6164
opts.Logger(new TestOutputMartenLogger(_output));
6265
}
6366
)
64-
.InitializeWith(new reset_all_data_usage.Users());
67+
.InitializeWith(new Users());
6568
}
6669
)
6770
.StartAsync();
@@ -71,3 +74,17 @@ public async Task can_reset_all_data_on_ihost_for_specific_marten_database()
7174
#endregion
7275
}
7376
}
77+
78+
public class Users : IInitialData
79+
{
80+
public Task Populate(IDocumentStore store, CancellationToken cancellation)
81+
{
82+
var users = new User[]
83+
{
84+
new User { UserName = "one" }, new User { UserName = "two" }, new User { UserName = "three" },
85+
new User { UserName = "four" },
86+
};
87+
88+
return store.BulkInsertDocumentsAsync(users, cancellation: cancellation);
89+
}
90+
}

0 commit comments

Comments
 (0)