microsoft / microsoft/sqlmanagementobjects

DependencyWalker.DiscoverDependencies fails with System.ArgumentException: Item has already been added.

未关闭
#148 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
143
派生
28
PR 合并指标
30 天内没有已合并 PR

描述

We hit this when we had a few old stored procedures referring to the same dropped table with different casing for database name. I see commented out code at https://github.com/microsoft/sqlmanagementobjects/blob/main/src/Microsoft/SqlServer/Management/Smo/DependencyTree.cs#L198 that might have fixed this issue, not sure why it's been commented out though.

Microsoft.SqlServer.Management.Smo.FailedOperationException: Discover dependencies failed. 
 ---> System.ArgumentException: Item has already been added. Key in dictionary: 'Server[@Name='SERVER']/Database[@Name='database']/UnresolvedEntity[@Name='nonexisting_table' and @Schema='dbo']'  Key being added: 'Server[@Name='SERVER']/Database[@Name='DATABASE']/UnresolvedEntity[@Name='nonexisting_table' and @Schema='dbo']'
   at Microsoft.SqlServer.Management.Smo.DependencyTree..ctor(Urn[] urns, DependencyChainCollection dependencies, Boolean fParents, Server server)
   at Microsoft.SqlServer.Management.Smo.DependencyWalker.DiscoverDependencies(Urn[] urns, Boolean parents)

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 src/Microsoft/SqlServer/Management/Smo/DependencyTree.cs 第 198 行附近开始,跟踪 DependencyWalker.DiscoverDependencies,了解未解析实体是如何作为键的。使用仅数据库名称大小写不同的引用重现该故障,然后评估已注释掉的逻辑。当等效的未解析引用使用不同的大小写时,依赖项发现不再抛出异常,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, sql
领域
database
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。