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.
68CREATE 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