Skip to content

Update mongo.py #2970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Update mongo.py #2970

wants to merge 7 commits into from

Conversation

huangsijun17
Copy link

@huangsijun17 huangsijun17 commented May 12, 2025

兼容高版本MongoDB Shell。

Fix: #2969

@huangsijun17
Copy link
Author

huangsijun17 commented May 12, 2025

测试脚本没装新、老版的Mongosh,能过就怪了。

Copy link
Owner

@hhyo hhyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci的对应的yaml也可以做调整装上客户端

@@ -383,6 +385,13 @@ def _build_cmd(
common_params["auth_options"] = ""
return cmd_template.format(**common_params)

def get_mongosh(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议放在init方法内

@@ -434,6 +443,7 @@ def execute_workflow(self, workflow):

def execute(self, db_name=None, sql=""):
"""mongo命令执行语句"""
self.get_mongosh()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只在execute内覆盖,会导致其他方法找不到类属性报错

@@ -479,7 +489,10 @@ def execute(self, db_name=None, sql=""):
try:
r = json.loads(r)
except Exception as e:
logger.info(str(e))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果明确是版本差异,可以通过客户端版本区分

修改返回内容解析逻辑。
在代码检查中加入mongo-shell。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants