MCPcopy Index your code
hub / github.com/aarondl/sqlboiler / evaluateDestination

Method evaluateDestination

types/array.go:722–755  ·  view source on GitHub ↗
(rt reflect.Type)

Source from the content-addressed store, hash-verified

720type GenericArray struct{ A any }
721
722func (GenericArray) evaluateDestination(rt reflect.Type) (reflect.Type, func([]byte, reflect.Value) error, string) {
723 var assign func([]byte, reflect.Value) error
724 var del = ","
725
726 // TODO calculate the assign function for other types
727 // TODO repeat this section on the element type of arrays or slices (multidimensional)
728 {
729 if reflect.PtrTo(rt).Implements(typeSQLScanner) {
730 // dest is always addressable because it is an element of a slice.
731 assign = func(src []byte, dest reflect.Value) (err error) {
732 ss := dest.Addr().Interface().(sql.Scanner)
733 if src == nil {
734 err = ss.Scan(nil)
735 } else {
736 err = ss.Scan(src)
737 }
738 return
739 }
740 goto FoundType
741 }
742
743 assign = func([]byte, reflect.Value) error {
744 return fmt.Errorf("boil: scanning to %s is not implemented; only sql.Scanner", rt)
745 }
746 }
747
748FoundType:
749
750 if ad, ok := reflect.Zero(rt).Interface().(ArrayDelimiter); ok {
751 del = ad.ArrayDelimiter()
752 }
753
754 return rt, assign, del
755}
756
757// Scan implements the sql.Scanner interface.
758func (a GenericArray) Scan(src any) error {

Callers 1

scanBytesMethod · 0.95

Calls 2

ArrayDelimiterMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected