-
-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExcludeSystemUser correct logic in Get-DbaDbUser #9415
Conversation
Actual logic: PS> (Get-DbaDbUser @Splat).Count 15 PS> (Get-DbaDbUser @Splat -ExcludeSystemUser).Count 11 PS> (Get-DbaDbUser @Splat -ExcludeSystemUser:$false).Count 11 PS> (Get-DbaDbUser @Splat -ExcludeSystemUser:$true).Count 11 # logical error here Revised logic: PS> (Get-DbaDbUser @Splat).Count 15 PS> (Get-DbaDbUser @Splat -ExcludeSystemUser).Count 11 PS> (Get-DbaDbUser @Splat -ExcludeSystemUser:$false).Count 15 PS> (Get-DbaDbUser @Splat -ExcludeSystemUser:$true).Count 11
LGTM, @andreasjordan ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Maybe we have the same problem in other commands as well.
We do. Testing the presence of a switch parameter does not provide the right logic. Here's a list of a similar pattern: PS C:\Users\me\Code\Repo\dbatools.fork.git\public> dir *.ps1|sls 'Test-Bound -ParameterName Exclude'
Get-DbaDbCheckConstraint.ps1:105: if ( (Test-Bound -ParameterName ExcludeSystemTable) -and
$tbl.IsSystemObject ) {
Get-DbaDbForeignKey.ps1:105: if ( (Test-Bound -ParameterName ExcludeSystemTable) -and
$tbl.IsSystemObject ) {
Get-DbaDbServiceBrokerQueue.ps1:92: if ( (Test-Bound -ParameterName ExcludeSystemQueue) -and
$queue.IsSystemObject ) {
Get-DbaDbServiceBrokerService.ps1:92: if ( (Test-Bound -ParameterName ExcludeSystemService) -and
$service.IsSystemObject ) {
Get-DbaDbStoredProcedure.ps1:185: if ( (Test-Bound -ParameterName ExcludeSystemSp) -and
$proc.IsSystemObject ) {
Get-DbaDbUdf.ps1:122: if (Test-Bound -ParameterName ExcludeSystemUdf) {
Get-DbaDbUser.ps1:124: if (Test-Bound -ParameterName ExcludeSystemUser) {
Get-DbaDbView.ps1:170: if (Test-Bound -ParameterName ExcludeSystemView) {
Get-DbaInstanceAudit.ps1:76: if (Test-Bound -ParameterName ExcludeAudit) {
Set-DbaMaxDop.ps1:153: } elseif ((Test-Bound -Not -ParameterName AllDatabases) -and (Test-Bound
-ParameterName ExcludeDatabase)) { I would probably send PR in the same ways for these. I mean with a testing scenario. Would that be OK? |
Sure. |
Thanks everyone! 🏆 |
Type of Change
.\tests\manual.pester.ps1
)Purpose
Correct a logical error in Get-DbaDbUser
Approach
Commands to test
Screenshots
Learning