mirror of
https://github.com/bitwarden/server.git
synced 2026-02-01 06:33:17 +08:00
[PS-1806] Fix EF LEFT JOIN's on multiple values (#2389)
* Fix OrganizationUserOrganizationDetails * Rewrote query to be equal with SQL Server implementation * Fix OrganizationUserUserView * Rewrote query to be equal to SQL Server implementation * Formatting
This commit is contained in:
@@ -9,14 +9,14 @@ public class OrganizationUserUserDetailsViewQuery : IQuery<OrganizationUserUserD
|
||||
var query = from ou in dbContext.OrganizationUsers
|
||||
join u in dbContext.Users on ou.UserId equals u.Id into u_g
|
||||
from u in u_g.DefaultIfEmpty()
|
||||
join su in dbContext.SsoUsers on u.Id equals su.UserId into su_g
|
||||
join su in dbContext.SsoUsers on new { ou.UserId, OrganizationId = (Guid?)ou.OrganizationId } equals new { UserId = (Guid?)su.UserId, su.OrganizationId } into su_g
|
||||
from su in su_g.DefaultIfEmpty()
|
||||
select new { ou, u, su };
|
||||
return query.Select(x => new OrganizationUserUserDetails
|
||||
{
|
||||
Id = x.ou.Id,
|
||||
OrganizationId = x.ou.OrganizationId,
|
||||
UserId = x.ou.UserId,
|
||||
OrganizationId = x.ou.OrganizationId,
|
||||
Name = x.u.Name,
|
||||
Email = x.u.Email ?? x.ou.Email,
|
||||
TwoFactorProviders = x.u.TwoFactorProviders,
|
||||
@@ -28,7 +28,7 @@ public class OrganizationUserUserDetailsViewQuery : IQuery<OrganizationUserUserD
|
||||
SsoExternalId = x.su.ExternalId,
|
||||
Permissions = x.ou.Permissions,
|
||||
ResetPasswordKey = x.ou.ResetPasswordKey,
|
||||
UsesKeyConnector = x.u != null && x.u.UsesKeyConnector,
|
||||
UsesKeyConnector = x.u.UsesKeyConnector,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user