mirror of
https://github.com/bitwarden/server.git
synced 2025-07-17 07:30:59 -05:00
SelectionReadOnly MERGE to CollectionGroup
This commit is contained in:
@ -193,5 +193,6 @@
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_ReadGroupIdsByOrganizationUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_UpdateGroups.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_Delete.sql" />
|
||||
<Build Include="dbo\User Defined Types\SelectionReadOnlyArray.sql" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -5,7 +5,7 @@
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@CollectionIds AS [dbo].[GuidIdArray] READONLY
|
||||
@Collections AS [dbo].[SelectionReadOnlyArray] READONLY
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
@ -29,9 +29,9 @@ BEGIN
|
||||
SELECT
|
||||
[Id],
|
||||
@Id,
|
||||
0
|
||||
[ReadOnly]
|
||||
FROM
|
||||
@CollectionIds
|
||||
@Collections
|
||||
WHERE
|
||||
[Id] IN (SELECT [Id] FROM [AvailableCollectionsCTE])
|
||||
END
|
@ -7,7 +7,8 @@ BEGIN
|
||||
EXEC [dbo].[Group_ReadById] @Id
|
||||
|
||||
SELECT
|
||||
[CollectionId]
|
||||
[CollectionId] [Id],
|
||||
[ReadOnly]
|
||||
FROM
|
||||
[dbo].[CollectionGroup]
|
||||
WHERE
|
||||
|
@ -5,7 +5,7 @@
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@CollectionIds AS [dbo].[GuidIdArray] READONLY
|
||||
@Collections AS [dbo].[SelectionReadOnlyArray] READONLY
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
@ -23,7 +23,7 @@ BEGIN
|
||||
MERGE
|
||||
[dbo].[CollectionGroup] AS [Target]
|
||||
USING
|
||||
@CollectionIds AS [Source]
|
||||
@Collections AS [Source]
|
||||
ON
|
||||
[Target].[CollectionId] = [Source].[Id]
|
||||
AND [Target].[GroupId] = @Id
|
||||
@ -33,8 +33,10 @@ BEGIN
|
||||
(
|
||||
[Source].[Id],
|
||||
@Id,
|
||||
0
|
||||
[Source].[ReadOnly]
|
||||
)
|
||||
WHEN MATCHED AND [Target].[ReadOnly] != [Source].[ReadOnly] THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly]
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[GroupId] = @Id THEN
|
||||
DELETE
|
||||
|
@ -0,0 +1,4 @@
|
||||
CREATE TYPE [dbo].[SelectionReadOnlyArray] AS TABLE (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReadOnly] BIT NOT NULL);
|
||||
|
Reference in New Issue
Block a user