Skip to content
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

Fix boolean logic and inline docs #6874

Merged

Conversation

mwsutherland
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

Fix some boolean logic and the cmdlet name in the inline documentation

Approach

Line 119, as originally written,

if (-not $InputObject -and (-not $Schedule -or $ScheduleUid)) {

would only allow you to get past this point if you have either $InputObject or have $Schedule and not have $ScheduleUid, which makes no sense and contradicts the error message.

I believe the -not should have been outside the parentheses, as in

if (-not $InputObject -and -not ($Schedule -or $ScheduleUid)) {

but it seems more clear to use the logical equivalent

if (-not ($InputObject -or $Schedule -or $ScheduleUid)) {

to say "If you don't have at least one of these, you may not continue"

Commands to test

Neither of these should return the error "Please enter the schedule or schedule uid"

Remove-DbaAgentSchedule -SqlInstance sql1 -ScheduleUid 'bf57fa7e-7720-4936-85a0-87d279db7eb7'
Remove-DbaAgentSchedule -SqlInstance sql1 -Schedule 'schedule1'

The inline docs had the wrong cmdlet name (Remove-DbaAgentJobSchedule vs Remove-DbaAgentSchedule)

Line 119, as originally written,

if (-not $InputObject -and (-not $Schedule -or $ScheduleUid)) {

would only allow you to get past this point if you have an $InputObject or have $Schedule and not have $ScheduleUid, which makes no sense and contradicts the error message.

I believe this was intended to be written as

if (-not $InputObject -and -not ($Schedule -or $ScheduleUid)) {

but it seems more clear to use the logical equivalent

if (-not ($InputObject -or $Schedule -or $ScheduleUid)) {

to say "If you don't have one of these, you may not continue"
@potatoqualitee
Copy link
Member

Thank you so much, @mwsutherland! This looks good and changes make sense 💯

@potatoqualitee potatoqualitee merged commit aa8af68 into dataplat:development Sep 28, 2020
@mwsutherland mwsutherland deleted the Remove-DbaAgentSchedule-fix branch September 28, 2020 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants