func (a IntArray) Value() (driver.Value, error) {
	if a == nil {
		return nil, nil
	}
	if n := len(a); n > 0 {
		b := make([]byte, 1, 1+2*n)
		b[0] = '{'
		b = strconv.AppendInt(b, int64(a[0]), 10)
		for i := 1; i < n; i++ {
			b = append(b, ',')
			b = strconv.AppendInt(b, int64(a[i]), 10)
		}
		return string(append(b, '}')), nil
	}
	return "{}", nil
}
Value implements the driver.Valuer interface.
package types
import (
	"bytes"
	"database/sql/driver"
	"fmt"
	"net/url"
	"strconv"
	"strings"
	"github.com/lib/pq"
)
type slice struct {
	val interface{}
}
func Slice(v interface{}) SQLType {
	switch v := v.(type) {
	case []url.URL:
		return Slice(&v)
	case []uint64:
		return (*Uint64Array)(&v)
	case *[]uint64:
		return (*Uint64Array)(v)
	case []int:
		return (*IntArray)(&v)
	case *[]int:
		return (*IntArray)(v)
	case []uint:
		return (*UintArray)(&v)
	case *[]uint:
		return (*UintArray)(v)
	case []int32:
		return (*Int32Array)(&v)
	case *[]int32:
		return (*Int32Array)(v)
	case []uint32:
		return (*Uint32Array)(&v)
	case *[]uint32:
		return (*Uint32Array)(v)
	case []int16:
		return (*Int16Array)(&v)
	case *[]int16:
		return (*Int16Array)(v)
	case []uint16:
		return (*Uint16Array)(&v)
	case *[]uint16:
		return (*Uint16Array)(v)
	case []int8:
		return (*Int8Array)(&v)
	case *[]int8:
		return (*Int8Array)(v)
	case []byte:
		return (*ByteArray)(&v)
	case *[]byte:
		return (*ByteArray)(v)
	case *[]float32:
		return (*Float32Array)(v)
	case []float32:
		return (*Float32Array)(&v)
	}
	return &slice{v}
}
func (a *slice) Scan(v interface{}) error {
	switch o := a.val.(type) {
	case *[]url.URL:
		var s []string
		if err := pq.Array(&s).Scan(v); err != nil {
			return err
		}
		var res = make([]url.URL, len(s))
		for i, v := range s {
			var u = new(URL)
			if err := u.Scan(v); err != nil {
				return err
			}
			res[i] = url.URL(*u)
		}
		*o = res
		return nil
	case *[]*url.URL:
		var s []string
		if err := pq.Array(&s).Scan(v); err != nil {
			return err
		}
		var res = make([]*url.URL, len(s))
		for i, v := range s {
			var u = new(URL)
			if err := u.Scan(v); err != nil {
				return err
			}
			res[i] = (*url.URL)(u)
		}
		*o = res
		return nil
	}
	return pq.Array(a.val).Scan(v)
}
func (a slice) Value() (driver.Value, error) {
	switch v := a.val.(type) {
	case *[]url.URL:
		var s = make([]string, len(*v))
		for i, u := range *v {
			url, err := URL(u).Value()
			if err != nil {
				return nil, err
			}
			s[i] = url.(string)
		}
		return pq.Array(s).Value()
	case *[]*url.URL:
		var s = make([]string, len(*v))
		for i, u := range *v {
			url, err := (*URL)(u).Value()
			if err != nil {
				return nil, err
			}
			s[i] = url.(string)
		}
		return pq.Array(s).Value()
	default:
		return pq.Array(v).Value()
	}
}
type Uint64Array []uint64
func (a *Uint64Array) Scan(src interface{}) error {
	switch src := src.(type) {
	case []byte:
		return a.scanBytes(src)
	case string:
		return a.scanBytes([]byte(src))
	case nil:
		*a = nil
		return nil
	}
	return fmt.Errorf("kallax: cannot convert %T to Uint64Array", src)
}
func (a *Uint64Array) scanBytes(src []byte) error {
	elems, err := scanLinearArray(src, []byte{','}, "Uint64Array")
	if err != nil {
		return err
	}
	if *a != nil && len(elems) == 0 {
		*a = (*a)[:0]
	} else {
		b := make(Uint64Array, len(elems))
		for i, v := range elems {
			if b[i], err = strconv.ParseUint(string(v), 10, 64); err != nil {
				return fmt.Errorf("kallax: parsing array element index %d: %v", i, err)
			}
		}
		*a = b
	}
	return nil
}
func (a Uint64Array) Value() (driver.Value, error) {
	if a == nil {
		return nil, nil
	}
	if n := len(a); n > 0 {
		b := make([]byte, 1, 1+2*n)
		b[0] = '{'
		b = strconv.AppendUint(b, a[0], 10)
		for i := 1; i < n; i++ {
			b = append(b, ',')
			b = strconv.AppendUint(b, a[i], 10)
		}
		return string(append(b, '}')), nil
	}
	return "{}", nil
}
type IntArray []int
func (a *IntArray) Scan(src interface{}) error {
	switch src := src.(type) {
	case []byte:
		return a.scanBytes(src)
	case string:
		return a.scanBytes([]byte(src))
	case nil:
		*a = nil
		return nil
	}
	return fmt.Errorf("kallax: cannot convert %T to IntArray", src)
}
func (a *IntArray) scanBytes(src []byte) error {
	elems, err := scanLinearArray(src, []byte{','}, "IntArray")
	if err != nil {
		return err
	}
	if *a != nil && len(elems) == 0 {
		*a = (*a)[:0]
	} else {
		b := make(IntArray, len(elems))
		for i, v := range elems {
			if b[i], err = strconv.Atoi(string(v)); err != nil {
				return fmt.Errorf("kallax: parsing array element index %d: %v", i, err)
			}
		}
		*a = b
	}
	return nil
}