Skip to content

Commit

Permalink
修复doris表结构查询异常 (#2602)
Browse files Browse the repository at this point in the history
fix: #2589
优化MysqlEngine与doris的兼容性:
doris中,带变量的sql语句,不支持“WHERE TABLE_SCHEMA = %(db_name)s” 的写法。
  • Loading branch information
Grain-Yu authored Apr 22, 2024
1 parent 5f42514 commit 5e073aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sql/engines/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ def reset_instance_user_pwd(self, user_host: str, reset_pwd: str, **kwargs):

def get_all_columns_by_tb(self, db_name, tb_name, **kwargs):
"""获取所有字段, 返回一个ResultSet"""
db_name = self.escape_string(db_name)
tb_name = self.escape_string(tb_name)
sql = f"""SELECT
COLUMN_NAME,
COLUMN_TYPE,
Expand All @@ -460,8 +462,8 @@ def get_all_columns_by_tb(self, db_name, tb_name, **kwargs):
FROM
information_schema.COLUMNS
WHERE
TABLE_SCHEMA = %(db_name)s
AND TABLE_NAME = %(tb_name)s
TABLE_SCHEMA = '{db_name}'
AND TABLE_NAME = '{tb_name}'
ORDER BY ORDINAL_POSITION;"""
result = self.query(
db_name=db_name,
Expand Down

0 comments on commit 5e073aa

Please sign in to comment.