Sql150ScriptGenerator.GenerateScript ignores WHERE statement
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Inizia con la riproduzione usando TSql150Parser, QuerySpecification e Sql150ScriptGenerator.GenerateScript, come indicato nel corpo dell’issue. Confronta la QuerySpecification analizzata con l’output generato, quindi esegui l’esempio e verifica che la clausola WHERE venga mantenuta nell’SQL formattato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I try to format my sql script using GenerateScript method but WHERE clause is missing from its output.
Nuget version Microsoft.SqlServer.TransactSql.ScriptDom 161.9109.0.
Under debug I see parsed WHERE statement.
input and output:
ORIGINAL:
SELECT
x2_0.KeyPowerPlantUnit
,x3_0.KeyEnergyPlantTypeParent
,x2_0.KeyEnergyPlantType
,x2_0.MostRecentSequence
FROM SNLEdit_new.dbo.PowerPlantUnitFuel x2_0
LEFT JOIN Lookup.dbo.EnergyPlantType x3_0
ON x2_0.KeyEnergyPlantType = x3_0.KeyEnergyPlantType
AND x3_0.updoperation < 2
WHERE x2_0.MostRecentSequence IN (1, 2, 3, 4, 5, 6);
FORMATTED:
SELECT x2_0.KeyPowerPlantUnit,
x3_0.KeyEnergyPlantTypeParent,
x2_0.KeyEnergyPlantType,
x2_0.MostRecentSequence
FROM SNLEdit_new.dbo.PowerPlantUnitFuel AS x2_0
LEFT OUTER JOIN
Lookup.dbo.EnergyPlantType AS x3_0
ON x2_0.KeyEnergyPlantType = x3_0.KeyEnergyPlantType
AND x3_0.updoperation < 2
Code to reproduce:
using Microsoft.SqlServer.TransactSql.ScriptDom;
using System.Diagnostics;
var sql = @"
SELECT
x2_0.KeyPowerPlantUnit
,x3_0.KeyEnergyPlantTypeParent
,x2_0.KeyEnergyPlantType
,x2_0.MostRecentSequence
FROM SNLEdit_new.dbo.PowerPlantUnitFuel x2_0
LEFT JOIN Lookup.dbo.EnergyPlantType x3_0
ON x2_0.KeyEnergyPlantType = x3_0.KeyEnergyPlantType
AND x3_0.updoperation < 2
WHERE x2_0.MostRecentSequence IN (1, 2, 3, 4, 5, 6);
";
Console.WriteLine("ORIGINAL:" + sql);
var reader = new StringReader(sql);
var parser = new TSql150Parser(true);
var fragment = (TSqlScript)parser.Parse(reader, out var errors);
if (errors.Count > 0)
{
Console.WriteLine("Failed to parse SQL script:");
foreach (var error in errors)
{
Console.WriteLine(error.Message);
}
Debugger.Break();
}
var options = new SqlScriptGeneratorOptions
{
IncludeSemicolons = true,
IndentationSize = 4
};
var generator = new Sql150ScriptGenerator(options);
var statement = (SelectStatement)fragment.Batches[0].Statements[0];
var expression = (QuerySpecification)statement.QueryExpression;
generator.GenerateScript(expression, out var formattedSql);
Console.WriteLine();
Console.WriteLine("FORMATTED:" + Environment.NewLine + formattedSql);
Console.ReadLine();
- Lingua principale
- GAP
- Stelle
- 277
- Fork
- 43
- Merge medio
- 6g 17h
- PR unite (30g)
- 3
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/SqlScriptDOM
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/SqlScriptDOM#228 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/SqlScriptDOM#183 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
microsoft/SqlScriptDOM#226 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
microsoft/SqlScriptDOM#225 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
microsoft/SqlScriptDOM#224 ·
Tutte le issue di microsoft/SqlScriptDOM
Issue simili
-
Add: BuyPass TV Apertachannels:add check:passed
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
use-agent-os/agent-os#3312 ·
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
registrystack/registry-stack#1282 ·