File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -360,6 +360,7 @@ def group_functions(tlist):
360360 tidx , token = tlist .token_next_by (t = T .Name , idx = tidx )
361361
362362
363+ @recurse (sql .Identifier )
363364def group_order (tlist ):
364365 """Group together Identifier and Asc/Desc token"""
365366 tidx , token = tlist .token_next_by (t = T .Keyword .Order )
Original file line number Diff line number Diff line change @@ -247,6 +247,14 @@ def test_grouping_identifier_list_with_order():
247247 assert str (p .tokens [0 ].tokens [3 ]) == '2 desc'
248248
249249
250+ def test_grouping_nested_identifier_with_order ():
251+ # issue745
252+ p = sqlparse .parse ('(a desc)' )[0 ]
253+ assert isinstance (p .tokens [0 ], sql .Parenthesis )
254+ assert isinstance (p .tokens [0 ].tokens [1 ], sql .Identifier )
255+ assert str (p .tokens [0 ].tokens [1 ]) == 'a desc'
256+
257+
250258def test_grouping_where ():
251259 s = 'select * from foo where bar = 1 order by id desc'
252260 p = sqlparse .parse (s )[0 ]
You can’t perform that action at this time.
0 commit comments