From 3795ab47df3af0580581ffa1b009f055b68daf6e Mon Sep 17 00:00:00 2001 From: grainyu Date: Sun, 21 Apr 2024 19:34:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddoris=E8=A1=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E6=9F=A5=E8=AF=A2=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: https://github.com/hhyo/Archery/issues/2589 优化MysqlEngine与doris的兼容性: doris中,带变量的sql语句,不支持“WHERE TABLE_SCHEMA = %(db_name)s” 的写法。 --- sql/engines/mysql.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/engines/mysql.py b/sql/engines/mysql.py index 828bfcd67b..4a5b399ec4 100644 --- a/sql/engines/mysql.py +++ b/sql/engines/mysql.py @@ -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, @@ -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,