optimize: field.ReflectValueOf (#7530)
Some checks failed
tests / mysql (mysql:5.7, 1.24, ubuntu-latest) (push) Failing after 59s
tests / mysql (mysql:8, 1.23, ubuntu-latest) (push) Failing after 59s
tests / mysql (mysql:8, 1.24, ubuntu-latest) (push) Failing after 5s
tests / sqlite (1.23, ubuntu-latest) (push) Failing after 1m26s
tests / mysql (mysql:9, 1.23, ubuntu-latest) (push) Failing after 36s
tests / mysql (mysql:9, 1.24, ubuntu-latest) (push) Failing after 32s
tests / mariadb (mariadb:latest, 1.24, ubuntu-latest) (push) Failing after 9s
tests / mariadb (mariadb:latest, 1.23, ubuntu-latest) (push) Failing after 22s
tests / postgres (postgres:13, 1.23, ubuntu-latest) (push) Failing after 24s
tests / mysql (mysql:5.7, 1.23, ubuntu-latest) (push) Failing after 2m1s
tests / postgres (postgres:14, 1.23, ubuntu-latest) (push) Failing after 20s
tests / postgres (postgres:14, 1.24, ubuntu-latest) (push) Failing after 6s
tests / postgres (postgres:15, 1.24, ubuntu-latest) (push) Failing after 14s
tests / postgres (postgres:15, 1.23, ubuntu-latest) (push) Failing after 29s
tests / postgres (postgres:latest, 1.23, ubuntu-latest) (push) Failing after 26s
tests / postgres (postgres:latest, 1.24, ubuntu-latest) (push) Failing after 18s
tests / postgres (postgres:13, 1.24, ubuntu-latest) (push) Failing after 2m55s
tests / sqlite (1.24, ubuntu-latest) (push) Failing after 4m53s
tests / tidb (v6.5.0, 1.24, ubuntu-latest) (push) Failing after 2m6s
golangci-lint / lint (push) Failing after 6m41s
tests / gaussdb (opengauss/opengauss:7.0.0-RC1.B023, 1.23, ubuntu-latest) (push) Failing after 3m31s
tests / gaussdb (opengauss/opengauss:7.0.0-RC1.B023, 1.24, ubuntu-latest) (push) Failing after 3m38s
tests / sqlserver (1.23, ubuntu-latest) (push) Failing after 7m36s
tests / tidb (v6.5.0, 1.23, ubuntu-latest) (push) Failing after 12m41s
tests / sqlserver (1.24, ubuntu-latest) (push) Failing after 14m12s
Stale / stale (push) Failing after 4s
Close invalid questions issues / stale (push) Successful in 5s
Close Missing Playground issues / stale (push) Successful in 5s
Some checks failed
tests / mysql (mysql:5.7, 1.24, ubuntu-latest) (push) Failing after 59s
tests / mysql (mysql:8, 1.23, ubuntu-latest) (push) Failing after 59s
tests / mysql (mysql:8, 1.24, ubuntu-latest) (push) Failing after 5s
tests / sqlite (1.23, ubuntu-latest) (push) Failing after 1m26s
tests / mysql (mysql:9, 1.23, ubuntu-latest) (push) Failing after 36s
tests / mysql (mysql:9, 1.24, ubuntu-latest) (push) Failing after 32s
tests / mariadb (mariadb:latest, 1.24, ubuntu-latest) (push) Failing after 9s
tests / mariadb (mariadb:latest, 1.23, ubuntu-latest) (push) Failing after 22s
tests / postgres (postgres:13, 1.23, ubuntu-latest) (push) Failing after 24s
tests / mysql (mysql:5.7, 1.23, ubuntu-latest) (push) Failing after 2m1s
tests / postgres (postgres:14, 1.23, ubuntu-latest) (push) Failing after 20s
tests / postgres (postgres:14, 1.24, ubuntu-latest) (push) Failing after 6s
tests / postgres (postgres:15, 1.24, ubuntu-latest) (push) Failing after 14s
tests / postgres (postgres:15, 1.23, ubuntu-latest) (push) Failing after 29s
tests / postgres (postgres:latest, 1.23, ubuntu-latest) (push) Failing after 26s
tests / postgres (postgres:latest, 1.24, ubuntu-latest) (push) Failing after 18s
tests / postgres (postgres:13, 1.24, ubuntu-latest) (push) Failing after 2m55s
tests / sqlite (1.24, ubuntu-latest) (push) Failing after 4m53s
tests / tidb (v6.5.0, 1.24, ubuntu-latest) (push) Failing after 2m6s
golangci-lint / lint (push) Failing after 6m41s
tests / gaussdb (opengauss/opengauss:7.0.0-RC1.B023, 1.23, ubuntu-latest) (push) Failing after 3m31s
tests / gaussdb (opengauss/opengauss:7.0.0-RC1.B023, 1.24, ubuntu-latest) (push) Failing after 3m38s
tests / sqlserver (1.23, ubuntu-latest) (push) Failing after 7m36s
tests / tidb (v6.5.0, 1.23, ubuntu-latest) (push) Failing after 12m41s
tests / sqlserver (1.24, ubuntu-latest) (push) Failing after 14m12s
Stale / stale (push) Failing after 4s
Close invalid questions issues / stale (push) Successful in 5s
Close Missing Playground issues / stale (push) Successful in 5s
This commit is contained in:
parent
52b4744410
commit
49eaeacb89
@ -514,12 +514,19 @@ func (field *Field) setupValuerAndSetter(modelType reflect.Type) {
|
||||
// ReflectValueOf returns field's reflect value
|
||||
switch {
|
||||
case len(field.StructField.Index) == 1 && fieldIndex >= 0:
|
||||
field.ReflectValueOf = func(ctx context.Context, value reflect.Value) reflect.Value {
|
||||
return reflect.Indirect(value).Field(fieldIndex)
|
||||
field.ReflectValueOf = func(ctx context.Context, v reflect.Value) reflect.Value {
|
||||
v = reflect.Indirect(v)
|
||||
if v.Type() != modelType {
|
||||
return v.FieldByName(field.Name)
|
||||
}
|
||||
return v.Field(fieldIndex)
|
||||
}
|
||||
default:
|
||||
field.ReflectValueOf = func(ctx context.Context, v reflect.Value) reflect.Value {
|
||||
v = reflect.Indirect(v)
|
||||
if v.Type() != modelType {
|
||||
return v.FieldByName(field.Name)
|
||||
}
|
||||
for idx, fieldIdx := range field.StructField.Index {
|
||||
if fieldIdx >= 0 {
|
||||
v = v.Field(fieldIdx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user