Skip to content

Commit

Permalink
移除查询中对+的限制 fix #1145
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Jan 23, 2022
1 parent 4c5f5c5 commit fb84fd1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 15 deletions.
3 changes: 0 additions & 3 deletions sql/engines/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ def query_check(self, db_name=None, sql=''):
if re.search(star_patter, sql_lower) is not None:
keyword_warning += '禁止使用 * 关键词\n'
result['has_star'] = True
if '+' in sql_lower:
keyword_warning += '禁止使用 + 关键词\n'
result['bad_query'] = True
for keyword in banned_keywords:
pattern = r"(^|,| |=){}( |\(|$)".format(keyword)
if re.search(pattern, sql_lower) is not None:
Expand Down
3 changes: 0 additions & 3 deletions sql/engines/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ def query_check(self, db_name=None, sql=''):
if re.search(star_patter, sql_lower) is not None:
keyword_warning += '禁止使用 * 关键词\n'
result['has_star'] = True
if '+' in sql_lower:
keyword_warning += '禁止使用 + 关键词\n'
result['bad_query'] = True
if result.get('bad_query') or result.get('has_star'):
result['msg'] = keyword_warning
return result
Expand Down
9 changes: 0 additions & 9 deletions sql/engines/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,15 +1384,6 @@ def test_query_check_IndexError(self):
self.assertDictEqual(check_result,
{'msg': '没有有效的SQL语句', 'bad_query': True, 'filtered_sql': sql.strip(), 'has_star': False})

@patch('sql.engines.oracle.OracleEngine.explain_check', return_value={'msg': '', 'rows': 0})
def test_query_check_plus(self, _explain_check):
sql = "select 100+1 from tb;"
new_engine = OracleEngine(instance=self.ins)
check_result = new_engine.query_check(db_name='archery', sql=sql)
self.assertDictEqual(check_result,
{'msg': '禁止使用 + 关键词\n', 'bad_query': True, 'filtered_sql': sql.strip(';'),
'has_star': False})

def test_filter_sql_with_delimiter(self):
sql = "select * from xx;"
new_engine = OracleEngine(instance=self.ins)
Expand Down

0 comments on commit fb84fd1

Please sign in to comment.