diff options
author | spigwitmer <itgpmc@gmail.com> | 2014-02-05 08:49:15 -0800 |
---|---|---|
committer | spigwitmer <itgpmc@gmail.com> | 2014-02-05 08:49:15 -0800 |
commit | cb4aff931dbc2027a9e504368a128d1fbbc5b1d8 (patch) | |
tree | 4678d8c4882a2b8be19cef5824d1d417eb46fa87 | |
parent | a6a4bccb5840303e134e514c9a604dd2bbb32703 (diff) | |
download | sqlparse-cb4aff931dbc2027a9e504368a128d1fbbc5b1d8.tar.gz |
Fix Function.get_parameters() returning empty list for SQL functions that have a single nested function as a param
-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 |