Find-DbaAgentJob - Only the last condition filter counts when several are given
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- powershell
- 领域
- databases
调研方向
Read the Find-DbaAgentJob command and list every place its condition filters reassign $output from $jobs instead of narrowing it; the help examples for -IsDisabled -IsNoEmailNotification -IsNotScheduled and the Get-DbaRegServer | Find-DbaAgentJob -Disabled -IsNotScheduled example need rewriting to match whichever semantics is chosen. Reproduce with the two-job lab from the issue (A disabled with a schedule, B enabled without one) and check the extra claim that [boolean]$LastUsed.ToString() never blocks a filterless call. Done means a maintainer decision on AND vs OR is recorded, all condition filters compose accordingly, help text matches, and tests cover two conditions together and with -JobName.
由索引模型根据 Issue 内容生成。
描述
What happens
Find-DbaAgentJob has seven condition filters: -Category, -IsFailed, -LastUsed, -IsDisabled, -IsNotScheduled, -IsNoEmailNotification and -Owner. Each one does $output = $jobs | Where-Object .... That starts again from all jobs (or from the jobs that -JobName, -StepName or -Pattern selected) and throws away what the filters before it found. So when several are given, only the last one in the code counts, whatever order the call uses. -ExcludeJobName and -Since filter $output and do combine.
Lab, development 895132336, SQL Server 2019, two jobs: A is disabled and has a schedule, B is enabled and has none.
| Call | Result |
|---|---|
-JobName A, B -IsDisabled |
A |
-JobName A, B -IsNotScheduled |
B |
-JobName A, B -IsDisabled -IsNotScheduled |
B |
-IsNotScheduled -IsDisabled -JobName A, B |
B |
With AND, the combined call would return nothing; with OR, it would return both jobs.
Two help examples promise OR:
-IsDisabled -IsNoEmailNotification -IsNotScheduled: "either disabled, have no email notification or don't have a schedule". It returns only the jobs without e-mail notification, because-IsNoEmailNotificationcomes last in the code.Get-DbaRegServer ... | Find-DbaAgentJob -Disabled -IsNotScheduled: "either been disabled or have no schedule". It returns only the jobs without a schedule.
#6274 fixed -JobName combined with one condition filter in 2020 (the filters start from the jobs -JobName selected), but not two condition filters together.
The question
A fix changes the result for every caller who combines these switches today, in one of two directions:
- AND: a job has to match every given filter. That is what several filter parameters usually mean in PowerShell, and what #6274 asked for with
-JobName.-IsDisabled -IsNotScheduledwould then mean "disabled and without a schedule". - OR: a job that matches any given filter is returned, as the two examples promise. This suits an audit ("show me everything that looks wrong"), but
-JobNamekeeps its AND role while the condition filters get OR, which is harder to explain.
Which one should it be? I would go with AND and rewrite the two examples. Once that is decided, the fix is a few lines plus tests.
Found on the way
begin refuses a call without any search term ("At least one search term must be specified"). But one of the terms in that check is [boolean]$LastUsed.ToString(), and that is always $true, because "0" is a non-empty string. So the check never fires: Find-DbaAgentJob -SqlInstance x with no filter at all returns every job, without a warning (lab: 3 jobs, no warning). Fixing the check would break callers who rely on this, so it might be better to document "without a filter it returns all jobs" than to make the check work. Same question: which way?
Found while fixing #10833 in #10848.
This text was created by Claude and reviewed by Andreas Jordan.
- 主要语言
- PowerShell
- 星标
- 2.9k
- 派生
- 869
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 38
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dataplat/dbatools 的其他 Issue
-
bugs life triage required
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
bugs life triage required
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
-
Invoke-DbaDbPiiScan - Fix broken PII patterns, add Nordic known names, and proposals for metadata-only scan and native classification可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
维护者通常 2 天内回复
-
bugs life triage required
难度 4/5 3-5 天 新手友好度 48/100
dataplat/dbatools#10860 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 3/5 1-2 天 新手友好度 42/100
维护者通常 2 天内回复
查看 dataplat/dbatools 的全部 Issue
相似的 Issue
-
bug vector-store
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
jxxghp/MoviePilot#7576 ·
维护者通常 1 天内回复
-
Invalid JSON options for ngram and edge_ngram silently use defaults可能已有人在做 @Tilendlesa 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 3 天内回复