func (o *Purchase) UpdateP(exec boil.Executor, columns boil.Columns) {
	err := o.Update(exec, columns)
	if err != nil {
		panic(boil.WrapErr(err))
	}
}
UpdateP uses an executor to update the Purchase, and panics on error.
See Update for more documentation.
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 Purchase struct {
	ID                  uint64      `boil:"id" json:"id" toml:"id" yaml:"id"`
	TransactionByHashID null.String `boil:"transaction_by_hash_id" json:"transaction_by_hash_id,omitempty" toml:"transaction_by_hash_id" yaml:"transaction_by_hash_id,omitempty"`
	Vout                uint        `boil:"vout" json:"vout" toml:"vout" yaml:"vout"`
	ClaimID             null.String `boil:"claim_id" json:"claim_id,omitempty" toml:"claim_id" yaml:"claim_id,omitempty"`
	PublisherID         null.String `boil:"publisher_id" json:"publisher_id,omitempty" toml:"publisher_id" yaml:"publisher_id,omitempty"`
	Height              uint        `boil:"height" json:"height" toml:"height" yaml:"height"`
	AmountSatoshi       int64       `boil:"amount_satoshi" json:"amount_satoshi" toml:"amount_satoshi" yaml:"amount_satoshi"`
	Created             time.Time   `boil:"created" json:"created" toml:"created" yaml:"created"`
	Modified            time.Time   `boil:"modified" json:"modified" toml:"modified" yaml:"modified"`
	R *purchaseR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L purchaseL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var PurchaseColumns = struct {
	ID                  string
	TransactionByHashID string
	Vout                string
	ClaimID             string
	PublisherID         string
	Height              string
	AmountSatoshi       string
	Created             string
	Modified            string
}{
	ID:                  "id",
	TransactionByHashID: "transaction_by_hash_id",
	Vout:                "vout",
	ClaimID:             "claim_id",
	PublisherID:         "publisher_id",
	Height:              "height",
	AmountSatoshi:       "amount_satoshi",
	Created:             "created",
	Modified:            "modified",
}
var PurchaseWhere = struct {
	ID                  whereHelperuint64
	TransactionByHashID whereHelpernull_String
	Vout                whereHelperuint
	ClaimID             whereHelpernull_String
	PublisherID         whereHelpernull_String
	Height              whereHelperuint
	AmountSatoshi       whereHelperint64
	Created             whereHelpertime_Time
	Modified            whereHelpertime_Time
}{
	ID:                  whereHelperuint64{field: "`purchase`.`id`"},
	TransactionByHashID: whereHelpernull_String{field: "`purchase`.`transaction_by_hash_id`"},
	Vout:                whereHelperuint{field: "`purchase`.`vout`"},
	ClaimID:             whereHelpernull_String{field: "`purchase`.`claim_id`"},
	PublisherID:         whereHelpernull_String{field: "`purchase`.`publisher_id`"},
	Height:              whereHelperuint{field: "`purchase`.`height`"},
	AmountSatoshi:       whereHelperint64{field: "`purchase`.`amount_satoshi`"},
	Created:             whereHelpertime_Time{field: "`purchase`.`created`"},
	Modified:            whereHelpertime_Time{field: "`purchase`.`modified`"},
}
var PurchaseRels = struct {
	TransactionByHash string
}{
	TransactionByHash: "TransactionByHash",
}
type purchaseR struct {
	TransactionByHash *Transaction
}
func (*purchaseR) NewStruct() *purchaseR {
	return &purchaseR{}
}
type purchaseL struct{}
var (
	purchaseAllColumns            = []string{"id", "transaction_by_hash_id", "vout", "claim_id", "publisher_id", "height", "amount_satoshi", "created", "modified"}
	purchaseColumnsWithoutDefault = []string{"transaction_by_hash_id", "vout", "claim_id", "publisher_id", "height"}
	purchaseColumnsWithDefault    = []string{"id", "amount_satoshi", "created", "modified"}
	purchasePrimaryKeyColumns     = []string{"id"}
)
type (
	PurchaseSlice []*Purchase
	purchaseQuery struct {
		*queries.Query
	}
)
var (
	purchaseType                 = reflect.TypeOf(&Purchase{})
	purchaseMapping              = queries.MakeStructMapping(purchaseType)
	purchasePrimaryKeyMapping, _ = queries.BindMapping(purchaseType, purchaseMapping, purchasePrimaryKeyColumns)
	purchaseInsertCacheMut       sync.RWMutex
	purchaseInsertCache          = make(map[string]insertCache)
	purchaseUpdateCacheMut       sync.RWMutex
	purchaseUpdateCache          = make(map[string]updateCache)
	purchaseUpsertCacheMut       sync.RWMutex
	purchaseUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = qmhelper.Where
)
func (q purchaseQuery) OneG() (*Purchase, error) {
	return q.One(boil.GetDB())
}
func (q purchaseQuery) OneGP() *Purchase {
	o, err := q.One(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q purchaseQuery) OneP(exec boil.Executor) *Purchase {
	o, err := q.One(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q purchaseQuery) One(exec boil.Executor) (*Purchase, error) {
	o := &Purchase{}
	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 purchase")
	}
	return o, nil
}
func (q purchaseQuery) AllG() (PurchaseSlice, error) {
	return q.All(boil.GetDB())
}
func (q purchaseQuery) AllGP() PurchaseSlice {
	o, err := q.All(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q purchaseQuery) AllP(exec boil.Executor) PurchaseSlice {
	o, err := q.All(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q purchaseQuery) All(exec boil.Executor) (PurchaseSlice, error) {
	var o []*Purchase
	err := q.Bind(nil, exec, &o)
	if err != nil {
		return nil, errors.Wrap(err, "model: failed to assign all query results to Purchase slice")
	}
	return o, nil
}
func (q purchaseQuery) CountG() (int64, error) {
	return q.Count(boil.GetDB())
}
func (q purchaseQuery) CountGP() int64 {
	c, err := q.Count(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q purchaseQuery) CountP(exec boil.Executor) int64 {
	c, err := q.Count(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q purchaseQuery) 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 purchase rows")
	}
	return count, nil
}
func (q purchaseQuery) ExistsG() (bool, error) {
	return q.Exists(boil.GetDB())
}
func (q purchaseQuery) ExistsGP() bool {
	e, err := q.Exists(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q purchaseQuery) ExistsP(exec boil.Executor) bool {
	e, err := q.Exists(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q purchaseQuery) 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 purchase exists")
	}
	return count > 0, nil
}
func (o *Purchase) TransactionByHash(mods ...qm.QueryMod) transactionQuery {
	queryMods := []qm.QueryMod{
		qm.Where("hash=?", o.TransactionByHashID),
	}
	queryMods = append(queryMods, mods...)
	query := Transactions(queryMods...)
	queries.SetFrom(query.Query, "`transaction`")
	return query
}
func (purchaseL) LoadTransactionByHash(e boil.Executor, singular bool, maybePurchase interface{}, mods queries.Applicator) error {
	var slice []*Purchase
	var object *Purchase
	if singular {
		object = maybePurchase.(*Purchase)
	} else {
		slice = *maybePurchase.(*[]*Purchase)
	}
	args := make([]interface{}, 0, 1)
	if singular {
		if object.R == nil {
			object.R = &purchaseR{}
		}
		if !queries.IsNil(object.TransactionByHashID) {
			args = append(args, object.TransactionByHashID)
		}
	} else {
	Outer:
		for _, obj := range slice {
			if obj.R == nil {
				obj.R = &purchaseR{}
			}
			for _, a := range args {
				if queries.Equal(a, obj.TransactionByHashID) {
					continue Outer
				}
			}
			if !queries.IsNil(obj.TransactionByHashID) {
				args = append(args, obj.TransactionByHashID)
			}
		}
	}
	if len(args) == 0 {
		return nil
	}
	query := NewQuery(qm.From(`transaction`), qm.WhereIn(`hash 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")
	}
	var resultSlice []*Transaction
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Transaction")
	}
	if err = results.Close(); err != nil {
		return errors.Wrap(err, "failed to close results of eager load for transaction")
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "error occurred during iteration of eager loaded relations for transaction")
	}
	if len(resultSlice) == 0 {
		return nil
	}
	if singular {
		foreign := resultSlice[0]
		object.R.TransactionByHash = foreign
		if foreign.R == nil {
			foreign.R = &transactionR{}
		}
		foreign.R.TransactionByHashPurchases = append(foreign.R.TransactionByHashPurchases, object)
		return nil
	}
	for _, local := range slice {
		for _, foreign := range resultSlice {
			if queries.Equal(local.TransactionByHashID, foreign.Hash) {
				local.R.TransactionByHash = foreign
				if foreign.R == nil {
					foreign.R = &transactionR{}
				}
				foreign.R.TransactionByHashPurchases = append(foreign.R.TransactionByHashPurchases, local)
				break
			}
		}
	}
	return nil
}
func (o *Purchase) SetTransactionByHashG(insert bool, related *Transaction) error {
	return o.SetTransactionByHash(boil.GetDB(), insert, related)
}
func (o *Purchase) SetTransactionByHashP(exec boil.Executor, insert bool, related *Transaction) {
	if err := o.SetTransactionByHash(exec, insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Purchase) SetTransactionByHashGP(insert bool, related *Transaction) {
	if err := o.SetTransactionByHash(boil.GetDB(), insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Purchase) SetTransactionByHash(exec boil.Executor, insert bool, related *Transaction) error {
	var err error
	if insert {
		if err = related.Insert(exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}
	updateQuery := fmt.Sprintf(
		"UPDATE `purchase` SET %s WHERE %s",
		strmangle.SetParamNames("`", "`", 0, []string{"transaction_by_hash_id"}),
		strmangle.WhereClause("`", "`", 0, purchasePrimaryKeyColumns),
	)
	values := []interface{}{related.Hash, o.ID}
	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 local table")
	}
	queries.Assign(&o.TransactionByHashID, related.Hash)
	if o.R == nil {
		o.R = &purchaseR{
			TransactionByHash: related,
		}
	} else {
		o.R.TransactionByHash = related
	}
	if related.R == nil {
		related.R = &transactionR{
			TransactionByHashPurchases: PurchaseSlice{o},
		}
	} else {
		related.R.TransactionByHashPurchases = append(related.R.TransactionByHashPurchases, o)
	}
	return nil
}
func (o *Purchase) RemoveTransactionByHashG(related *Transaction) error {
	return o.RemoveTransactionByHash(boil.GetDB(), related)
}
func (o *Purchase) RemoveTransactionByHashP(exec boil.Executor, related *Transaction) {
	if err := o.RemoveTransactionByHash(exec, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Purchase) RemoveTransactionByHashGP(related *Transaction) {
	if err := o.RemoveTransactionByHash(boil.GetDB(), related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Purchase) RemoveTransactionByHash(exec boil.Executor, related *Transaction) error {
	var err error
	queries.SetScanner(&o.TransactionByHashID, nil)
	if err = o.Update(exec, boil.Whitelist("transaction_by_hash_id")); err != nil {
		return errors.Wrap(err, "failed to update local table")
	}
	o.R.TransactionByHash = nil
	if related == nil || related.R == nil {
		return nil
	}
	for i, ri := range related.R.TransactionByHashPurchases {
		if queries.Equal(o.TransactionByHashID, ri.TransactionByHashID) {
			continue
		}
		ln := len(related.R.TransactionByHashPurchases)
		if ln > 1 && i < ln-1 {
			related.R.TransactionByHashPurchases[i] = related.R.TransactionByHashPurchases[ln-1]
		}
		related.R.TransactionByHashPurchases = related.R.TransactionByHashPurchases[:ln-1]
		break
	}
	return nil
}
func Purchases(mods ...qm.QueryMod) purchaseQuery {
	mods = append(mods, qm.From("`purchase`"))
	return purchaseQuery{NewQuery(mods...)}
}
func FindPurchaseG(iD uint64, selectCols ...string) (*Purchase, error) {
	return FindPurchase(boil.GetDB(), iD, selectCols...)
}
func FindPurchaseP(exec boil.Executor, iD uint64, selectCols ...string) *Purchase {
	retobj, err := FindPurchase(exec, iD, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindPurchaseGP(iD uint64, selectCols ...string) *Purchase {
	retobj, err := FindPurchase(boil.GetDB(), iD, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindPurchase(exec boil.Executor, iD uint64, selectCols ...string) (*Purchase, error) {
	purchaseObj := &Purchase{}
	sel := "*"
	if len(selectCols) > 0 {
		sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
	}
	query := fmt.Sprintf(
		"select %s from `purchase` where `id`=?", sel,
	)
	q := queries.Raw(query, iD)
	err := q.Bind(nil, exec, purchaseObj)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "model: unable to select from purchase")
	}
	return purchaseObj, nil
}
func (o *Purchase) InsertG(columns boil.Columns) error {
	return o.Insert(boil.GetDB(), columns)
}
func (o *Purchase) InsertP(exec boil.Executor, columns boil.Columns) {
	if err := o.Insert(exec, columns); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Purchase) InsertGP(columns boil.Columns) {
	if err := o.Insert(boil.GetDB(), columns); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Purchase) Insert(exec boil.Executor, columns boil.Columns) error {
	if o == nil {
		return errors.New("model: no purchase provided for insertion")
	}
	var err error
	nzDefaults := queries.NonZeroDefaultSet(purchaseColumnsWithDefault, o)
	key := makeCacheKey(columns, nzDefaults)
	purchaseInsertCacheMut.RLock()
	cache, cached := purchaseInsertCache[key]
	purchaseInsertCacheMut.RUnlock()
	if !cached {
		wl, returnColumns := columns.InsertColumnSet(
			purchaseAllColumns,
			purchaseColumnsWithDefault,
			purchaseColumnsWithoutDefault,
			nzDefaults,
		)
		cache.valueMapping, err = queries.BindMapping(purchaseType, purchaseMapping, wl)
		if err != nil {
			return err
		}
		cache.retMapping, err = queries.BindMapping(purchaseType, purchaseMapping, returnColumns)
		if err != nil {
			return err
		}
		if len(wl) != 0 {
			cache.query = fmt.Sprintf("INSERT INTO `purchase` (`%s`) %%sVALUES (%s)%%s", strings.Join(wl, "`,`"), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1))
		} else {
			cache.query = "INSERT INTO `purchase` () VALUES ()%s%s"
		}
		var queryOutput, queryReturning string
		if len(cache.retMapping) != 0 {
			cache.retQuery = fmt.Sprintf("SELECT `%s` FROM `purchase` WHERE %s", strings.Join(returnColumns, "`,`"), strmangle.WhereClause("`", "`", 0, purchasePrimaryKeyColumns))
		}
		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 purchase")
	}
	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] == purchaseMapping["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 purchase")
	}
CacheNoHooks:
	if !cached {
		purchaseInsertCacheMut.Lock()
		purchaseInsertCache[key] = cache
		purchaseInsertCacheMut.Unlock()
	}
	return nil
}
func (o *Purchase) UpdateG(columns boil.Columns) error {
	return o.Update(boil.GetDB(), columns)
}