fix: harden module lifecycle and debug log setup

Export CurrentDialect(), return setup errors when debug logger is not
registered, and guard DestName logging when the module is uninitialized.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 17:50:31 -07:00
parent 8d697eda5b
commit 63187ee905
5 changed files with 105 additions and 5 deletions
+9 -2
View File
@@ -20,14 +20,14 @@ func DestName(destTypeStruct any, path ...string) string {
for i, p := range path {
if v.Kind() != reflect.Struct {
dbxshared.DBModule.Logger().Error("DestName: path parent is not a struct", "path", destIdent+"."+strings.Join(path[:i+1], "."))
destNameLogError("DestName: path parent is not a struct", destIdent+"."+strings.Join(path[:i+1], "."))
return ""
}
v = v.FieldByName(p)
if !v.IsValid() {
dbxshared.DBModule.Logger().Error("DestName: field does not exist", "path", destIdent+"."+strings.Join(path[:i+1], "."))
destNameLogError("DestName: field does not exist", destIdent+"."+strings.Join(path[:i+1], "."))
return ""
}
@@ -36,3 +36,10 @@ func DestName(destTypeStruct any, path ...string) string {
return destIdent
}
func destNameLogError(msg, path string) {
if dbxshared.DBModule == nil {
return
}
dbxshared.DBModule.Logger().Error(msg, "path", path)
}