TylerBrinks / SqlParser-cs

A Friendly SQL Parser for .NET
MIT License
102 stars 19 forks source link

MS SQL Server Create table statement parsing error #16

Open shilohooo opened 5 months ago

shilohooo commented 5 months ago

Env

Code

using SqlParser;
using SqlParser.Dialects;

const string sql = """
                   create table T_Users(
                       id bigint primary key identity ,
                       username varchar(255) not null
                   );
                   """;

var ast = new Parser().ParseSql(sql, new MsSqlDialect());

Result

Unhandled exception. SqlParser.ParserException: Expected ',' or ')' after column definition, found identity, Line: 2, Col: 27
   at SqlParser.Parser.ThrowExpected(String expected, Token actual)
   at SqlParser.Parser.ParseColumns()
   at SqlParser.Parser.ParseCreateTable(Boolean orReplace, Boolean temporary, Nullable`1 global, Boolean transient)
   at SqlParser.Parser.ParseCreate()
   at SqlParser.Parser.ParseKeywordStatement(Word word)
   at SqlParser.Parser.ParseStatement()
   at SqlParser.Parser.ParseStatements()
   at SqlParser.Parser.ParseSql(ReadOnlySpan`1 sql, Dialect dialect, ParserOptions options)
   at Program.<Main>$(String[] args) in C:\Users\shiloh\code\csharp\learn-csharp\SqlParserDemo\SqlParserDemo\Program.cs:line 12

Process finished with exit code -532,462,766.

Please tell me what went wrong, thanks:)

TylerBrinks commented 5 months ago

This appears to be a bug in the Rust implementation as well. I've files a defect with the Rust implementation which will be picked up here as well.

shilohooo commented 5 months ago

Ok:)