Files
grafana/pkg/util/xorm/table_name.go
Serge Zaitsev 047f5edae9 Chore: Add xorm.io/core into xorm (#103700)
* add xorm.io/core into xorm

* update workspace

* format imports

* update workspace
2025-04-16 08:58:50 +02:00

32 lines
733 B
Go

// Copyright 2020 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package xorm
import (
"reflect"
"github.com/grafana/grafana/pkg/util/xorm/core"
)
func getTableName(mapper core.IMapper, v reflect.Value) string {
if t, ok := v.Interface().(TableName); ok {
return t.TableName()
}
if v.Type().Implements(tpTableName) {
return v.Interface().(TableName).TableName()
}
if v.Kind() == reflect.Ptr {
v = v.Elem()
if t, ok := v.Interface().(TableName); ok {
return t.TableName()
}
if v.Type().Implements(tpTableName) {
return v.Interface().(TableName).TableName()
}
}
return mapper.Obj2Table(v.Type().Name())
}