microsoft / microsoft/sqlmanagementobjects
Using .Databases with a misspelled database name changes database name in SMO
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 143
- 派生
- 28
- PR 合并指标
- 30 天内没有已合并 PR
描述
This bug was found using dbatools: https://github.com/dataplat/dbatools/issues/8598
There are two ways to select a single database from the list of databases from a Microsoft.SqlServer.Management.Smo.Server object: $server.Databases | Where-Object Name -EQ <dbname> and $server['<dbname>'].
The first one works without problems. But the second one changes the casing of the name from the original one to the one used to query the database.
Here is the code to show that:
Import-Module -Name dbatools
# correct:
$server = [Microsoft.SqlServer.Management.Smo.Server]::new('sql01')
$server.Databases | Where-Object Name -EQ Master | Select-Object -ExpandProperty Name
$server.Databases['Master'] | Select-Object -ExpandProperty Name
# wrong:
$server = [Microsoft.SqlServer.Management.Smo.Server]::new('sql01')
$server.Databases['Master'] | Select-Object -ExpandProperty Name
$server.Databases | Where-Object Name -EQ Master | Select-Object -ExpandProperty Name
And here is a screenshot:

Yes, I'm using not the current version - but I don't have the current version at hand. But I think it will take you only minutes to test this in your test environment. If it is fixed with the current version: Sorry to bother you.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用 Server.Databases 及其字符串索引器,通过 PowerShell 示例复现该行为。然后跟踪 Databases 集合查找背后的实现,并为大小写不同或拼写错误的查询添加回归测试覆盖。当查询数据库不再更改原始数据库名称或其大小写时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, powershell
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100