Skip to content

TSQLStatementReader.ParseStatements throws Object reference not set to an instance of an object. exception #93

Description

@bruce-dunwiddie

Discussed in #92

Originally posted by muneeebsheikh June 3, 2022

I am trying to parse this select statement

SELECT system_user

but the method TSQLStatementReader.ParseStatements() throws

Object reference not set to an instance of an object.

stack trace

at TSQL.Elements.Parsers.TSQLSelectColumnParser.Parse(ITSQLTokenizer tokenizer)
at TSQL.Clauses.Parsers.TSQLSelectClauseParser.Parse(ITSQLTokenizer tokenizer)
at TSQL.Statements.Parsers.TSQLSelectStatementParser.Parse()
at TSQL.Statements.Parsers.TSQLSelectStatementParser.TSQL.Statements.Parsers.ITSQLStatementParser.Parse()
at TSQL.TSQLStatementReader.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TSQL.TSQLStatementReader.ParseStatements(String tsqlText, Boolean useQuotedIdentifiers, Boolean includeWhitespace)
at Testing.App.SQLMethods.ParseSQLStatements(String sqlText) in D:\Testing.App\Testing.App\SQLMethods.cs:line 72

Kindly help me out if I am missing something or that's the expected behavior. This is how I'm doing:

string sqlText = @"SELECT system_user;";

var statements = TSQLStatementReader.ParseStatements(sqlText);

I am using nuget package version: 2.1.0

interestingly if I change the select statement to this

SELECT system_user from tbl;

I just added a FROM clause and it works, it gives me the statement and tokens.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions