mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[AC-1682] Simplified inner queries
This commit is contained in:
@ -90,24 +90,17 @@ BEGIN
|
|||||||
target.[ReadOnly] = 0,
|
target.[ReadOnly] = 0,
|
||||||
target.[HidePasswords] = 0,
|
target.[HidePasswords] = 0,
|
||||||
target.[Manage] = 0
|
target.[Manage] = 0
|
||||||
FROM [dbo].[CollectionUser] AS target
|
FROM [dbo].[CollectionUser] AS target
|
||||||
INNER JOIN (
|
INNER JOIN [dbo].[Collection] AS C ON target.[CollectionId] = C.[Id]
|
||||||
SELECT C.[Id] AS [CollectionId], TU.[OrganizationUserId]
|
INNER JOIN #TempUsersAccessAll AS TU ON C.[OrganizationId] = TU.[OrganizationId] AND target.[OrganizationUserId] = TU.[OrganizationUserId];
|
||||||
FROM [dbo].[Collection] C
|
|
||||||
INNER JOIN #TempUsersAccessAll TU ON C.[OrganizationId] = TU.[OrganizationId]
|
|
||||||
) AS source
|
|
||||||
ON target.[CollectionId] = source.[CollectionId] AND target.[OrganizationUserId] = source.[OrganizationUserId];
|
|
||||||
|
|
||||||
-- Insert new rows into [dbo].[CollectionUser]
|
-- Insert new rows into [dbo].[CollectionUser]
|
||||||
INSERT INTO [dbo].[CollectionUser] ([CollectionId], [OrganizationUserId], [ReadOnly], [HidePasswords], [Manage])
|
INSERT INTO [dbo].[CollectionUser] ([CollectionId], [OrganizationUserId], [ReadOnly], [HidePasswords], [Manage])
|
||||||
SELECT source.[CollectionId], source.[OrganizationUserId], 0, 0, 0
|
SELECT C.[Id] AS [CollectionId], TU.[OrganizationUserId], 0, 0, 0
|
||||||
FROM (
|
FROM [dbo].[Collection] C
|
||||||
SELECT C.[Id] AS [CollectionId], TU.[OrganizationUserId]
|
INNER JOIN #TempUsersAccessAll TU ON C.[OrganizationId] = TU.[OrganizationId]
|
||||||
FROM [dbo].[Collection] C
|
LEFT JOIN [dbo].[CollectionUser] target
|
||||||
INNER JOIN #TempUsersAccessAll TU ON C.[OrganizationId] = TU.[OrganizationId]
|
ON target.[CollectionId] = C.[Id] AND target.[OrganizationUserId] = TU.[OrganizationUserId]
|
||||||
) AS source
|
|
||||||
LEFT JOIN [dbo].[CollectionUser] AS target
|
|
||||||
ON target.[CollectionId] = source.[CollectionId] AND target.[OrganizationUserId] = source.[OrganizationUserId]
|
|
||||||
WHERE target.[CollectionId] IS NULL;
|
WHERE target.[CollectionId] IS NULL;
|
||||||
|
|
||||||
-- Update OrganizationUser to clear AccessAll flag
|
-- Update OrganizationUser to clear AccessAll flag
|
||||||
|
Reference in New Issue
Block a user