Bug on Find Invalid Objects
DanAvni
Posts: 72 Bronze 2
I have the function below on a DB. the table ObjectPermissions does not exist anymore but the function does not list as an invalid object
ALTER FUNCTION [dbo].[CheckEnforceGroupPermissionsForEmployeeGUID]
(
@EmployeeGUID uniqueidentifier,
@EnforceGroupPermissionsForUserGuid uniqueidentifier
)
RETURNS bit
AS BEGIN
DECLARE @RetVal as bit
IF @EnforceGroupPermissionsForUserGuid is null
BEGIN
SET @RetVal = 1
end
ELSE
begin --running against a specific user
declare @GroupGUID uniqueidentifier
select @GroupGUID = GroupGuid
From Employees
Where Employees.Guid = @EmployeeGUID
if @GroupGUID is null
begin --no group for employee
SET @RetVal = 0
end
else
begin --employee has a group
if exists ( Select *
From ObjectPermissions
where ObjectGuid = @GroupGUID AND
UserGuid = @EnforceGroupPermissionsForUserGuid AND
ObjectType = 0 )
begin
SET @RetVal = 1
end
else
begin
SET @RetVal = 0
end
end
end
RETURN @RetVal
END
ALTER FUNCTION [dbo].[CheckEnforceGroupPermissionsForEmployeeGUID]
(
@EmployeeGUID uniqueidentifier,
@EnforceGroupPermissionsForUserGuid uniqueidentifier
)
RETURNS bit
AS BEGIN
DECLARE @RetVal as bit
IF @EnforceGroupPermissionsForUserGuid is null
BEGIN
SET @RetVal = 1
end
ELSE
begin --running against a specific user
declare @GroupGUID uniqueidentifier
select @GroupGUID = GroupGuid
From Employees
Where Employees.Guid = @EmployeeGUID
if @GroupGUID is null
begin --no group for employee
SET @RetVal = 0
end
else
begin --employee has a group
if exists ( Select *
From ObjectPermissions
where ObjectGuid = @GroupGUID AND
UserGuid = @EnforceGroupPermissionsForUserGuid AND
ObjectType = 0 )
begin
SET @RetVal = 1
end
else
begin
SET @RetVal = 0
end
end
end
RETURN @RetVal
END
Dan Avni
Comments
Thanks for your post, I can recreate this here and will look into seeing what we can do about fixing it.
Thanks,
Aaron.
We think we've got a fix for you, could you please give this private build a try and let us know if the function is correctly detected as invalid?
Thanks,
Aaron.