microsoft / microsoft/sqlmanagementobjects

API to parse/split GO statements into batches

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

还没有人认领这个 Issue。

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

描述

Per comment on another issue I am opening this to ask for an API in similar effect to this wrapped function:

/// <summary>
/// Split/Parse a TSQL string into batches by the "GO" statement.
/// Mirrors SQL Management Studio's parsing (because it is the same)
/// </summary>
public static List<string> ParseSQLBatches(string tsql)
{
    var batchParser = new Microsoft.SqlServer.Management.Common.ExecuteBatch();
    var ret = batchParser.GetStatements(tsql);
    return ret.Cast<string>().ToList();
}

The reasoning behind this is that we have scripts written by us for schema/data migrations that commonly utilize GO statements in many ways. We can't easily rely on a simplified "Split on bare GO statements outside of comments" due to sometimes having GO 20 or other such fun things, or multi-line strings etc that might have GO in them for unrelated reasons. Although we could write a parser, that SMO provided one that out of the box (as far as we noticed) was identical to SSMS's was very convenient for us. It seems that this exposed class/api that we were relying on was an implementation detail/surface that is going away in an upcoming release. So the ask here is to facilitate at least this minimal API of "given TSQL string, here it is split-and-duplicated-etc into individual batches".

贡献指南

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

从这里开始

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

调研方向

首先查看 issue 中描述的 Microsoft.SqlServer.Management.Common.ExecuteBatch 和 GetStatements 的现有用法,以及 issue 4 中链接的讨论。定义用于将 T-SQL 拆分为批处理的受支持公共 API,包括 GO 20、注释和多行字符串,然后验证其结果是否符合预期的 SQL Management Studio 行为。

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

评估

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

把新 issue 发到你的邮箱

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