From 691c0400e5a7d8229b7dce09bf47176539add328 Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Thu, 14 May 2009 22:17:34 +0200 Subject: Fixed grouping of semicolons within assignments. --- sqlparse/engine/grouping.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sqlparse/engine') diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 181dae4..471116e 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -29,8 +29,12 @@ def _group_left_right(tlist, ttype, value, cls, ttype, value) else: if include_semicolon: - right = tlist.token_next_match(tlist.token_index(right), - T.Punctuation, ';') + sright = tlist.token_next_match(tlist.token_index(right), + T.Punctuation, ';') + if sright is not None: + # only overwrite "right" if a semicolon is actually + # present. + right = sright tokens = tlist.tokens_between(left, right)[1:] if not isinstance(left, cls): new = cls([left]) -- cgit v1.2.1