Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsql: "IDENTITY(1,1) NOT FOR REPLICATION NOT NULL," parse issue on FOR #2107

Closed
dmoore247 opened this issue Aug 23, 2023 · 1 comment
Closed

Comments

@dmoore247
Copy link
Contributor

dmoore247 commented Aug 23, 2023

For tsql:

CREATE TABLE [dbo].[mytable](
	[id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
	[mycolumn] [varchar](500) NULL
 CONSTRAINT [PK__mytable_1] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, 
       ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

we receive parse error on the FOR

ParseError: Required keyword: 'kind' missing for . Line 3, Col: 33.
  
CREATE TABLE [dbo].[mytable](
	[id] [int] IDENTITY(1,1) NOT �[4mFOR�[0m REPLICATION NOT NULL,
	[mycolumn] [varchar](500) NULL
 CONSTRAINT [PK__mytable_1] PRIMARY KEY CLUST

Fully reproducible code snippet

tsql6 = """
CREATE TABLE [dbo].[mytable](
	[id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
	[mycolumn] [varchar](500) NULL
 CONSTRAINT [PK__mytable_1] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
"""
sqlglot.parse(sql=tsql6, read="tsql")

Official Documentation
image

Please include links to official SQL documentation related to your issue.
I can't find the official MSFT documentation, but it is called out 100's of times in an exact search (IDENTITY(1,1) NOT FOR REPLICATION NOT NULL) and called out in official blog:

@tobymao
Copy link
Owner

tobymao commented Aug 23, 2023

@dmoore247 now that you have a couple examples of these, please make PRs in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants