summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_tsql.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dialects/test_tsql.py')
-rw-r--r--tests/dialects/test_tsql.py19
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(