From a9d1df64bc78de418c46f58fc788c83285635720 Mon Sep 17 00:00:00 2001 From: jng Date: Thu, 31 Oct 2024 11:58:51 -0400 Subject: [PATCH] updates to CipherDetails query for accurate ViewPassword value --- .../Cipher/CipherDetails_ReadByIdUserId.sql | 37 +++++++++++++-- ...2024-10-29_00_UpdateCipherDetailsQuery.sql | 45 +++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 util/Migrator/DbScripts/2024-10-29_00_UpdateCipherDetailsQuery.sql diff --git a/src/Sql/Vault/dbo/Stored Procedures/Cipher/CipherDetails_ReadByIdUserId.sql b/src/Sql/Vault/dbo/Stored Procedures/Cipher/CipherDetails_ReadByIdUserId.sql index e2fb2629b..20eecbf3c 100644 --- a/src/Sql/Vault/dbo/Stored Procedures/Cipher/CipherDetails_ReadByIdUserId.sql +++ b/src/Sql/Vault/dbo/Stored Procedures/Cipher/CipherDetails_ReadByIdUserId.sql @@ -5,12 +5,41 @@ AS BEGIN SET NOCOUNT ON - SELECT TOP 1 - * +SELECT + [Id], + [UserId], + [OrganizationId], + [Type], + [Data], + [Attachments], + [CreationDate], + [RevisionDate], + [Favorite], + [FolderId], + [DeletedDate], + [Reprompt], + [Key], + [OrganizationUseTotp] + , MAX ([Edit]) AS [Edit] + , MAX ([ViewPassword]) AS [ViewPassword] FROM [dbo].[UserCipherDetails](@UserId) WHERE [Id] = @Id - ORDER BY - [Edit] DESC + GROUP BY + [Id], + [UserId], + [OrganizationId], + [Type], + [Data], + [Attachments], + [CreationDate], + [RevisionDate], + [Favorite], + [FolderId], + [DeletedDate], + [Reprompt], + [Key], + [OrganizationUseTotp] + END \ No newline at end of file diff --git a/util/Migrator/DbScripts/2024-10-29_00_UpdateCipherDetailsQuery.sql b/util/Migrator/DbScripts/2024-10-29_00_UpdateCipherDetailsQuery.sql new file mode 100644 index 000000000..f433d6237 --- /dev/null +++ b/util/Migrator/DbScripts/2024-10-29_00_UpdateCipherDetailsQuery.sql @@ -0,0 +1,45 @@ +CREATE OR ALTER PROCEDURE [dbo].[CipherDetails_ReadByIdUserId] + @Id UNIQUEIDENTIFIER, + @UserId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + +SELECT + [Id], + [UserId], + [OrganizationId], + [Type], + [Data], + [Attachments], + [CreationDate], + [RevisionDate], + [Favorite], + [FolderId], + [DeletedDate], + [Reprompt], + [Key], + [OrganizationUseTotp], + MAX ([Edit]) AS [Edit], + MAX ([ViewPassword]) AS [ViewPassword] +FROM + [dbo].[UserCipherDetails](@UserId) +WHERE + [Id] = @Id +GROUP BY + [Id], + [UserId], + [OrganizationId], + [Type], + [Data], + [Attachments], + [CreationDate], + [RevisionDate], + [Favorite], + [FolderId], + [DeletedDate], + [Reprompt], + [Key], + [OrganizationUseTotp] +END +GO