DacFx icon indicating copy to clipboard operation
DacFx copied to clipboard

SqlScriptGenerator does not account for BinaryQueryExpressions

Open richardgavel opened this issue 3 years ago • 2 comments

When I parse a query which has a UNION statement, I get a SelectStatement with a QueryExpression that is a BinaryQueryExpression. However, when I try to use the SqlScriptGenerator to regenerate the SQL from the object tree, it stops at the FirstExpression + BinaryQueryExpressionType.

eg. => SELECT x FROM FOO UNION SELECT x FROM BAR turns into SELECT x FROM FOO UNION

richardgavel avatar Dec 30 '21 20:12 richardgavel

@richardgavel can you please add more info? Are you using sqlpackage.exe or DacFx framework?

llali avatar Mar 21 '22 15:03 llali

DacFx framework, This is basically the result of sql -> syntax tree -> sql

string sql = "...";
var parser = new TSql150Parser(true, SqlEngineType.All);
var tree = parser.Parse(new StringReader(sql), out _);

var generator = new Sql150ScriptGenerator();
generator.GenerateScript(tree, out string script);

sql: Has the second part of the union script: Missing the second part of the union.

richardgavel avatar Mar 21 '22 16:03 richardgavel