func (i Int8) Value() (driver.Value, error) {
	return int64(i), 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
}