diff options
author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-01 22:32:58 +0200 |
---|---|---|
committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-01 22:32:58 +0200 |
commit | cd42b68188970376bc1e77473837083a4cd72226 (patch) | |
tree | 079e32068829a302a47114b1dcd3549ee8bb0ace | |
parent | 9255cbc838b1fada24b2360ec9a12e311b9ced63 (diff) | |
download | sqlparse-cd42b68188970376bc1e77473837083a4cd72226.tar.gz |
Added comments
-rw-r--r-- | sqlparse/filters.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index bc2af95..5919045 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -336,17 +336,32 @@ class ReindentFilter: self.offset -= num_offset def _process_identifierlist(self, tlist): + # 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) 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 default tokens over tlist as usual self._process_default(tlist) def _process_case(self, tlist): @@ -383,7 +398,9 @@ class ReindentFilter: self._split_statements(tlist) if kwds: self._split_kwds(tlist) - [self._process(sgroup) for sgroup in tlist.get_sublists()] + + for sgroup in tlist.get_sublists(): + self._process(sgroup) def process(self, stack, stmt): if isinstance(stmt, sql.Statement): |