-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sorting problem with one operation being delete on 3.x (#1607)
- fix sorting when only one operation is a deletion - retrofit the fix on master # 1588 into 3.x * add failing test Co-authored-by: Steve Rasch <[email protected]>
- Loading branch information
1 parent
71a39ec
commit 73c6ef2
Showing
2 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
140 changes: 140 additions & 0 deletions
140
src/Marten.Testing/CoreFunctionality/document_session_sort_large_operation_bundle_Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
using System; | ||
using Marten.Testing.Harness; | ||
using Xunit; | ||
|
||
namespace Marten.Testing.CoreFunctionality | ||
{ | ||
using System.Linq.Expressions; | ||
|
||
public sealed class document_session_sort_large_operation_bundle_Tests: IntegrationContext | ||
{ | ||
public document_session_sort_large_operation_bundle_Tests(DefaultStoreFixture fixture): base(fixture) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void save_large_bundle_of_operations() | ||
{ | ||
var id1 = Guid.NewGuid(); | ||
var id2 = Guid.NewGuid(); | ||
|
||
using (var session = theStore.OpenSession()) | ||
{ | ||
session.DeleteWhere<TestModel5>(x => x.ObjectId == id1 && x.DefinitionId == 1 && x.Stage > 1); | ||
|
||
session.Patch<TestModel5>(x => x.ObjectId == id1 && x.DefinitionId == 1 && x.Stage == 1) | ||
.Set(x => x.Name, "Matrix 1"); | ||
|
||
session.DeleteWhere<TestModel6>(x => x.ObjectId == id1 && x.DefinitionId == 1 && x.Stage > 1); | ||
|
||
session.Patch<TestModel6>(x => x.ObjectId == id1 && x.DefinitionId == 1 && x.Stage == 1) | ||
.Set(x => x.Text, ""); | ||
|
||
Expression<Func<TestModel4, bool>> definitionFilter = x => x.ObjectId == id1 && x.DefinitionId == 1; | ||
session.Patch(definitionFilter).Set(x => x.Stages, 1); | ||
session.Patch(definitionFilter).Set(x => x.Bool5, false); | ||
session.Patch(definitionFilter).Set(x => x.Text, ""); | ||
session.Patch(definitionFilter).Set(x => x.Bool4, false); | ||
session.Patch(definitionFilter).Set(x => x.Mode, "Automatic"); | ||
session.Patch(definitionFilter).Set(x => x.Bool3, true); | ||
session.Patch(definitionFilter).Set(x => x.Bool1, true); | ||
session.Patch(definitionFilter).Set(x => x.Bool2, true); | ||
session.Patch(definitionFilter).Set(x => x.Fields1, "||"); | ||
session.Patch(definitionFilter).Set(x => x.Fields2, "||"); | ||
session.Patch(definitionFilter).Set(x => x.Attr, "|gwk-id|pt-id|"); | ||
|
||
session.DeleteWhere<TestModel3>(x => x.ObjectId == id1 && x.DefinitionId == 1 && x.Stage > 1); | ||
session.Patch<TestModel3>(x => x.ObjectId == id1 && x.DefinitionId == 1) | ||
.Set(x => x.Cond1, 1); | ||
session.Patch<TestModel3>(x => x.ObjectId == id1 && x.DefinitionId == 1) | ||
.Set(x => x.Cond2, 1); | ||
|
||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test2"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test3"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test4"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test5"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test6"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test7"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test8"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test9"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test10"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test11"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test12"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test13"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test14"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test15"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test16"); | ||
session.Patch<TestModel2>(Guid.NewGuid()).Set(x => x.Content, "test17"); | ||
|
||
session.DeleteWhere<TestModel1>(x => x.ObjectId == id1 && x.DefinitionId == 1 && x.Stage > 1); | ||
session.Patch<TestModel1>(x => x.ObjectId == id1 && x.DefinitionId == 1) | ||
.Set(x => x.Mode, 1); | ||
|
||
session.SaveChanges(); | ||
} | ||
} | ||
|
||
public class TestModel1 | ||
{ | ||
public Guid Id { get; set; } | ||
public Guid ObjectId { get; set; } | ||
public int DefinitionId { get; set; } | ||
public int Stage { get; set; } | ||
public int Mode { get; set; } | ||
} | ||
|
||
public class TestModel2 | ||
{ | ||
public Guid Id { get; set; } | ||
public string Content { get; set; } | ||
} | ||
|
||
public class TestModel3 | ||
{ | ||
public Guid Id { get; set; } | ||
public Guid ObjectId { get; set; } | ||
public int DefinitionId { get; set; } | ||
public int Stage { get; set; } | ||
public int Cond1 { get; set; } | ||
public int Cond2 { get; set; } | ||
} | ||
|
||
|
||
public class TestModel4 | ||
{ | ||
public Guid Id { get; set; } | ||
public Guid ObjectId { get; set; } | ||
public int DefinitionId { get; set; } | ||
public bool Bool1 { get; set; } | ||
public bool Bool2 { get; set; } | ||
public bool Bool3 { get; set; } | ||
public string Fields1 { get; set; } | ||
public string Fields2 { get; set; } | ||
public string Attr { get; set; } | ||
public bool Bool5 { get; set; } | ||
public int Stages { get; set; } | ||
public string Text { get; set; } | ||
public bool Bool4 { get; set; } | ||
public string Mode { get; set; } | ||
} | ||
|
||
public class TestModel5 | ||
{ | ||
public Guid Id { get; set; } | ||
public Guid ObjectId { get; set; } | ||
public int DefinitionId { get; set; } | ||
public string Name { get; set; } | ||
public int Stage { get; set; } | ||
} | ||
|
||
public class TestModel6 | ||
{ | ||
public Guid Id { get; set; } | ||
public Guid ObjectId { get; set; } | ||
public int DefinitionId { get; set; } | ||
public int Stage { get; set; } | ||
public string Text { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters