func (o AddressSlice) UpdateAllG(cols M) error {
	return o.UpdateAll(boil.GetDB(), cols)
}
UpdateAllG updates all rows with the specified column values.
package model
import (
	"database/sql"
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/pkg/errors"
	"github.com/volatiletech/null"
	"github.com/volatiletech/sqlboiler/boil"
	"github.com/volatiletech/sqlboiler/queries"
	"github.com/volatiletech/sqlboiler/queries/qm"
	"github.com/volatiletech/sqlboiler/queries/qmhelper"
	"github.com/volatiletech/sqlboiler/strmangle"
)
type Address struct {
	ID         uint64    `boil:"id" json:"id" toml:"id" yaml:"id"`
	Address    string    `boil:"address" json:"address" toml:"address" yaml:"address"`
	FirstSeen  null.Time `boil:"first_seen" json:"first_seen,omitempty" toml:"first_seen" yaml:"first_seen,omitempty"`
	CreatedAt  time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"`
	ModifiedAt time.Time `boil:"modified_at" json:"modified_at" toml:"modified_at" yaml:"modified_at"`
	Balance    float64   `boil:"balance" json:"balance" toml:"balance" yaml:"balance"`
	R *addressR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L addressL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var AddressColumns = struct {
	ID         string
	Address    string
	FirstSeen  string
	CreatedAt  string
	ModifiedAt string
	Balance    string
}{
	ID:         "id",
	Address:    "address",
	FirstSeen:  "first_seen",
	CreatedAt:  "created_at",
	ModifiedAt: "modified_at",
	Balance:    "balance",
}
type whereHelpernull_Time struct{ field string }
func (w whereHelpernull_Time) EQ(x null.Time) qm.QueryMod {
	return qmhelper.WhereNullEQ(w.field, false, x)
}
func (w whereHelpernull_Time) NEQ(x null.Time) qm.QueryMod {
	return qmhelper.WhereNullEQ(w.field, true, x)
}
func (w whereHelpernull_Time) IsNull() qm.QueryMod    { return qmhelper.WhereIsNull(w.field) }
func (w whereHelpernull_Time) IsNotNull() qm.QueryMod { return qmhelper.WhereIsNotNull(w.field) }
func (w whereHelpernull_Time) LT(x null.Time) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.LT, x)
}
func (w whereHelpernull_Time) LTE(x null.Time) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.LTE, x)
}
func (w whereHelpernull_Time) GT(x null.Time) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.GT, x)
}
func (w whereHelpernull_Time) GTE(x null.Time) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.GTE, x)
}
type whereHelperfloat64 struct{ field string }
func (w whereHelperfloat64) EQ(x float64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) }
func (w whereHelperfloat64) NEQ(x float64) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.NEQ, x)
}
func (w whereHelperfloat64) LT(x float64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) }
func (w whereHelperfloat64) LTE(x float64) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.LTE, x)
}
func (w whereHelperfloat64) GT(x float64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) }
func (w whereHelperfloat64) GTE(x float64) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.GTE, x)
}
var AddressWhere = struct {
	ID         whereHelperuint64
	Address    whereHelperstring
	FirstSeen  whereHelpernull_Time
	CreatedAt  whereHelpertime_Time
	ModifiedAt whereHelpertime_Time
	Balance    whereHelperfloat64
}{
	ID:         whereHelperuint64{field: "`address`.`id`"},
	Address:    whereHelperstring{field: "`address`.`address`"},
	FirstSeen:  whereHelpernull_Time{field: "`address`.`first_seen`"},
	CreatedAt:  whereHelpertime_Time{field: "`address`.`created_at`"},
	ModifiedAt: whereHelpertime_Time{field: "`address`.`modified_at`"},
	Balance:    whereHelperfloat64{field: "`address`.`balance`"},
}
var AddressRels = struct {
	TransactionAddresses string
}{
	TransactionAddresses: "TransactionAddresses",
}
type addressR struct {
	TransactionAddresses TransactionAddressSlice
}
func (*addressR) NewStruct() *addressR {
	return &addressR{}
}
type addressL struct{}
var (
	addressAllColumns            = []string{"id", "address", "first_seen", "created_at", "modified_at", "balance"}
	addressColumnsWithoutDefault = []string{"address", "first_seen"}
	addressColumnsWithDefault    = []string{"id", "created_at", "modified_at", "balance"}
	addressPrimaryKeyColumns     = []string{"id"}
)
type (
	AddressSlice []*Address
	addressQuery struct {
		*queries.Query
	}
)
var (
	addressType                 = reflect.TypeOf(&Address{})
	addressMapping              = queries.MakeStructMapping(addressType)
	addressPrimaryKeyMapping, _ = queries.BindMapping(addressType, addressMapping, addressPrimaryKeyColumns)
	addressInsertCacheMut       sync.RWMutex
	addressInsertCache          = make(map[string]insertCache)
	addressUpdateCacheMut       sync.RWMutex
	addressUpdateCache          = make(map[string]updateCache)
	addressUpsertCacheMut       sync.RWMutex
	addressUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = qmhelper.Where
)
func (q addressQuery) OneG() (*Address, error) {
	return q.One(boil.GetDB())
}
func (q addressQuery) OneGP() *Address {
	o, err := q.One(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q addressQuery) OneP(exec boil.Executor) *Address {
	o, err := q.One(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q addressQuery) One(exec boil.Executor) (*Address, error) {
	o := &Address{}
	queries.SetLimit(q.Query, 1)
	err := q.Bind(nil, exec, o)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "model: failed to execute a one query for address")
	}
	return o, nil
}
func (q addressQuery) AllG() (AddressSlice, error) {
	return q.All(boil.GetDB())
}
func (q addressQuery) AllGP() AddressSlice {
	o, err := q.All(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q addressQuery) AllP(exec boil.Executor) AddressSlice {
	o, err := q.All(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q addressQuery) All(exec boil.Executor) (AddressSlice, error) {
	var o []*Address
	err := q.Bind(nil, exec, &o)
	if err != nil {
		return nil, errors.Wrap(err, "model: failed to assign all query results to Address slice")
	}
	return o, nil
}
func (q addressQuery) CountG() (int64, error) {
	return q.Count(boil.GetDB())
}
func (q addressQuery) CountGP() int64 {
	c, err := q.Count(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q addressQuery) CountP(exec boil.Executor) int64 {
	c, err := q.Count(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q addressQuery) Count(exec boil.Executor) (int64, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	err := q.Query.QueryRow(exec).Scan(&count)
	if err != nil {
		return 0, errors.Wrap(err, "model: failed to count address rows")
	}
	return count, nil
}
func (q addressQuery) ExistsG() (bool, error) {
	return q.Exists(boil.GetDB())
}
func (q addressQuery) ExistsGP() bool {
	e, err := q.Exists(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q addressQuery) ExistsP(exec boil.Executor) bool {
	e, err := q.Exists(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q addressQuery) Exists(exec boil.Executor) (bool, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	queries.SetLimit(q.Query, 1)
	err := q.Query.QueryRow(exec).Scan(&count)
	if err != nil {
		return false, errors.Wrap(err, "model: failed to check if address exists")
	}
	return count > 0, nil
}
func (o *Address) TransactionAddresses(mods ...qm.QueryMod) transactionAddressQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.Where("`transaction_address`.`address_id`=?", o.ID),
	)
	query := TransactionAddresses(queryMods...)
	queries.SetFrom(query.Query, "`transaction_address`")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"`transaction_address`.*"})
	}
	return query
}
func (addressL) LoadTransactionAddresses(e boil.Executor, singular bool, maybeAddress interface{}, mods queries.Applicator) error {
	var slice []*Address
	var object *Address
	if singular {
		object = maybeAddress.(*Address)
	} else {
		slice = *maybeAddress.(*[]*Address)
	}
	args := make([]interface{}, 0, 1)
	if singular {
		if object.R == nil {
			object.R = &addressR{}
		}
		args = append(args, object.ID)
	} else {
	Outer:
		for _, obj := range slice {
			if obj.R == nil {
				obj.R = &addressR{}
			}
			for _, a := range args {
				if a == obj.ID {
					continue Outer
				}
			}
			args = append(args, obj.ID)
		}
	}
	if len(args) == 0 {
		return nil
	}
	query := NewQuery(qm.From(`transaction_address`), qm.WhereIn(`address_id in ?`, args...))
	if mods != nil {
		mods.Apply(query)
	}
	results, err := query.Query(e)
	if err != nil {
		return errors.Wrap(err, "failed to eager load transaction_address")
	}
	var resultSlice []*TransactionAddress
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice transaction_address")
	}
	if err = results.Close(); err != nil {
		return errors.Wrap(err, "failed to close results in eager load on transaction_address")
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "error occurred during iteration of eager loaded relations for transaction_address")
	}
	if singular {
		object.R.TransactionAddresses = resultSlice
		for _, foreign := range resultSlice {
			if foreign.R == nil {
				foreign.R = &transactionAddressR{}
			}
			foreign.R.Address = object
		}
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.AddressID {
				local.R.TransactionAddresses = append(local.R.TransactionAddresses, foreign)
				if foreign.R == nil {
					foreign.R = &transactionAddressR{}
				}
				foreign.R.Address = local
				break
			}
		}
	}
	return nil
}
func (o *Address) AddTransactionAddressesG(insert bool, related ...*TransactionAddress) error {
	return o.AddTransactionAddresses(boil.GetDB(), insert, related...)
}
func (o *Address) AddTransactionAddressesP(exec boil.Executor, insert bool, related ...*TransactionAddress) {
	if err := o.AddTransactionAddresses(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Address) AddTransactionAddressesGP(insert bool, related ...*TransactionAddress) {
	if err := o.AddTransactionAddresses(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Address) AddTransactionAddresses(exec boil.Executor, insert bool, related ...*TransactionAddress) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.AddressID = o.ID
			if err = rel.Insert(exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE `transaction_address` SET %s WHERE %s",
				strmangle.SetParamNames("`", "`", 0, []string{"address_id"}),
				strmangle.WhereClause("`", "`", 0, transactionAddressPrimaryKeyColumns),
			)
			values := []interface{}{o.ID, rel.TransactionID, rel.AddressID}
			if boil.DebugMode {
				fmt.Fprintln(boil.DebugWriter, updateQuery)
				fmt.Fprintln(boil.DebugWriter, values)
			}
			if _, err = exec.Exec(updateQuery, values...); err != nil {
				return errors.Wrap(err, "failed to update foreign table")
			}
			rel.AddressID = o.ID
		}
	}
	if o.R == nil {
		o.R = &addressR{
			TransactionAddresses: related,
		}
	} else {
		o.R.TransactionAddresses = append(o.R.TransactionAddresses, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &transactionAddressR{
				Address: o,
			}
		} else {
			rel.R.Address = o
		}
	}
	return nil
}
func Addresses(mods ...qm.QueryMod) addressQuery {
	mods = append(mods, qm.From("`address`"))
	return addressQuery{NewQuery(mods...)}
}
func FindAddressG(iD uint64, selectCols ...string) (*Address, error) {
	return FindAddress(boil.GetDB(), iD, selectCols...)
}
func FindAddressP(exec boil.Executor, iD uint64, selectCols ...string) *Address {
	retobj, err := FindAddress(exec, iD, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindAddressGP(iD uint64, selectCols ...string) *Address {
	retobj, err := FindAddress(boil.GetDB(), iD, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindAddress(exec boil.Executor, iD uint64, selectCols ...string) (*Address, error) {
	addressObj := &Address{}
	sel := "*"
	if len(selectCols) > 0 {
		sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
	}
	query := fmt.Sprintf(
		"select %s from `address` where `id`=?", sel,
	)
	q := queries.Raw(query, iD)
	err := q.Bind(nil, exec, addressObj)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "model: unable to select from address")
	}
	return addressObj, nil
}
func (o *Address) InsertG(columns boil.Columns) error {
	return o.Insert(boil.GetDB(), columns)
}
func (o *Address) InsertP(exec boil.Executor, columns boil.Columns) {
	if err := o.Insert(exec, columns); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Address) InsertGP(columns boil.Columns) {
	if err := o.Insert(boil.GetDB(), columns); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Address) Insert(exec boil.Executor, columns boil.Columns) error {
	if o == nil {
		return errors.New("model: no address provided for insertion")
	}
	var err error
	nzDefaults := queries.NonZeroDefaultSet(addressColumnsWithDefault, o)
	key := makeCacheKey(columns, nzDefaults)
	addressInsertCacheMut.RLock()
	cache, cached := addressInsertCache[key]
	addressInsertCacheMut.RUnlock()
	if !cached {
		wl, returnColumns := columns.InsertColumnSet(
			addressAllColumns,
			addressColumnsWithDefault,
			addressColumnsWithoutDefault,
			nzDefaults,
		)
		cache.valueMapping, err = queries.BindMapping(addressType, addressMapping, wl)
		if err != nil {
			return err
		}
		cache.retMapping, err = queries.BindMapping(addressType, addressMapping, returnColumns)
		if err != nil {
			return err
		}
		if len(wl) != 0 {
			cache.query = fmt.Sprintf("INSERT INTO `address` (`%s`) %%sVALUES (%s)%%s", strings.Join(wl, "`,`"), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1))
		} else {
			cache.query = "INSERT INTO `address` () VALUES ()%s%s"
		}
		var queryOutput, queryReturning string
		if len(cache.retMapping) != 0 {
			cache.retQuery = fmt.Sprintf("SELECT `%s` FROM `address` WHERE %s", strings.Join(returnColumns, "`,`"), strmangle.WhereClause("`", "`", 0, addressPrimaryKeyColumns))
		}
		cache.query = fmt.Sprintf(cache.query, queryOutput, queryReturning)
	}
	value := reflect.Indirect(reflect.ValueOf(o))
	vals := queries.ValuesFromMapping(value, cache.valueMapping)
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, vals)
	}
	result, err := exec.Exec(cache.query, vals...)
	if err != nil {
		return errors.Wrap(err, "model: unable to insert into address")
	}
	var lastID int64
	var identifierCols []interface{}
	if len(cache.retMapping) == 0 {
		goto CacheNoHooks
	}
	lastID, err = result.LastInsertId()
	if err != nil {
		return ErrSyncFail
	}
	o.ID = uint64(lastID)
	if lastID != 0 && len(cache.retMapping) == 1 && cache.retMapping[0] == addressMapping["ID"] {
		goto CacheNoHooks
	}
	identifierCols = []interface{}{
		o.ID,
	}
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.retQuery)
		fmt.Fprintln(boil.DebugWriter, identifierCols...)
	}
	err = exec.QueryRow(cache.retQuery, identifierCols...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
	if err != nil {
		return errors.Wrap(err, "model: unable to populate default values for address")
	}
CacheNoHooks:
	if !cached {
		addressInsertCacheMut.Lock()
		addressInsertCache[key] = cache
		addressInsertCacheMut.Unlock()
	}
	return nil
}
func (o *Address) UpdateG(columns boil.Columns) error {
	return o.Update(boil.GetDB(), columns)
}
func (o *Address) UpdateP(exec boil.Executor, columns boil.Columns) {
	err := o.Update(exec, columns)
	if err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Address) UpdateGP(columns boil.Columns) {
	err := o.Update(boil.GetDB(), columns)
	if err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Address) Update(exec boil.Executor, columns boil.Columns) error {
	var err error
	key := makeCacheKey(columns, nil)
	addressUpdateCacheMut.RLock()
	cache, cached := addressUpdateCache[key]
	addressUpdateCacheMut.RUnlock()
	if !cached {
		wl := columns.UpdateColumnSet(
			addressAllColumns,
			addressPrimaryKeyColumns,
		)
		if len(wl) == 0 {
			return errors.New("model: unable to update address, could not build whitelist")
		}
		cache.query = fmt.Sprintf("UPDATE `address` SET %s WHERE %s",
			strmangle.SetParamNames("`", "`", 0, wl),
			strmangle.WhereClause("`", "`", 0, addressPrimaryKeyColumns),
		)
		cache.valueMapping, err = queries.BindMapping(addressType, addressMapping, append(wl, addressPrimaryKeyColumns...))
		if err != nil {
			return err
		}
	}
	values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping)
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, values)
	}
	_, err = exec.Exec(cache.query, values...)
	if err != nil {
		return errors.Wrap(err, "model: unable to update address row")
	}
	if !cached {
		addressUpdateCacheMut.Lock()
		addressUpdateCache[key] = cache
		addressUpdateCacheMut.Unlock()
	}
	return nil
}
func (q addressQuery) UpdateAllP(exec boil.Executor, cols M) {
	err := q.UpdateAll(exec, cols)
	if err != nil {
		panic(boil.WrapErr(err))
	}
}
func (q addressQuery) UpdateAllG(cols M) error {
	return q.UpdateAll(boil.GetDB(), cols)
}
func (q addressQuery) UpdateAll(exec boil.Executor, cols M) error {
	queries.SetUpdate(q.Query, cols)
	_, err := q.Query.Exec(exec)
	if err != nil {
		return errors.Wrap(err, "model: unable to update all for address")
	}
	return nil
}