@@ -61,19 +61,6 @@ def test_strip_comments_single(self):
6161 'from foo--comment\n f'
6262 res = sqlparse .format (sql , strip_comments = True )
6363 assert res == 'select a\n from foo\n f'
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\n select * 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\n select * from foo\n # comment simple'
75- res = sqlparse .format (sql , strip_comments = True )
76- assert res == '#+ hint\n select * from foo\n '
7764
7865 def test_strip_comments_invalid_option (self ):
7966 sql = 'select-- foo\n from -- bar\n where'
@@ -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 \n from 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\n select * 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\n select * from foo\n # comment simple'
120+ res = sqlparse .format (sql , strip_comments = True )
121+ assert res == '#+ hint\n select * 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 \t where ( 1 = 2 )\n '
0 commit comments