Skip to content

Commit 17980b0

Browse files
PM-34130 - PR feedback resolution
1 parent b2161e5 commit 17980b0

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

src/Sql/dbo/Auth/Stored Procedures/Device_ReadActiveWithPendingAuthRequestsByUserId.sql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ BEGIN
2020
D.[Active],
2121
AR.[Id] AS [AuthRequestId],
2222
AR.[CreationDate] AS [AuthRequestCreationDate]
23-
FROM [dbo].[DeviceView] D
23+
FROM
24+
[dbo].[DeviceView] D
2425
LEFT OUTER JOIN (
2526
SELECT
2627
[Id],
2728
[CreationDate],
2829
[RequestDeviceIdentifier],
2930
[Approved],
3031
ROW_NUMBER() OVER (PARTITION BY [RequestDeviceIdentifier] ORDER BY [CreationDate] DESC) AS rn
31-
FROM [dbo].[AuthRequestView]
32-
WHERE [Type] IN (0,1) -- AuthenticateAndUnlock and Unlock types only
32+
FROM
33+
[dbo].[AuthRequestView]
34+
WHERE
35+
[Type] IN (0,1) -- AuthenticateAndUnlock and Unlock types only
3336
AND [CreationDate] >= DATEADD(MINUTE, -@ExpirationMinutes, GETUTCDATE()) -- Ensure the request hasn't expired
3437
AND [UserId] = @UserId -- Requests for this user only
3538
) AR -- This join will get the most recent request per device, regardless of approval status

util/Migrator/DbScripts/2026-04-07_00_Alter_Device_ReadActiveWithPendingAuthRequestsByUserId.sql

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
-- PM-34130: Replace SELECT D.* with an explicit column list.
2-
-- Previously, Dapper mapped results by column position into a 14-parameter constructor.
3-
-- A column addition, removal, or reorder in DeviceView would silently assign wrong values
4-
-- with no compile or runtime error. Explicit columns enable name-based mapping via property
5-
-- setters, eliminating the positional dependency and restoring EDD backwards compatibility.
2+
-- Previously, Dapper selected the 14-parameter constructor and mapped columns
3+
-- positionally. A column addition, removal, or reorder in DeviceView would
4+
-- silently assign wrong values with no compile or runtime error.
5+
-- DeviceAuthDetails now has a parameterless constructor, so Dapper maps by
6+
-- property name instead. The explicit column list documents intent and prevents
7+
-- unexpected columns from DeviceView leaking into the result.
68
CREATE OR ALTER PROCEDURE [dbo].[Device_ReadActiveWithPendingAuthRequestsByUserId]
79
@UserId UNIQUEIDENTIFIER,
810
@ExpirationMinutes INT
@@ -25,16 +27,19 @@ BEGIN
2527
D.[Active],
2628
AR.[Id] AS [AuthRequestId],
2729
AR.[CreationDate] AS [AuthRequestCreationDate]
28-
FROM [dbo].[DeviceView] D
30+
FROM
31+
[dbo].[DeviceView] D
2932
LEFT OUTER JOIN (
3033
SELECT
3134
[Id],
3235
[CreationDate],
3336
[RequestDeviceIdentifier],
3437
[Approved],
3538
ROW_NUMBER() OVER (PARTITION BY [RequestDeviceIdentifier] ORDER BY [CreationDate] DESC) AS rn
36-
FROM [dbo].[AuthRequestView]
37-
WHERE [Type] IN (0,1) -- AuthenticateAndUnlock and Unlock types only
39+
FROM
40+
[dbo].[AuthRequestView]
41+
WHERE
42+
[Type] IN (0,1) -- AuthenticateAndUnlock and Unlock types only
3843
AND [CreationDate] >= DATEADD(MINUTE, -@ExpirationMinutes, GETUTCDATE()) -- Ensure the request hasn't expired
3944
AND [UserId] = @UserId -- Requests for this user only
4045
) AR -- This join will get the most recent request per device, regardless of approval status

0 commit comments

Comments
 (0)