Skip to content

Commit

Permalink
Get-DbaUserPermission - Fix collation conflict (#8367)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudioESSilva authored May 24, 2022
1 parent 552a6ae commit 277ea60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/stig.sql
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ USE tempdb;
P.[Source View]
FROM
STIG.database_permissions P
INNER JOIN Targets T ON T.[Principal] = P.[Grantee]
INNER JOIN Targets T ON T.[Principal] COLLATE DATABASE_DEFAULT = P.[Grantee] COLLATE DATABASE_DEFAULT
ORDER BY
P.[Securable Type or Class],
P.[Schema/Owner],
Expand Down
17 changes: 17 additions & 0 deletions tests/Get-DbaUserPermission.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,21 @@ exec sp_addrolemember 'userrole','bob';
}
}
}

Context "Command do not return error when database as different collation" {
$dbName = "dbatoolsci_UserPermissionDiffCollation"
$dbCollation = "Latin1_General_CI_AI"

$null = New-DbaDatabase -SqlInstance $script:instance1 -Name $dbName -Collation $dbCollation

$results = Get-DbaUserPermission -SqlInstance $script:instance1 -Database $dbName -WarningVariable warnvar
It "Should not warn about collation conflict" {
$warnvar | Should -Be $null
}
It "returns results" {
$results.Count -gt 0 | Should Be $true
}

$null = Remove-DbaDatabase -SqlInstance $script:instance1 -Database $dbName -Confirm:$false
}
}

0 comments on commit 277ea60

Please sign in to comment.