Skip to content

Commit 47706b9

Browse files
committed
Added StripWhitespace filter
1 parent 10afc20 commit 47706b9

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

sqlparse/filters.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ def process(self, stack, stream):
7575
yield token_type, value
7676

7777

78+
def StripWhitespace(stream):
79+
"""Strip the whitespaces from a stream"""
80+
last_type = None
81+
82+
for token_type, value in stream:
83+
if last_type == None:
84+
if token_type not in Whitespace + Punctuation:
85+
yield token_type, value
86+
last_type = token_type
87+
88+
else:
89+
if token_type in Whitespace:
90+
if last_type not in Whitespace:
91+
yield token_type, ' '
92+
else:
93+
yield token_type, value
94+
95+
last_type = token_type
96+
97+
7898
class IncludeStatement(Filter):
7999
"""Filter that enable a INCLUDE statement"""
80100

0 commit comments

Comments
 (0)