You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following CREATE TABLE statement parses just fine:
import sqlglot
test = """CREATE TABLE dbo.test (
id INT,
name VARCHAR(50),
CONSTRAINT pk_testTable PRIMARY KEY (id)
) ;"""
parsed_script = sqlglot.parse(test, read="tsql")
However, when I add ASC or DESC to the PRIMARY KEY constraint, it fails to parse:
import sqlglot
test = """CREATE TABLE dbo.test (
id INT,
name VARCHAR(50),
CONSTRAINT pk_testTable PRIMARY KEY (id DESC)
) ;"""
parsed_script = sqlglot.parse(test, read="tsql")
Error Message:
Exception has occurred: ParseError
Expecting ). Line 4, Col: 45.
bo.test (
id INT,
name VARCHAR(50),
CONSTRAINT pk_testTable PRIMARY KEY (id �[4mDESC�[0m)
) ;
File "C:\*snip*\main.py", line 96, in main
parsed_script = sqlglot.parse(test, read="tsql")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\*snip*\main.py", line 116, in <module>
main()
sqlglot.errors.ParseError: Expecting ). Line 4, Col: 45.
bo.test (
id INT,
name VARCHAR(50),
CONSTRAINT pk_testTable PRIMARY KEY (id �[4mDESC�[0m)
) ;
The following CREATE TABLE statement parses just fine:
However, when I add ASC or DESC to the PRIMARY KEY constraint, it fails to parse:
Error Message:
Official Documentation: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-ver16#constraint
Edit: sqlglot version is 25.21.3.
The text was updated successfully, but these errors were encountered: