func (b Bool) Value() (driver.Value, error) {
	if !b {
		return false, nil
	}
	return bool(b), nil
}
Value implements the driver Valuer interface.
package core
import (
	"context"
	"database/sql"
	"database/sql/driver"
	"encoding/json"
	"fmt"
	"log"
	"reflect"
	"strings"
	"time"
	"unsafe"
	"github.com/lib/pq"
)
type Row struct {
	Row *sql.Row
	Log func(err error) error
}
func (r Row) Scan(dest ...interface{}) error {
	err := r.Row.Scan(dest...)
	return r.Log(err)
}
type CommonQuery interface {
	Get(obj IGet, preds ...interface{}) (bool, error)
	Find(objs IFind, preds ...interface{}) error
	Insert(objs ...IInsert) (int64, error)
	Update(objs ...IUpdate) (int64, error)
	UpdateMap(m map[string]interface{}) (int64, error)
	Delete(obj ITableName) (int64, error)
	Count(obj ITableName, preds ...interface{}) (uint64, error)
	Table(name string) Query
	Prefix(sql string, args ...interface{}) Query
	Select(cols ...string) Query
	From(table string) Query
	SQL(preds ...interface{}) Query
	Where(preds ...interface{}) Query
	OrderBy(orderBys ...string) Query
	GroupBy(groupBys ...string) Query
	Limit(limit uint64) Query
	Offset(offset uint64) Query
	Suffix(sql string, args ...interface{}) Query
	UpdateAll() Query
	In(column string, args ...interface{}) Query
	NotIn(column string, args ...interface{}) Query
	Exists(column string, exists bool) Query
	IsNull(column string, null bool) Query
	Preload(table string, preds ...interface{}) Query
	Apply(funcs ...func(CommonQuery)) Query
}
type DBInterface interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) Row
}
type Query interface {
	CommonQuery
	Build(preds ...interface{}) (string, []interface{}, error)
	BuildGet(obj IGet, preds ...interface{}) (string, []interface{}, error)
	BuildFind(objs IFind, preds ...interface{}) (string, []interface{}, error)
	BuildInsert(obj IInsert) (string, []interface{}, error)
	BuildUpdate(obj IUpdate) (string, []interface{}, error)
	BuildDelete(obj ITableName) (string, []interface{}, error)
	BuildCount(obj ITableName, preds ...interface{}) (string, []interface{}, error)
	Clone() Query
	Exec() (sql.Result, error)
	Query() (*sql.Rows, error)
	QueryRow() (Row, error)
	Scan(dest ...interface{}) error
	WithContext(context.Context) Query
}
type Error string
func (e Error) Error() string {
	return string(e)
}
type InvalidArgumentError string
func (e InvalidArgumentError) Error() string {
	return string(e)
}
func Errorf(format string, args ...interface{}) Error {
	return Error(fmt.Sprintf(format, args...))
}
var (
	ErrNoColumn = Error("sqlgen: no column to update")
	ErrNoRows   = sql.ErrNoRows
)
type Opts struct {
	UseArrayInsteadOfJSON bool
}
func (opts Opts) Array(v interface{}) Array {
	return Array{V: v, Opts: opts}
}
func (opts Opts) JSON(v interface{}) JSON {
	return JSON{V: v}
}
type JoinType string
type ITableName interface {
	SQLTableName() string
}
type IScan interface {
	ITableName
	SQLScan(Opts, *sql.Rows) error
}
type IScanRow interface {
	ITableName
	SQLScan(Opts, *sql.Row) error
}
type ISelect interface {
	ITableName
	SQLSelect(SQLWriter) error
}
type IInsert interface {
	ITableName
	SQLInsert(SQLWriter) error
}
type IUpdate interface {
	ITableName
	SQLUpdate(SQLWriter) error
	SQLUpdateAll(SQLWriter) error
}
type IGet interface {
	ITableName
	SQLSelect(SQLWriter) error
	SQLScan(Opts, *sql.Row) error
}
type IFind interface {
	ITableName
	SQLSelect(SQLWriter) error
	SQLScan(Opts, *sql.Rows) error
}
type IJoin interface {
	ITableName
	SQLJoin(SQLWriter, []JoinType) error
}
type IPreload interface {
	SQLPreload(name string) *PreloadDesc
	SQLPopulate(items IFind) error
}
type PreloadDesc struct {
	Fkey  string
	IDs   interface{}
	Items IFind
}
type SQLWriter interface {
	Len() int
	Opts() Opts
	TrimLast(n int)
	WriteArg(arg interface{})
	WriteArgs(args []interface{})
	WriteByte(b byte)
	WriteMarker()
	WriteMarkers(n int)
	WriteName(name string)
	WritePrefixedName(schema string, name string)
	WriteQuery(b []byte)
	WriteQueryName(name string)
	WriteQueryString(s string)
	WriteQueryStringWithPrefix(prefix string, s string)
	WriteRaw(b []byte)
	WriteRawString(s string)
	WriteScanArg(arg interface{})
	WriteScanArgs(args []interface{})
}
type Interface struct{ V interface{} }
func (i Interface) Bool() *bool {
	if i.V == nil {
		return nil
	}
	v := i.V.(bool)
	return &v
}
func (i Interface) Int() *int {
	if i.V == nil {
		return nil
	}
	v := int(i.V.(int64))
	return &v
}
func (i Interface) Int32() *int32 {
	if i.V == nil {
		return nil
	}
	v := int32(i.V.(int64))
	return &v
}
func (i Interface) Int64() *int64 {
	if i.V == nil {
		return nil
	}
	v := i.V.(int64)
	return &v
}
func (i Interface) String() *string {
	if i.V == nil {
		return nil
	}
	switch v := i.V.(type) {
	case string:
		return &v
	case []byte:
		res := unsafeBytesToString(v)
		return &res
	default:
		panic(fmt.Sprintf("sqlgen: unknown type %v", reflect.TypeOf(i.V)))
	}
}
func (i Interface) Time() time.Time {
	if i.V == nil {
		return time.Time{}
	}
	v := i.V.(time.Time)
	return v
}
func (i Interface) JSON() json.RawMessage {
	if i.V == nil {
		return nil
	}
	v := i.V.([]byte)
	return v
}
func (i Interface) Unmarshal(v interface{}) error {
	if i.V == nil {
		return nil
	}
	err := json.Unmarshal(i.V.([]byte), v)
	if err != nil {
		log.Println("sqlgen: error unmarshalling", err)
	}
	return err
}
func (i Interface) Map() map[string]interface{} {
	if i.V == nil {
		return nil
	}
	v := i.V.(map[string]interface{})
	return v
}
func Now(t, now time.Time, update bool) time.Time {
	if update && t.IsZero() {
		return now
	}
	return t
}
func NowP(t *time.Time, now time.Time, update bool) time.Time {
	if update && t == nil {
		return now
	}
	return *t
}
type String string
func (s String) String() string {
	return string(s)
}
func (s *String) Scan(src interface{}) error {
	var ns sql.NullString
	err := ns.Scan(src)
	if err == nil && ns.Valid {
		*s = String(ns.String)
	}
	return err
}
func (s String) Value() (driver.Value, error) {
	if s == "" {
		return nil, nil
	}
	return string(s), nil
}
type Int int
func (i *Int) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Int(ni.Int64)
	}
	return err
}
func (i Int) Value() (driver.Value, error) {
	return int64(i), nil
}
type Int8 int8
func (i *Int8) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Int8(ni.Int64)
	}
	return err
}
func (i Int8) Value() (driver.Value, error) {
	return int64(i), nil
}
type Int16 int16
func (i *Int16) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Int16(ni.Int64)
	}
	return err
}
func (i Int16) Value() (driver.Value, error) {
	return int64(i), nil
}
type Int32 int32
func (i *Int32) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Int32(ni.Int64)
	}
	return err
}
func (i Int32) Value() (driver.Value, error) {
	if i == 0 {
		return int64(0), nil
	}
	return int64(i), nil
}
type Int64 int64
func (i *Int64) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Int64(ni.Int64)
	}
	return err
}
func (i Int64) Value() (driver.Value, error) {
	if i == 0 {
		return nil, nil
	}
	return int64(i), nil
}
type Uint uint
func (i *Uint) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Uint(ni.Int64)
	}
	return err
}
func (i Uint) Value() (driver.Value, error) {
	return int64(i), nil
}
type Uint8 uint8
func (i *Uint8) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Uint8(ni.Int64)
	}
	return err
}
func (i Uint8) Value() (driver.Value, error) {
	return int64(i), nil
}
type Uint16 uint16
func (i *Uint16) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Uint16(ni.Int64)
	}
	return err
}
func (i Uint16) Value() (driver.Value, error) {
	return int64(i), nil
}
type Uint32 uint32
func (i *Uint32) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Uint32(ni.Int64)
	}
	return err
}
func (i Uint32) Value() (driver.Value, error) {
	return int64(i), nil
}
type Uint64 uint64
func (i *Uint64) Scan(src interface{}) error {
	var ni sql.NullInt64
	err := ni.Scan(src)
	if err == nil && ni.Valid {
		*i = Uint64(ni.Int64)
	}
	return err
}
func (i Uint64) Value() (driver.Value, error) {
	if i == 0 {
		return nil, nil
	}
	return int64(i), nil
}
type Float32 float32
func (f *Float32) Scan(src interface{}) error {
	var nf sql.NullFloat64
	err := nf.Scan(src)
	if err == nil && nf.Valid {
		*f = Float32(nf.Float64)
	}
	return err
}
func (f Float32) Value() (driver.Value, error) {
	return float64(f), nil
}
type Float64 float64
type Float = Float64
func (f *Float64) Scan(src interface{}) error {
	var nf sql.NullFloat64
	err := nf.Scan(src)
	if err == nil && nf.Valid {
		*f = Float64(nf.Float64)
	}
	return err
}
func (f Float64) Value() (driver.Value, error) {
	return float64(f), nil
}
type Bool bool
func (b *Bool) Scan(src interface{}) error {
	var nb sql.NullBool
	err := nb.Scan(src)
	if err == nil && nb.Valid {
		*b = Bool(nb.Bool)
	}
	return err
}