Skip to content

Commit 27ec74b

Browse files
authored
fix(tsql)!: Properly set 'this' when parsing IDENTITY (#4719)
* fix(tsql): Properly set 'this' when parsing IDENTITY * hopefully fix the formatting error
1 parent 13eeec4 commit 27ec74b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

sqlglot/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5707,7 +5707,9 @@ def _parse_auto_increment(
57075707
increment = self._parse_bitwise()
57085708

57095709
if start and increment:
5710-
return exp.GeneratedAsIdentityColumnConstraint(start=start, increment=increment)
5710+
return exp.GeneratedAsIdentityColumnConstraint(
5711+
start=start, increment=increment, this=False
5712+
)
57115713

57125714
return exp.AutoIncrementColumnConstraint()
57135715

tests/dialects/test_tsql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ def test_ddl(self):
926926
},
927927
write={
928928
"databricks": "CREATE TABLE tbl (id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 10 INCREMENT BY 1) PRIMARY KEY)",
929+
"postgres": "CREATE TABLE tbl (id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 10 INCREMENT BY 1) PRIMARY KEY)",
929930
},
930931
)
931932
self.validate_all(

0 commit comments

Comments
 (0)