From b89d03804d16c064d237e26340853bf4b3ed41f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna=22?= Date: Sat, 2 Jun 2012 00:36:54 +0200 Subject: Moved check for Function --- sqlparse/filters.py | 54 +++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'sqlparse') diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 3ee2607..271bb75 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -422,32 +422,34 @@ class ReindentFilter: If there are more than an identifier, put each on a line """ - # Get identifiers from the tlist - identifiers = list(tlist.get_identifiers()) - - # Split the identifier list if we have more than one identifier - # and its not from a function - if len(identifiers) > 1 and not tlist.within(sql.Function): - # Get first token - first = list(identifiers[0].flatten())[0] - - # Increase offset the size of the first token - num_offset = self._get_offset(first) - len(first.value) - - # Increase offset and insert new lines - self.offset += num_offset - - # Insert a new line between the tokens - for token in identifiers[1:]: - tlist.insert_before(token, self.nl()) - - # Imsert another new line after comment tokens - for token in tlist.tokens: - if isinstance(token, sql.Comment): - tlist.insert_after(token, self.nl()) - - # Decrease offset the size of the first token - self.offset -= num_offset + # Split the identifier list if we are not in a function + if not tlist.within(sql.Function): + # Get identifiers from the tlist + identifiers = list(tlist.get_identifiers()) + print identifiers + + # Split the identifier list if we have more than one identifier + if len(identifiers) > 1: + # Get first token + first = list(identifiers[0].flatten())[0] + + # Increase offset the size of the first token + num_offset = self._get_offset(first) - len(first.value) + + # Increase offset and insert new lines + self.offset += num_offset + + # Insert a new line between the tokens + for token in identifiers[1:]: + tlist.insert_before(token, self.nl()) + + # Imsert another new line after comment tokens + for token in tlist.tokens: + if isinstance(token, sql.Comment): + tlist.insert_after(token, self.nl()) + + # Decrease offset the size of the first token + self.offset -= num_offset # Process the identifier list as usual self._process_default(tlist) -- cgit v1.2.1