Skip to content

Commit 08d9fe1

Browse files
committed
fix: optimize TabularDataHead i18n description processing
- 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
1 parent 79db1f3 commit 08d9fe1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sqle/driver/v2/util.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,17 @@ func ConvertProtoTabularDataToDriver(pTd *protoV2.TabularData, isI18n bool) (Tab
392392
I18nDesc: nil,
393393
}
394394
if isI18n {
395-
if _, exist := c.I18NDesc[i18nPkg.DefaultLang.String()]; !exist {
396-
// 多语言的插件 需包含 i18nPkg.DefaultLang
397-
return TabularData{}, fmt.Errorf("client TabularDataHead: %s does not support language: %s", c.Name, i18nPkg.DefaultLang.String())
395+
if len(c.I18NDesc) > 0 { // 列描述可以为空,为空时跳过
396+
if _, exist := c.I18NDesc[i18nPkg.DefaultLang.String()]; !exist {
397+
// 多语言的插件 需包含 i18nPkg.DefaultLang
398+
return TabularData{}, fmt.Errorf("client TabularDataHead: %s does not support language: %s", c.Name, i18nPkg.DefaultLang.String())
399+
}
400+
i18nDesc, err := i18nPkg.ConvertStrMap2I18nStr(c.I18NDesc)
401+
if err != nil {
402+
return TabularData{}, fmt.Errorf("TabularData: %w", err)
403+
}
404+
h.I18nDesc = i18nDesc
398405
}
399-
i18nDesc, err := i18nPkg.ConvertStrMap2I18nStr(c.I18NDesc)
400-
if err != nil {
401-
return TabularData{}, fmt.Errorf("TabularData: %w", err)
402-
}
403-
h.I18nDesc = i18nDesc
404406
} else {
405407
// 对非多语言的插件支持
406408
h.I18nDesc.SetStrInLang(i18nPkg.DefaultLang, c.Desc)

0 commit comments

Comments
 (0)