summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorJesús Leganés Combarro "Piranna" <piranna@gmail.com>2012-03-24 18:45:12 +0100
committerJesús Leganés Combarro "Piranna" <piranna@gmail.com>2012-03-24 18:45:12 +0100
commitf0708f982a77f116243d6139249a3f202be9557c (patch)
treeaffe9d056ce4f99b15c8a7c96b33f36bc3277d54 /sqlparse
parent38b1106fed5ea75165d81c87855a1f7c1e0cd71f (diff)
downloadsqlparse-f0708f982a77f116243d6139249a3f202be9557c.tar.gz
Optimization of returned SQL code
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/filters.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py
index 83c466b..cbf6b9e 100644
--- a/sqlparse/filters.py
+++ b/sqlparse/filters.py
@@ -7,10 +7,8 @@ from os.path import abspath, join
from sqlparse import sql
from sqlparse import tokens as T
from sqlparse.engine import FilterStack
-from sqlparse.tokens import (
- Comment, Keyword, Name,
- Punctuation, String, Whitespace,
-)
+from sqlparse.tokens import (Comment, Comparison, Keyword, Name, Punctuation,
+ String, Whitespace)
class Filter(object):
@@ -76,14 +74,16 @@ class StripComments(Filter):
def StripWhitespace(stream):
- """Strip the whitespaces from a stream leaving only one between tokens"""
+ "Strip the useless whitespaces from a stream leaving only the minimal ones"
last_type = None
for token_type, value in stream:
# We got a previous token
if last_type:
+ print repr(token_type), repr(value)
if token_type in Whitespace:
- if last_type in (Whitespace, Whitespace.Newline, Punctuation):
+ print '\t', repr(token_type), repr(value)
+ if last_type in (Whitespace, Whitespace.Newline, Comparison, Punctuation):
continue
value = ' '