microsoft / microsoft/sqlmanagementobjects
API to parse/split GO statements into batches
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 143
- Forks
- 28
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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".
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der Überprüfung der bestehenden Verwendung von Microsoft.SqlServer.Management.Common.ExecuteBatch und GetStatements, die im Issue beschrieben ist, sowie der verknüpften Diskussion in Issue 4. Definieren Sie die unterstützte öffentliche API zum Aufteilen von T-SQL in Batches, einschließlich GO 20, Kommentaren und mehrzeiligen Zeichenfolgen, und überprüfen Sie anschließend, dass ihre Ergebnisse dem erwarteten Verhalten von SQL Management Studio entsprechen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, sql
- Bereich
- api, databases
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100