Skip to content

Commit

Permalink
fix #2252 (#2266)
Browse files Browse the repository at this point in the history
* fixed #2252

fix #2252

* Update oracle.py

* Update oracle.py

* Update oracle.py

* Update sql_utils.py

* Update oracle.py

fix #2262

* Update oracle.py

* Update oracle.py

* Update sql_utils.py

* Update sql_utils.py

* Update sql_utils.py

* Update oracle.py

* Update oracle.py

* Update oracle.py

* Update oracle.py
  • Loading branch information
tonyhu214 authored Aug 28, 2023
1 parent 9d01416 commit 61f493e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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.get("rows", None)
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.get("rows", None)
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

0 comments on commit 61f493e

Please sign in to comment.