diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-26 17:21:54 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-26 17:21:54 +0000 |
commit | c03ba18c491e52cc85d8aae1825dd9e0b4f75e32 (patch) | |
tree | f76d58b50900be4bfd2dc15f0ec38d1a70d8417b /sqlglot/dialects/tsql.py | |
parent | Releasing debian version 18.13.0-1. (diff) | |
download | sqlglot-c03ba18c491e52cc85d8aae1825dd9e0b4f75e32.tar.xz sqlglot-c03ba18c491e52cc85d8aae1825dd9e0b4f75e32.zip |
Merging upstream version 18.17.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/tsql.py')
-rw-r--r-- | sqlglot/dialects/tsql.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sqlglot/dialects/tsql.py b/sqlglot/dialects/tsql.py index 69adb45..867e4e4 100644 --- a/sqlglot/dialects/tsql.py +++ b/sqlglot/dialects/tsql.py @@ -8,6 +8,7 @@ from sqlglot import exp, generator, parser, tokens, transforms from sqlglot.dialects.dialect import ( Dialect, any_value_to_max_sql, + generatedasidentitycolumnconstraint_sql, max_or_greatest, min_or_least, move_insert_cte_sql, @@ -603,6 +604,7 @@ class TSQL(Dialect): exp.DataType.Type.DATETIME: "DATETIME2", exp.DataType.Type.DOUBLE: "FLOAT", exp.DataType.Type.INT: "INTEGER", + exp.DataType.Type.TEXT: "VARCHAR(MAX)", exp.DataType.Type.TIMESTAMP: "DATETIME2", exp.DataType.Type.TIMESTAMPTZ: "DATETIMEOFFSET", exp.DataType.Type.VARIANT: "SQL_VARIANT", @@ -617,6 +619,7 @@ class TSQL(Dialect): exp.CurrentDate: rename_func("GETDATE"), exp.CurrentTimestamp: rename_func("GETDATE"), exp.Extract: rename_func("DATEPART"), + exp.GeneratedAsIdentityColumnConstraint: generatedasidentitycolumnconstraint_sql, exp.GroupConcat: _string_agg_sql, exp.If: rename_func("IIF"), exp.Insert: move_insert_cte_sql, @@ -778,11 +781,3 @@ class TSQL(Dialect): this = self.sql(expression, "this") expressions = self.expressions(expression, flat=True, sep=" ") return f"CONSTRAINT {this} {expressions}" - - # https://learn.microsoft.com/en-us/answers/questions/448821/create-table-in-sql-server - def generatedasidentitycolumnconstraint_sql( - self, expression: exp.GeneratedAsIdentityColumnConstraint - ) -> str: - start = self.sql(expression, "start") or "1" - increment = self.sql(expression, "increment") or "1" - return f"IDENTITY({start}, {increment})" |