summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_grouping.py5
-rw-r--r--tests/test_parse.py10
-rw-r--r--tests/test_regressions.py17
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py
index 0c2f108..5b87a38 100644
--- a/tests/test_grouping.py
+++ b/tests/test_grouping.py
@@ -187,6 +187,11 @@ class TestGrouping(TestCaseBase):
self.assertEqual(len(p.tokens), 1)
self.assertEqual(p.tokens[0].get_alias(), 'foo')
+ def test_alias_returns_none(self): # see issue185
+ p = sqlparse.parse('foo.bar')[0]
+ self.assertEqual(len(p.tokens), 1)
+ self.assertEqual(p.tokens[0].get_alias(), None)
+
def test_idlist_function(self): # see issue10 too
p = sqlparse.parse('foo(1) x, bar')[0]
self.assert_(isinstance(p.tokens[0], sql.IdentifierList))
diff --git a/tests/test_parse.py b/tests/test_parse.py
index c953dc2..bbe60df 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -294,3 +294,13 @@ def test_single_line_comments(sql):
assert p.tokens[-1].ttype == T.Comment.Single
+@pytest.mark.parametrize('sql', [
+ 'foo',
+ '@foo',
+ '#foo', # see issue192
+ '##foo'
+])
+def test_names_and_special_names(sql):
+ p = sqlparse.parse(sql)[0]
+ assert len(p.tokens) == 1
+ assert isinstance(p.tokens[0], sqlparse.sql.Identifier)
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
index 31fda0f..6bd198b 100644
--- a/tests/test_regressions.py
+++ b/tests/test_regressions.py
@@ -248,3 +248,20 @@ def test_null_with_as():
'FROM t1'
])
assert formatted == tformatted
+
+
+def test_issue193_splitting_function():
+ sql = """CREATE FUNCTION a(x VARCHAR(20)) RETURNS VARCHAR(20)
+BEGIN
+ DECLARE y VARCHAR(20);
+ RETURN x;
+END;
+SELECT * FROM a.b;"""
+ splitted = sqlparse.split(sql)
+ assert len(splitted) == 2
+
+
+def test_issue186_get_type():
+ sql = "-- comment\ninsert into foo"
+ p = sqlparse.parse(sql)[0]
+ assert p.get_type() == 'INSERT'