diff options
author | Andi Albrecht <albrecht.andi@gmail.com> | 2014-02-06 05:51:37 +0100 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@gmail.com> | 2014-02-06 05:51:37 +0100 |
commit | c5da90197504fcca32e569efb889aaaefeb4a6c1 (patch) | |
tree | 4678d8c4882a2b8be19cef5824d1d417eb46fa87 | |
parent | a6a4bccb5840303e134e514c9a604dd2bbb32703 (diff) | |
parent | cb4aff931dbc2027a9e504368a128d1fbbc5b1d8 (diff) | |
download | sqlparse-c5da90197504fcca32e569efb889aaaefeb4a6c1.tar.gz |
Merge pull request #127 from spigwitmer/hoarked_nested_functions
Fix Function.get_parameters() returning empty list for SQL functions tha...
-rw-r--r-- | sqlparse/sql.py | 6 | ||||
-rw-r--r-- | tests/test_parse.py | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 4664142..b8e4090 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -626,9 +626,9 @@ class Function(TokenList): for t in parenthesis.tokens: if isinstance(t, IdentifierList): return t.get_identifiers() - elif isinstance(t, Identifier): - return [t,] - elif t.ttype in T.Literal: + elif isinstance(t, Identifier) or \ + isinstance(t, Function) or \ + t.ttype in T.Literal: return [t,] return [] diff --git a/tests/test_parse.py b/tests/test_parse.py index 27da5b5..6d7f7df 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -121,6 +121,11 @@ class SQLParseTest(TestCaseBase): self.assertEqual(len(t), 1) self.assert_(t[0].ttype is T.Number.Integer) + def test_nested_function(self): + t = sqlparse.parse('foo(bar(5))')[0].tokens[0].get_parameters() + self.assertEqual(len(t), 1) + self.assert_(type(t[0]) is sqlparse.sql.Function) + def test_quoted_identifier(): t = sqlparse.parse('select x.y as "z" from foo')[0].tokens |