1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-28 13:15:12 +01:00

[PM-1191] collections cannot be managed in family organization (#2765)

* [PM-1191] fix: use join instead of select-subquery

EF6 is currently not able to translate LINQ that include selects after groupby statements. Using join let's us bypass this issue.

* [PM-1191] chore: simplify queries

* Revert "[PM-1191] chore: simplify queries"

This reverts commit f57443d8c4.
This commit is contained in:
Andreas Coroiu 2023-03-07 14:35:39 +01:00 committed by GitHub
parent 5e3f4c9bbe
commit 2c9df6d1ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -186,13 +186,13 @@ public class CollectionRepository : Repository<Core.Entities.Collection, Collect
{ {
var dbContext = GetDatabaseContext(scope); var dbContext = GetDatabaseContext(scope);
var groups = var groups =
from cg in dbContext.CollectionGroups from c in collections
where cg.Collection.OrganizationId == organizationId join cg in dbContext.CollectionGroups on c.Id equals cg.CollectionId
group cg by cg.CollectionId into g group cg by cg.CollectionId into g
select g; select g;
var users = var users =
from cu in dbContext.CollectionUsers from c in collections
where cu.Collection.OrganizationId == organizationId join cu in dbContext.CollectionUsers on c.Id equals cu.CollectionId
group cu by cu.CollectionId into u group cu by cu.CollectionId into u
select u; select u;
@ -230,19 +230,16 @@ public class CollectionRepository : Repository<Core.Entities.Collection, Collect
{ {
var dbContext = GetDatabaseContext(scope); var dbContext = GetDatabaseContext(scope);
var groups = var groups =
from cg in dbContext.CollectionGroups from c in collections
where cg.Collection.OrganizationId == organizationId join cg in dbContext.CollectionGroups on c.Id equals cg.CollectionId
&& collections.Select(c => c.Id).Contains(cg.Collection.Id)
group cg by cg.CollectionId into g group cg by cg.CollectionId into g
select g; select g;
var users = var users =
from cu in dbContext.CollectionUsers from c in collections
where cu.Collection.OrganizationId == organizationId join cu in dbContext.CollectionUsers on c.Id equals cu.CollectionId
&& collections.Select(c => c.Id).Contains(cu.Collection.Id)
group cu by cu.CollectionId into u group cu by cu.CollectionId into u
select u; select u;
return collections.Select(collection => return collections.Select(collection =>
new Tuple<Core.Entities.Collection, CollectionAccessDetails>( new Tuple<Core.Entities.Collection, CollectionAccessDetails>(
collection, collection,