From d719a142047f3378843129b5bdac75ac94cd2d6c Mon Sep 17 00:00:00 2001 From: Nick Wang Date: Wed, 23 Nov 2022 21:08:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmongo=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E4=B8=8Emethod=E5=8F=96=E5=80=BC=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#1973)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 小圈圈 --- sql/engines/mongo.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sql/engines/mongo.py b/sql/engines/mongo.py index 3704db4084..08bcef05df 100644 --- a/sql/engines/mongo.py +++ b/sql/engines/mongo.py @@ -533,7 +533,7 @@ def execute_check(self, db_name=None, sql=""): "renameCollection", ] pattern = re.compile( - r"""^db\.createCollection\(([\s\S]*)\)$|^db\.([\w\.-]+)\.(?:[A-Za-z]+)(?:\([\s\S]*\)$)|^db\.getCollection\((?:\s*)(?:'|")([\w-]*)('|")(\s*)\)\.([A-Za-z]+)(\([\s\S]*\)$)""" + r"""^db\.createCollection\(([\s\S]*)\)$|^db\.([\w\.-]+)\.(?:[A-Za-z]+)(?:\([\s\S]*\)$)|^db\.getCollection\((?:\s*)(?:'|")([\w\.-]+)('|")(\s*)\)\.([A-Za-z]+)(\([\s\S]*\)$)""" ) m = pattern.match(check_sql) if ( @@ -571,10 +571,8 @@ def execute_check(self, db_name=None, sql=""): check_result.rows += [result] continue else: - # method = sql_str.split('.')[2] - # methodStr = method.split('(')[0].strip() methodStr = ( - sql_str.split("(")[0].split(".")[-1].strip() + sql_str.split(".")[-1].split("(")[0].strip() ) # 最后一个.和括号(之间的字符串作为方法 if methodStr in is_exist_premise_method and not is_in: check_result.error = "文档不存在"