-
-
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.
Duplicated fields + Select() + UseStatistics() combo. Closes GH-3274
- Loading branch information
1 parent
9e23037
commit 8a6ce16
Showing
4 changed files
with
1,188 additions
and
62 deletions.
There are no files selected for viewing
61 changes: 0 additions & 61 deletions
61
src/CoreTests/Bugs/Bug_3274_include_pagedlist_with_mapped_tenantid.cs
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
src/DocumentDbTests/Bugs/Bug_3274_include_pagedlist_with_mapped_tenantid.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,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Marten.Pagination; | ||
using Marten.Schema.Identity; | ||
using Marten.Testing.Harness; | ||
using Xunit; | ||
|
||
namespace DocumentDbTests.Bugs; | ||
|
||
public class Bug_3274: BugIntegrationContext | ||
{ | ||
[Fact] | ||
public async Task multi_tenant_query_with_include_should_work() | ||
{ | ||
StoreOptions(opts => | ||
{ | ||
opts.Policies.AllDocumentsAreMultiTenanted(); | ||
opts.Schema | ||
.For<User3274>() | ||
.Metadata(a => a.TenantId.MapTo(x => x.TenantId)); | ||
opts.Schema.For<UserState3274>(); | ||
}); | ||
|
||
var newUser = new User3274() | ||
{ | ||
Id = CombGuidIdGeneration.NewGuid(), | ||
Name = "Alex" | ||
}; | ||
var newDoc = new UserState3274(newUser.Id, "TestState"); | ||
|
||
var session = theStore.LightweightSession("tenant1"); | ||
session.Store(newUser); | ||
session.Store(newDoc); | ||
await session.SaveChangesAsync(); | ||
|
||
var userDict = new Dictionary<Guid, UserState3274>(); | ||
|
||
var document = await session | ||
.Query<User3274>() | ||
.Include(x => x.Id, userDict) | ||
.Where(a => a.Id == newUser.Id) | ||
.ToPagedListAsync(1, 10); | ||
|
||
|
||
Assert.Single(document); | ||
Assert.Single(userDict); | ||
|
||
Assert.Equal(document.Single().Id, userDict.Single().Key); | ||
} | ||
|
||
|
||
} | ||
|
||
public record UserState3274(Guid Id, string State); | ||
public class User3274 | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public string TenantId { get; set; } | ||
} |
Oops, something went wrong.