forked from NYANDEV/forgejo
parent
2f13d31ff0
commit
284c0160c3
3 changed files with 20 additions and 16 deletions
16
vendor/github.com/go-xorm/core/column.go
generated
vendored
16
vendor/github.com/go-xorm/core/column.go
generated
vendored
|
@ -32,7 +32,6 @@ type Column struct {
|
||||||
IsDeleted bool
|
IsDeleted bool
|
||||||
IsCascade bool
|
IsCascade bool
|
||||||
IsVersion bool
|
IsVersion bool
|
||||||
fieldPath []string
|
|
||||||
DefaultIsEmpty bool
|
DefaultIsEmpty bool
|
||||||
EnumOptions map[string]int
|
EnumOptions map[string]int
|
||||||
SetOptions map[string]int
|
SetOptions map[string]int
|
||||||
|
@ -59,7 +58,6 @@ func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable
|
||||||
IsDeleted: false,
|
IsDeleted: false,
|
||||||
IsCascade: false,
|
IsCascade: false,
|
||||||
IsVersion: false,
|
IsVersion: false,
|
||||||
fieldPath: nil,
|
|
||||||
DefaultIsEmpty: false,
|
DefaultIsEmpty: false,
|
||||||
EnumOptions: make(map[string]int),
|
EnumOptions: make(map[string]int),
|
||||||
}
|
}
|
||||||
|
@ -121,12 +119,10 @@ func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) {
|
||||||
|
|
||||||
func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) {
|
func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) {
|
||||||
var fieldValue reflect.Value
|
var fieldValue reflect.Value
|
||||||
if col.fieldPath == nil {
|
fieldPath := strings.Split(col.FieldName, ".")
|
||||||
col.fieldPath = strings.Split(col.FieldName, ".")
|
|
||||||
}
|
|
||||||
|
|
||||||
if dataStruct.Type().Kind() == reflect.Map {
|
if dataStruct.Type().Kind() == reflect.Map {
|
||||||
keyValue := reflect.ValueOf(col.fieldPath[len(col.fieldPath)-1])
|
keyValue := reflect.ValueOf(fieldPath[len(fieldPath)-1])
|
||||||
fieldValue = dataStruct.MapIndex(keyValue)
|
fieldValue = dataStruct.MapIndex(keyValue)
|
||||||
return &fieldValue, nil
|
return &fieldValue, nil
|
||||||
} else if dataStruct.Type().Kind() == reflect.Interface {
|
} else if dataStruct.Type().Kind() == reflect.Interface {
|
||||||
|
@ -134,19 +130,19 @@ func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) {
|
||||||
dataStruct = &structValue
|
dataStruct = &structValue
|
||||||
}
|
}
|
||||||
|
|
||||||
level := len(col.fieldPath)
|
level := len(fieldPath)
|
||||||
fieldValue = dataStruct.FieldByName(col.fieldPath[0])
|
fieldValue = dataStruct.FieldByName(fieldPath[0])
|
||||||
for i := 0; i < level-1; i++ {
|
for i := 0; i < level-1; i++ {
|
||||||
if !fieldValue.IsValid() {
|
if !fieldValue.IsValid() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if fieldValue.Kind() == reflect.Struct {
|
if fieldValue.Kind() == reflect.Struct {
|
||||||
fieldValue = fieldValue.FieldByName(col.fieldPath[i+1])
|
fieldValue = fieldValue.FieldByName(fieldPath[i+1])
|
||||||
} else if fieldValue.Kind() == reflect.Ptr {
|
} else if fieldValue.Kind() == reflect.Ptr {
|
||||||
if fieldValue.IsNil() {
|
if fieldValue.IsNil() {
|
||||||
fieldValue.Set(reflect.New(fieldValue.Type().Elem()))
|
fieldValue.Set(reflect.New(fieldValue.Type().Elem()))
|
||||||
}
|
}
|
||||||
fieldValue = fieldValue.Elem().FieldByName(col.fieldPath[i+1])
|
fieldValue = fieldValue.Elem().FieldByName(fieldPath[i+1])
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("field %v is not valid", col.FieldName)
|
return nil, fmt.Errorf("field %v is not valid", col.FieldName)
|
||||||
}
|
}
|
||||||
|
|
8
vendor/github.com/go-xorm/xorm/engine.go
generated
vendored
8
vendor/github.com/go-xorm/xorm/engine.go
generated
vendored
|
@ -521,6 +521,14 @@ func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.D
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Hack for postgres
|
||||||
|
if string(dialect.DBType()) == core.POSTGRES && table.AutoIncrColumn() != nil {
|
||||||
|
_, err = io.WriteString(w, "SELECT setval('table_id_seq', COALESCE((SELECT MAX("+table.AutoIncrColumn().Name+") FROM "+dialect.Quote(table.Name)+"), 1), false);\n")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
12
vendor/vendor.json
vendored
12
vendor/vendor.json
vendored
|
@ -443,10 +443,10 @@
|
||||||
"revisionTime": "2016-12-14T02:05:24Z"
|
"revisionTime": "2016-12-14T02:05:24Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "T1DSQqU9e7oW0up0W55TkG4Cb7M=",
|
"checksumSHA1": "OCcksAYN5m0kc5yJF/Ba4VVHqeA=",
|
||||||
"path": "github.com/go-xorm/core",
|
"path": "github.com/go-xorm/core",
|
||||||
"revision": "60b1704516c3af6ff969d81f359cf310ad43a2e0",
|
"revision": "e9e84b6f94ace6dec682a39034de56abffb964dd",
|
||||||
"revisionTime": "2017-01-03T06:17:17Z"
|
"revisionTime": "2017-02-06T14:57:10Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "k52lEKLp8j5M+jFpe+3u+bIFpxQ=",
|
"checksumSHA1": "k52lEKLp8j5M+jFpe+3u+bIFpxQ=",
|
||||||
|
@ -455,10 +455,10 @@
|
||||||
"revisionTime": "2016-08-11T02:11:45Z"
|
"revisionTime": "2016-08-11T02:11:45Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "pbmrxOvDzdm40iRgnsS25Ig+33o=",
|
"checksumSHA1": "BGWfs63vC5cJuxhVRrj+7YJKz7A=",
|
||||||
"path": "github.com/go-xorm/xorm",
|
"path": "github.com/go-xorm/xorm",
|
||||||
"revision": "445a934d32ed0934aedf0ef99b4b7c69b22f8e58",
|
"revision": "19f6dfc2e8c069adc624ca56cf8127444159d5c1",
|
||||||
"revisionTime": "2017-01-25T11:54:21Z"
|
"revisionTime": "2017-02-10T01:55:37Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "1ft/4j5MFa7C9dPI9whL03HSUzk=",
|
"checksumSHA1": "1ft/4j5MFa7C9dPI9whL03HSUzk=",
|
||||||
|
|
Loading…
Reference in a new issue