Skip to content

Invalid OVER clause parses successfully #195

@clement911

Description

@clement911

Example:

        var parser = new TSql170Parser(true, SqlEngineType.SqlAzure);
        var scalarExpr = parser.ParseExpression(new StringReader("COUNT(*) OVER([col])"), out var errors);
        Assert.IsTrue(errors.Count == 0 && scalarExpr != null);

        var gen = new Sql170ScriptGenerator(new SqlScriptGeneratorOptions
        {
            SqlEngineType = SqlEngineType.SqlAzure,
            SqlVersion = SqlVersion.Sql170
        });
        gen.GenerateScript(scalarExpr, out string formattedSql);
        Assert.IsTrue(formattedSql == "COUNT(*) OVER [col]");

Notice that the OVER clause is invalid as it should be contain a PARTITION or ORDER BY clause, not just a column.
In addition, when the script is formatted with the scriptgenerator, the parens are removed altoghter, which creates an unparsable result.

UPDATE: this was verified with version 170.191.0, which is the latest stable release as of today

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions