1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-03 16:20:19 +00:00

orm support custom multi unique / index

This commit is contained in:
slene
2013-08-22 21:19:58 +08:00
parent 02d2990576
commit 4c061feddf
4 changed files with 90 additions and 1 deletions

View File

@ -26,6 +26,38 @@ func getTableName(val reflect.Value) string {
return snakeString(ind.Type().Name())
}
func getTableIndex(val reflect.Value) [][]string {
fun := val.MethodByName("TableIndex")
if fun.IsValid() {
vals := fun.Call([]reflect.Value{})
if len(vals) > 0 {
val := vals[0]
if val.CanInterface() {
if d, ok := val.Interface().([][]string); ok {
return d
}
}
}
}
return nil
}
func getTableUnique(val reflect.Value) [][]string {
fun := val.MethodByName("TableUnique")
if fun.IsValid() {
vals := fun.Call([]reflect.Value{})
if len(vals) > 0 {
val := vals[0]
if val.CanInterface() {
if d, ok := val.Interface().([][]string); ok {
return d
}
}
}
}
return nil
}
func getColumnName(ft int, addrField reflect.Value, sf reflect.StructField, col string) string {
column := strings.ToLower(col)
if column == "" {