-
-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Duplicates the tenant id in a sub query when using ctid in the case o…
…f using conjoined tenancy and partition by tenant
- Loading branch information
1 parent
78395f7
commit c81a3dd
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...Tests/Partitioning/querying_against_conjoined_partitioning_with_tenant_id_and_subquery.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,58 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Marten; | ||
using Marten.Testing.Documents; | ||
using Marten.Testing.Harness; | ||
using Shouldly; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace CoreTests.Partitioning; | ||
|
||
public class querying_against_conjoined_partitioning_with_tenant_id_and_subquery : OneOffConfigurationsContext | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
|
||
public querying_against_conjoined_partitioning_with_tenant_id_and_subquery(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
[Fact] | ||
public async Task do_not_bleed_tenant_data_because_of_select_queries() | ||
{ | ||
var reds = Target.GenerateRandomData(100).ToArray(); | ||
var blues = Target.GenerateRandomData(1000).ToArray(); | ||
|
||
StoreOptions(opts => | ||
{ | ||
opts.Policies.AllDocumentsAreMultiTenantedWithPartitioning(x => | ||
{ | ||
x.ByList() | ||
.AddPartition("red", "red") | ||
.AddPartition("blue", "blue"); | ||
}); | ||
}); | ||
|
||
await theStore.BulkInsertAsync("red", reds); | ||
await theStore.BulkInsertAsync("blue", blues); | ||
|
||
using var session = theStore.LightweightSession("red"); | ||
session.Logger = new TestOutputMartenLogger(_output); | ||
|
||
var matching = await session.Query<Target>() | ||
.Where(x => x.Children.Any(c => c.Number > 8)) | ||
.OrderBy(x => x.Id) | ||
.Select(x => x.Id) | ||
.ToListAsync(); | ||
|
||
var expected = reds.Where(x => x.Children.Any(c => c.Number > 8)) | ||
.OrderBy(x => x.Id) | ||
.Select(x => x.Id) | ||
.ToList(); | ||
|
||
matching.Count.ShouldBe(expected.Count); | ||
|
||
matching.ShouldBe(expected); | ||
} | ||
} |
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
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
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