diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-03 07:31:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-03 07:31:50 +0000 |
commit | 1fb60a37d31eacbac62ddafde51b829522925694 (patch) | |
tree | 5c04a33630f7a2cd4cff248e965053f97ec3e4ac /tests/dialects/test_tsql.py | |
parent | Adding upstream version 11.4.1. (diff) | |
download | sqlglot-1fb60a37d31eacbac62ddafde51b829522925694.tar.xz sqlglot-1fb60a37d31eacbac62ddafde51b829522925694.zip |
Adding upstream version 11.4.5.upstream/11.4.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_tsql.py')
-rw-r--r-- | tests/dialects/test_tsql.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/dialects/test_tsql.py b/tests/dialects/test_tsql.py index 4224a1e..60867be 100644 --- a/tests/dialects/test_tsql.py +++ b/tests/dialects/test_tsql.py @@ -7,6 +7,7 @@ class TestTSQL(Validator): def test_tsql(self): self.validate_identity("SELECT CASE WHEN a > 1 THEN b END") + self.validate_identity("SELECT * FROM taxi ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY") self.validate_identity("END") self.validate_identity("@x") self.validate_identity("#x") @@ -567,15 +568,21 @@ WHERE write={"spark": "LAST_DAY(ADD_MONTHS(CURRENT_TIMESTAMP(), -1))"}, ) - def test_variables(self): - # In TSQL @, # can be used as a prefix for variables/identifiers - expr = parse_one("@x", read="tsql") - self.assertIsInstance(expr, exp.Column) - self.assertIsInstance(expr.this, exp.Identifier) - + def test_identifier_prefixes(self): expr = parse_one("#x", read="tsql") self.assertIsInstance(expr, exp.Column) self.assertIsInstance(expr.this, exp.Identifier) + self.assertEqual(expr.sql("tsql"), "#x") + + expr = parse_one("@x", read="tsql") + self.assertIsInstance(expr, exp.Parameter) + self.assertIsInstance(expr.this, exp.Var) + self.assertEqual(expr.sql("tsql"), "@x") + + table = parse_one("select * from @x", read="tsql").args["from"].expressions[0] + self.assertIsInstance(table, exp.Table) + self.assertIsInstance(table.this, exp.Parameter) + self.assertIsInstance(table.this.this, exp.Var) def test_system_time(self): self.validate_all( |