Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
pengkang1991 authored Nov 29, 2023
1 parent 9e729b3 commit 15fa320
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sql/engines/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ def query_check(self, db_name=None, sql=""):
result["msg"] = keyword_warning
return result

def filter_sql(sql="", limit_num=0):
sql_lower = sql.lower()
# 对查询sql增加limit限制
if re.match(r"^select", sql_lower):
if sql_lower.find(" top ") == -1:
if sql_lower.find(" distinct ") > 0:
return sql_lower.replace("distinct", "distinct top {}".format(limit_num))
return sql_lower.replace("select", "select top {}".format(limit_num))
return sql.strip()
def filter_sql(sql="", limit_num=0):
sql_lower = sql.lower()
# 对查询sql增加limit限制
if re.match(r"^select", sql_lower):
if sql_lower.find(" top ") == -1:
if sql_lower.find(" distinct ") > 0:
return sql_lower.replace("distinct", "distinct top {}".format(limit_num))
return sql_lower.replace("select", "select top {}".format(limit_num))
return sql.strip()

def query(
self,
Expand Down

0 comments on commit 15fa320

Please sign in to comment.