Skip to content

Commit 2f9c7ec

Browse files
skryzhandialbrecht
authored andcommitted
[feature] deleting envs from .gitignore, creating test for SQL-Hints
1 parent 8eb778c commit 2f9c7ec

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ MANIFEST
88
*.egg-info/
99
htmlcov/
1010
.pytest_cache
11-
**/.vscode
12-
**/.env

sqlparse/filters/others.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _get_insert_token(token):
4747
if is_sql_hint:
4848
# using current index as start index to search next token for
4949
# preventing infinite loop in cases when token type is a
50-
# "SQL-Hint"and has to be skipped
50+
# "SQL-Hint" and has to be skipped
5151
tidx, token = get_next_comment(idx=tidx)
5252
continue
5353

@@ -70,7 +70,7 @@ def _get_insert_token(token):
7070

7171
# using current index as start index to search next token for
7272
# preventing infinite loop in cases when token type is a
73-
# "SQL-Hint"and has to be skipped
73+
# "SQL-Hint" and has to be skipped
7474
tidx, token = get_next_comment(idx=tidx)
7575

7676
def process(self, stmt):

tests/test_format.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,6 @@ def test_strip_comments_single(self):
6161
'from foo--comment\nf'
6262
res = sqlparse.format(sql, strip_comments=True)
6363
assert res == 'select a\nfrom foo\nf'
64-
# SQL-Hints have to be preserved
65-
sql = 'select --+full(u)'
66-
res = sqlparse.format(sql, strip_comments=True)
67-
assert res == sql
68-
sql = '#+ hint\nselect * from foo'
69-
res = sqlparse.format(sql, strip_comments=True)
70-
assert res == sql
71-
sql = 'select --+full(u)\n--comment simple'
72-
res = sqlparse.format(sql, strip_comments=True)
73-
assert res == 'select --+full(u)\n'
74-
sql = '#+ hint\nselect * from foo\n# comment simple'
75-
res = sqlparse.format(sql, strip_comments=True)
76-
assert res == '#+ hint\nselect * from foo\n'
7764

7865
def test_strip_comments_invalid_option(self):
7966
sql = 'select-- foo\nfrom -- bar\nwhere'
@@ -96,13 +83,6 @@ def test_strip_comments_multi(self):
9683
sql = 'select (/* sql /* starts here */ select 2)'
9784
res = sqlparse.format(sql, strip_comments=True, strip_whitespace=True)
9885
assert res == 'select (select 2)'
99-
# SQL-Hints have to be preserved
100-
sql = 'SELECT /*+cluster(T)*/* FROM T_EEE T where A >:1'
101-
res = sqlparse.format(sql, strip_comments=True)
102-
assert res == sql
103-
sql = 'insert /*+ DIRECT */ into sch.table_name as select * from foo'
104-
res = sqlparse.format(sql, strip_comments=True)
105-
assert res == sql
10686

10787
def test_strip_comments_preserves_linebreak(self):
10888
sql = 'select * -- a comment\r\nfrom foo'
@@ -126,6 +106,26 @@ def test_strip_comments_preserves_whitespace(self):
126106
res = sqlparse.format(sql, strip_comments=True)
127107
assert res == 'SELECT 1 AS foo'
128108

109+
def test_strip_comments_preserves_hint(self):
110+
sql = 'select --+full(u)'
111+
res = sqlparse.format(sql, strip_comments=True)
112+
assert res == sql
113+
sql = '#+ hint\nselect * from foo'
114+
res = sqlparse.format(sql, strip_comments=True)
115+
assert res == sql
116+
sql = 'select --+full(u)\n--comment simple'
117+
res = sqlparse.format(sql, strip_comments=True)
118+
assert res == 'select --+full(u)\n'
119+
sql = '#+ hint\nselect * from foo\n# comment simple'
120+
res = sqlparse.format(sql, strip_comments=True)
121+
assert res == '#+ hint\nselect * from foo\n'
122+
sql = 'SELECT /*+cluster(T)*/* FROM T_EEE T where A >:1'
123+
res = sqlparse.format(sql, strip_comments=True)
124+
assert res == sql
125+
sql = 'insert /*+ DIRECT */ into sch.table_name as select * from foo'
126+
res = sqlparse.format(sql, strip_comments=True)
127+
assert res == sql
128+
129129
def test_strip_ws(self):
130130
f = lambda sql: sqlparse.format(sql, strip_whitespace=True)
131131
s = 'select\n* from foo\n\twhere ( 1 = 2 )\n'

0 commit comments

Comments
 (0)