File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ Bug Fixes
55* Fix a regression for identifiers with square bracktes notation (issue153).
66
77Enhancements
8- * Improved formatting of HAVING statements.
8+ * Improve formatting of HAVING statements.
9+ * Improve parsing of inline comments (issue163).
910
1011
1112Release 0.1.14 (Nov 30, 2014)
Original file line number Diff line number Diff line change @@ -172,6 +172,8 @@ def _consume_cycle(tl, i):
172172 if next (x )(t ):
173173 yield t
174174 else :
175+ if isinstance (t , sql .Comment ) and t .is_multiline ():
176+ yield t
175177 raise StopIteration
176178
177179 def _next_token (tl , i ):
Original file line number Diff line number Diff line change @@ -559,6 +559,9 @@ class Comment(TokenList):
559559 """A comment."""
560560 __slots__ = ('value' , 'ttype' , 'tokens' )
561561
562+ def is_multiline (self ):
563+ return self .tokens and self .tokens [0 ].ttype == T .Comment .Multiline
564+
562565
563566class Where (TokenList ):
564567 """A WHERE clause."""
Original file line number Diff line number Diff line change @@ -131,6 +131,12 @@ def test_identifier_list_other(self): # issue2
131131 l = p .tokens [2 ]
132132 self .assertEqual (len (l .tokens ), 13 )
133133
134+ def test_identifier_list_with_inline_comments (self ): # issue163
135+ p = sqlparse .parse ('foo /* a comment */, bar' )[0 ]
136+ self .assert_ (isinstance (p .tokens [0 ], sql .IdentifierList ))
137+ self .assert_ (isinstance (p .tokens [0 ].tokens [0 ], sql .Identifier ))
138+ self .assert_ (isinstance (p .tokens [0 ].tokens [3 ], sql .Identifier ))
139+
134140 def test_where (self ):
135141 s = 'select * from foo where bar = 1 order by id desc'
136142 p = sqlparse .parse (s )[0 ]
You can’t perform that action at this time.
0 commit comments