Skip to content

Commit

Permalink
[fix] issue262 adding comment and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skryzh authored and andialbrecht committed Nov 14, 2024
1 parent af6df6c commit 8eb778c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion sqlparse/filters/others.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _get_insert_token(token):
sql_hints = (T.Comment.Multiline.Hint, T.Comment.Single.Hint)
tidx, token = get_next_comment()
while token:
# skipping token remove if token is a SQL hint
# skipping token remove if token is a SQL-Hint. issue262
is_sql_hint = False
if token.ttype in sql_hints:
is_sql_hint = True
Expand Down
10 changes: 0 additions & 10 deletions tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,13 @@ def test_strip_comments_single(self):
sql = '#+ hint\nselect * from foo'
res = sqlparse.format(sql, strip_comments=True)
assert res == sql

sql = 'select --+full(u)\n--comment simple'
res = sqlparse.format(sql, strip_comments=True)
assert res == 'select --+full(u)\n'

sql = '#+ hint\nselect * from foo\n# comment simple'
res = sqlparse.format(sql, strip_comments=True)
assert res == '#+ hint\nselect * from foo\n'

# sql = ''
# res = sqlparse.format(sql, strip_comments=True)
# assert res == ''

def test_strip_comments_invalid_option(self):
sql = 'select-- foo\nfrom -- bar\nwhere'
with pytest.raises(SQLParseError):
Expand Down Expand Up @@ -110,10 +104,6 @@ def test_strip_comments_multi(self):
res = sqlparse.format(sql, strip_comments=True)
assert res == sql

sql = ''
res = sqlparse.format(sql, strip_comments=True)
assert res == ''

def test_strip_comments_preserves_linebreak(self):
sql = 'select * -- a comment\r\nfrom foo'
res = sqlparse.format(sql, strip_comments=True)
Expand Down

0 comments on commit 8eb778c

Please sign in to comment.