Skip to content

Commit

Permalink
修复mongo正则匹配与method取值问题 (hhyo#1973)
Browse files Browse the repository at this point in the history
Co-authored-by: 小圈圈 <rtttte@qq.com>
  • Loading branch information
nick2wang and hhyo committed Nov 23, 2022
1 parent 1598bb3 commit d719a14
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions sql/engines/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 = "文档不存在"
Expand Down

0 comments on commit d719a14

Please sign in to comment.