Skip to content

fix: optimize TabularDataHead i18n description processing #3057

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

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

BugsGuru
Copy link
Collaborator

@BugsGuru BugsGuru commented Jun 12, 2025

User description

关联的 issue

https://github.com/actiontech/sqle-ee/issues/2391

描述你的变更

允许国际化的插件执行计划的列头描述字段为空

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 改进多语言列描述为空情况处理

  • 添加空判断避免不必要的错误返回

  • 优化国际化列描述转换逻辑


Changes walkthrough 📝

Relevant files
Enhancement
util.go
改进多语言列描述处理逻辑                                                                                         

sqle/driver/v2/util.go

  • 在多语言场景下判断列描述是否为空
  • 添加默认语言键存在性检查
  • 增加错误处理和国际化转换调用
+10/-8   

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • - Add a check to skip i18n processing if I18NDesc is empty
    - This change improves performance and avoids unnecessary error checking
    - Maintains existing functionality for non-empty I18NDesc maps
    @BugsGuru BugsGuru self-assigned this Jun 12, 2025
    Copy link

    PR Reviewer Guide 🔍

    🎫 Ticket compliance analysis 🔶

    2391 - Partially compliant

    Compliant requirements:

    • 多语言列描述空值的处理优化

    Non-compliant requirements:

    []

    Requires further human verification:

    []

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    边界检查

    请确认当 c.I18NDesc 为空时的处理逻辑完全符合业务预期,考虑是否需要对空值赋予一个默认值以避免后续使用 nil 导致的问题。

    if len(c.I18NDesc) > 0 { // 列描述可以为空,为空时跳过
    	if _, exist := c.I18NDesc[i18nPkg.DefaultLang.String()]; !exist {
    		// 多语言的插件 需包含 i18nPkg.DefaultLang
    		return TabularData{}, fmt.Errorf("client TabularDataHead: %s does not support language: %s", c.Name, i18nPkg.DefaultLang.String())
    	}
    	i18nDesc, err := i18nPkg.ConvertStrMap2I18nStr(c.I18NDesc)
    	if err != nil {
    		return TabularData{}, fmt.Errorf("TabularData: %w", err)
    	}
    	h.I18nDesc = i18nDesc

    Copy link

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @littleniannian littleniannian merged commit a595bff into main Jun 13, 2025
    4 checks passed
    @littleniannian littleniannian deleted the fix-i18n-plugin-explain branch June 13, 2025 08:04
    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