Skip to content

CAST function parameter fragment is incorrectly calculated during parsing #224

Description

@SShetgaonkar

Version - 180.78.1

Parser - TSql180Parser and TSql170Parser

Issue Description : When the fragment for the parameter in CAST function is calculated it consist only the "'Test'" part and does not contain the "AS VARCHAR(20)" section.

Steps to reproduce -

Try parsing the below SQL script with the parser:

SELECT CAST('TEST' AS VARCHAR(20))

Example -

using Microsoft.SqlServer.TransactSql.ScriptDom;

internal class Program
{
    static void Main(string[] args)
    {
        var script = "Example Script";
        var parser = new TSql180Parser(true);
        var fragment = parser.Parse(new StringReader(script), out var parseErrors);

        if (parseErrors.Count > 0)
        {
            foreach(var parseError in parseErrors)
                Console.WriteLine(parseError.Message);
        }
        else
        {
            Console.WriteLine("Parsed successfully");
        }
    }
}

Actual Output - Parameter fragment given by the parser - 'TEST'
Expected Output - Parameter fragment - 'TEST' AS VARCHAR(20)

Metadata

Metadata

Assignees

No one assigned

    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