MCPcopy
hub / github.com/go-gorm/gorm / expandValues

Function expandValues

association.go:638–665  ·  view source on GitHub ↗
(values ...any)

Source from the content-addressed store, hash-verified

636}
637
638func expandValues(values ...any) (results []any) {
639 appendToResult := func(rv reflect.Value) {
640 // unwrap interface
641 if rv.IsValid() && rv.Kind() == reflect.Interface {
642 rv = rv.Elem()
643 }
644 if rv.IsValid() && rv.Kind() == reflect.Struct {
645 p := reflect.New(rv.Type())
646 p.Elem().Set(rv)
647 results = append(results, p.Interface())
648 } else if rv.IsValid() {
649 results = append(results, rv.Interface())
650 }
651 }
652
653 // Process each argument; if an argument is a slice/array, expand its elements
654 for _, value := range values {
655 rv := reflect.ValueOf(value)
656 if rv.Kind() == reflect.Slice || rv.Kind() == reflect.Array {
657 for i := 0; i < rv.Len(); i++ {
658 appendToResult(rv.Index(i))
659 }
660 } else {
661 appendToResult(rv)
662 }
663 }
664 return
665}

Callers 3

AppendMethod · 0.85
ReplaceMethod · 0.85
DeleteMethod · 0.85

Calls 4

LenMethod · 0.80
NewMethod · 0.65
TypeMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected