Skip to content

Commit

Permalink
Duplicated fields + Select() + UseStatistics() combo. Closes GH-3274
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Jun 29, 2024
1 parent 9e23037 commit 8a6ce16
Show file tree
Hide file tree
Showing 4 changed files with 1,188 additions and 62 deletions.

This file was deleted.

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; }
}
Loading

0 comments on commit 8a6ce16

Please sign in to comment.