// Scan implements sql.Scanner so UUIDs can be read from databases transparently
// Currently, database types that map to string and []byte are supported. Please
// consult database-specific driver documentation for matching types.
181201
func (uuid *UUID) Scan(src interface{}) error {
	switch src.(type) {
	case string:
		// if an empty UUID comes from a table, we return a null UUID
		if src.(string) == "" {
			return nil
		}

		// see uuid.Parse for required string format
		parsed := Parse(src.(string))

		if parsed == nil {
			return errors.New("Scan: invalid UUID format")
		}

		*uuid = parsed
	case []byte:
		b := src.([]byte)

		// if an empty UUID comes from a table, we return a null UUID
		if len(b) == 0 {
			return nil
		}

		// assumes a simple slice of bytes if 16 bytes
		// otherwise attempts to parse
		if len(b) == 16 {
			parsed := make([]byte, 16)
			copy(parsed, b)
			*uuid = UUID(parsed)
		} else {
			u := Parse(string(b))

			if u == nil {
				return errors.New("Scan: invalid UUID format")
			}

			*uuid = u
		}

	default:
		return fmt.Errorf("Scan: unable to scan type %T into UUID", src)
	}

	return nil
}
263788
func (n *NetID) Scan(src interface{}) error {
	b, ok := src.([]byte)
	if !ok {
		return errors.New("lorawan: []byte type expected")
	}
	if len(b) != len(n) {
		return fmt.Errorf("lorawan: []byte must have length %d", len(n))
	}
	copy(n[:], b)
	return nil
}
21273
func (mls *MultiLineString) Scan(src interface{}) error {
	if src == nil {
		mls.MultiLineString = nil
		return nil
	}
	b, ok := src.([]byte)
	if !ok {
		return ErrExpectedByteSlice{Value: src}
	}
	got, err := Unmarshal(b)
	if err != nil {
		return err
	}
	mls1, ok := got.(*geom.MultiLineString)
	if !ok {
		return wkbcommon.ErrUnexpectedType{Got: mls1, Want: mls}
	}
	mls.MultiLineString = mls1
	return nil
}
624011
func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) {
	return c.Range(ctx, ei, map[string][]*dosa.Condition{}, minimumFields, token, limit)
}
146393
func (j *JSONText) Scan(value interface{}) error {
	if value == nil {
		*j = nil
		return nil
	}

	var b []byte
	switch v := value.(type) {
	case []byte:
		b = v
	case string:
		b = []byte(v)
	default:
		return fmt.Errorf("JSONText.Scan: expected []byte or string, got %T (%q)", value, value)
	}

	*j = JSONText(append((*j)[0:0], b...))
	return nil
}
251764
func (m *JsonHelperScannable) Scan(src interface{}) error {
	var jsonBytes []byte
	switch tv := src.(type) {
	case string:
		jsonBytes = []byte(tv)
	case []byte:
		jsonBytes = tv
	case nil:
		return nil
	default:
		return fmt.Errorf("Incompatible type:%T for JsonHelperScannable", src)
	}
	jh := make(u.JsonHelper)
	if err := json.Unmarshal(jsonBytes, &jh); err != nil {
		return err
	}
	*m = JsonHelperScannable(jh)
	return nil
}
849099
func (s *String) Scan(value interface{}) error {
	if value == nil {
		s.Chars, s.Valid = "", false
		return nil
	}
	s.Valid = true

	switch v := value.(type) {
	case []byte:
		s.Chars = string(v)
	case string:
		s.Chars = v
	default:
		return fmt.Errorf("ntypes: unsuported type (%T) passed to String.Scan", value)
	}

	return nil
}
739527
func (id *ID) Scan(value interface{}) (err error) {
	switch val := value.(type) {
	case string:
		return id.UnmarshalText([]byte(val))
	case []byte:
		return id.UnmarshalText(val)
	case nil:
		*id = nilID
		return nil
	default:
		return fmt.Errorf("xid: scanning unsupported type: %T", value)
	}
}
651668
func (c *Connector) Scan(_ context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) {
	c.lock.RLock()
	defer c.lock.RUnlock()
	if c.data[ei.Def.Name] == nil {
		return []map[string]dosa.FieldValue{}, "", nil

	}
	entityRef := c.data[ei.Def.Name]
	allTheThings := make([]map[string]dosa.FieldValue, 0)

	// in order for Scan to be deterministic and continuable, we have
	// to sort the primary key references
	keys := make([]string, 0, len(entityRef))
	for key := range entityRef {
		keys = append(keys, key)
	}
	sort.Strings(keys)

	// if there was a token, decode it so we can determine the starting
	// partition key
	startPartKey, start, err := getStartingPoint(ei, token)
	if err != nil {
		return nil, "", errors.Wrapf(err, "Invalid token %s", token)
	}

	for _, key := range keys {
		if startPartKey != "" {
			// had a token, so we need to either partially skip or fully skip
			// depending on whether we found the token's partition key yet
			if key == startPartKey {
				// we reached the starting partition key, so stop skipping
				// future values, and add a portion of this one to the set
				startPartKey = ""
				found, offset := findInsertionPoint(ei.Def.Key, entityRef[key], start)
				if found {
					offset++
				}
				allTheThings = append(allTheThings, entityRef[key][offset:]...)
			} // else keep looking for this partition key
			continue
		}
		allTheThings = append(allTheThings, entityRef[key]...)
	}
	if len(allTheThings) == 0 {
		return []map[string]dosa.FieldValue{}, "", nil
	}
	// see if we need a token to return
	token = ""
	if len(allTheThings) > limit {
		token = makeToken(allTheThings[limit-1])
		allTheThings = allTheThings[:limit]
	}
	return copyRows(allTheThings), token, nil
}
946091
func (n *NullJSONText) Scan(value interface{}) error {
	if value == nil {
		n.JSONText, n.Valid = emptyJSON, false
		return nil
	}
	n.Valid = true
	return n.JSONText.Scan(value)
}
1075657
func (nu *NullUUID) Scan(val interface{}) error {
	if val == nil {
		nu.UUID, nu.Valid = [16]byte{}, false

		return nil
	}

	nu.Valid = true

	return nu.UUID.Scan(val)
}
4392
func (s *DiffIndexScanner) scan(line string) (*DiffIndexEntry, error) {
	// Format is:
	//   :100644 100644 c5b3d83a7542255ec7856487baa5e83d65b1624c 9e82ac1b514be060945392291b5b3108c22f6fe3 M foo.gif
	//   :<old mode> <new mode> <old sha1> <new sha1> <status>\t<file name>[\t<file name>]

	parts := strings.Split(line, "\t")
	if len(parts) < 2 {
		return nil, errors.Errorf("invalid line: %s", line)
	}

	desc := strings.Fields(parts[0])
	if len(desc) < 5 {
		return nil, errors.Errorf("invalid description: %s", parts[0])
	}

	entry := &DiffIndexEntry{
		SrcMode: strings.TrimPrefix(desc[0], ":"),
		DstMode: desc[1],
		SrcSha:  desc[2],
		DstSha:  desc[3],
		Status:  DiffIndexStatus(rune(desc[4][0])),
		SrcName: parts[1],
	}

	if score, err := strconv.Atoi(desc[4][1:]); err != nil {
		entry.StatusScore = score
	}

	if len(parts) > 2 {
		entry.DstName = parts[2]
	}

	return entry, nil
}
1197226
func (b *Base) Scan(data interface{}) (err error) {
	switch values := data.(type) {
	case *os.File:
		b.FileHeader = &fileWrapper{values}
		b.FileName = filepath.Base(values.Name())
	case *multipart.FileHeader:
		b.FileHeader, b.FileName = values, values.Filename
	case []*multipart.FileHeader:
		if len(values) > 0 {
			file := values[0]
			b.FileHeader, b.FileName = file, file.Filename
		}
	case []byte:
		if string(values) != "" {
			if err = json.Unmarshal(values, b); err == nil {
				var doCrop struct{ Crop bool }
				if err = json.Unmarshal(values, &doCrop); err == nil && doCrop.Crop {
					b.Crop = true
				}
			}
		}
	case string:
		return b.Scan([]byte(values))
	case []string:
		for _, str := range values {
			if err := b.Scan(str); err != nil {
				return err
			}
		}
	default:
		err = errors.New("unsupported driver -> Scan pair for MediaLibrary")
	}

	// If image is deleted, then clean up all values, for serialized fields
	if b.Delete {
		b.Url = ""
		b.FileName = ""
		b.CropOptions = nil
	}
	return
}
32339
func (dst *Int8) Scan(src interface{}) error {
	if src == nil {
		*dst = Int8{Status: Null}
		return nil
	}

	switch src := src.(type) {
	case int64:
		*dst = Int8{Int: src, Status: Present}
		return nil
	case string:
		return dst.DecodeText(nil, []byte(src))
	case []byte:
		srcCopy := make([]byte, len(src))
		copy(srcCopy, src)
		return dst.DecodeText(nil, srcCopy)
	}

	return errors.Errorf("cannot scan %T", src)
}
1107802
func (dst *UUID) Scan(src interface{}) error {
	if src == nil {
		*dst = UUID{Status: pgtype.Null}
		return nil
	}

	switch src := src.(type) {
	case string:
		return dst.DecodeText(nil, []byte(src))
	case []byte:
		return dst.DecodeText(nil, src)
	}

	return errors.Errorf("cannot scan %T", src)
}
742596
func (e *EUI64) Scan(src interface{}) error {
	b, ok := src.([]byte)
	if !ok {
		return errors.New("lorawan: []byte type expected")
	}
	if len(b) != len(e) {
		return fmt.Errorf("lorawan: []byte must have length %d", len(e))
	}
	copy(e[:], b)
	return nil
}
214763
func (s *DB) Scan(dest interface{}) *DB {
	return s.NewScope(s.Value).Set("gorm:query_destination", dest).callCallbacks(s.parent.callbacks.queries).db
}