Sql150ScriptGenerator.GenerateScript ignores WHERE statement
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu bằng việc tái hiện lỗi sử dụng TSql150Parser, QuerySpecification và Sql150ScriptGenerator.GenerateScript như được nêu trong nội dung issue. So sánh QuerySpecification đã được phân tích với đầu ra được tạo, sau đó chạy ví dụ và xác nhận rằng mệnh đề WHERE được giữ lại trong SQL đã được định dạng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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();
- Ngôn ngữ chính
- GAP
- Star
- 277
- Fork
- 43
- Merge trung bình
- 6 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 3
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/SqlScriptDOM
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/SqlScriptDOM#228 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
microsoft/SqlScriptDOM#183 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
microsoft/SqlScriptDOM#226 · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
microsoft/SqlScriptDOM#225 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
microsoft/SqlScriptDOM#224 ·
Tất cả issue của microsoft/SqlScriptDOM
Issue tương tự
-
Add: New Channel Pop! Đang mởchannels:add check:passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
confluentinc/dbt-confluent#160 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
AstrBotDevs/AstrBot#10205 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100