Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2252 #2266

Merged
merged 17 commits into from
Aug 28, 2023
21 changes: 11 additions & 10 deletions sql/engines/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,7 @@ def explain_check(self, db_name=None, sql="", close_conn=False):
conn = self.get_connection()
cursor = conn.cursor()
if db_name:
cursor.execute(
f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ",
{"db_name": db_name},
)
conn.current_schema = db_name
if re.match(r"^explain", sql, re.I):
sql = sql
else:
Expand Down Expand Up @@ -669,10 +666,7 @@ def query(
conn = self.get_connection()
cursor = conn.cursor()
if db_name:
cursor.execute(
f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ",
{"db_name": db_name},
)
conn.current_schema = db_name
sql = sql.rstrip(";")
# 支持oralce查询SQL执行计划语句
if re.match(r"^explain", sql, re.I):
Expand Down Expand Up @@ -869,7 +863,10 @@ def execute_check(self, db_name=None, sql="", close_conn=True):
)
else:
object_name_list.add(object_name)
if result_set["rows"] > 1000:
if (
result_set["rows"] is not None
tonyhu214 marked this conversation as resolved.
Show resolved Hide resolved
and result_set["rows"] > 1000
):
result = ReviewResult(
id=line,
errlevel=1,
Expand Down Expand Up @@ -898,7 +895,10 @@ def execute_check(self, db_name=None, sql="", close_conn=True):
execute_time=0,
)
else:
if result_set["rows"] > 1000:
if (
result_set["rows"] is not None
tonyhu214 marked this conversation as resolved.
Show resolved Hide resolved
and result_set["rows"] > 1000
):
result = ReviewResult(
id=line,
errlevel=1,
Expand Down Expand Up @@ -1095,6 +1095,7 @@ def execute_workflow(self, workflow, close_conn=True):
try:
conn = self.get_connection()
cursor = conn.cursor()
conn.current_schema = workflow.db_name
# 获取执行工单时间,用于备份SQL的日志挖掘起始时间
cursor.execute(f"alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'")
cursor.execute(f"select sysdate from dual")
Expand Down
1 change: 0 additions & 1 deletion sql/utils/sql_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ def get_exec_sqlitem_list(reviewResult, db_name):
:return:
"""
list = []
list.append(SqlItem(statement=f' ALTER SESSION SET CURRENT_SCHEMA = "{db_name}" '))

for item in reviewResult:
list.append(
Expand Down
Loading