summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorAndreas Albrecht <andreas.albrecht@Admins-MacBook-Pro.local>2019-03-10 07:46:06 +0100
committerAndreas Albrecht <andreas.albrecht@Admins-MacBook-Pro.local>2019-03-10 07:46:06 +0100
commitdcf8eb2c1012d2ba7424a351e3bd063e8cf70b8e (patch)
treeaa7b1bd26be8e891baddc89c7377fddd12c03230 /sqlparse
parent6a7eb243274e1f17c0bb99d65272c4313b9ee08c (diff)
parent6c7b89cc8ddbe3159befb4616b70384bf491a29e (diff)
downloadsqlparse-dcf8eb2c1012d2ba7424a351e3bd063e8cf70b8e.tar.gz
Merge branch 'issue_425' of https://github.com/fredyw/sqlparse into fredyw-issue_425
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/filters/others.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/sqlparse/filters/others.py b/sqlparse/filters/others.py
index eeb91f1..408f5d2 100644
--- a/sqlparse/filters/others.py
+++ b/sqlparse/filters/others.py
@@ -26,6 +26,13 @@ class StripCommentsFilter(object):
if (prev_ is None or next_ is None
or prev_.is_whitespace or prev_.match(T.Punctuation, '(')
or next_.is_whitespace or next_.match(T.Punctuation, ')')):
+ # Insert a whitespace to ensure the following SQL produces
+ # a valid SQL (see #425). For example:
+ #
+ # Before: select a--comment\nfrom foo
+ # After: select a from foo
+ if prev_ is not None and next_ is None:
+ tlist.tokens.insert(tidx, sql.Token(T.Whitespace, ' '))
tlist.tokens.remove(token)
else:
tlist.tokens[tidx] = sql.Token(T.Whitespace, ' ')