// Code generated by SQLBoiler 3.5.0-gct (https://github.com/thrasher-corp/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package postgres import ( "context" "database/sql" "fmt" "reflect" "strconv" "strings" "sync" "time" "github.com/pkg/errors" "github.com/thrasher-corp/sqlboiler/boil" "github.com/thrasher-corp/sqlboiler/queries" "github.com/thrasher-corp/sqlboiler/queries/qm" "github.com/thrasher-corp/sqlboiler/queries/qmhelper" "github.com/thrasher-corp/sqlboiler/strmangle" "github.com/volatiletech/null" ) // WithdrawalHistory is an object representing the database table. type WithdrawalHistory struct { ID string `boil:"id" json:"id" toml:"id" yaml:"id"` ExchangeID string `boil:"exchange_id" json:"exchange_id" toml:"exchange_id" yaml:"exchange_id"` Status string `boil:"status" json:"status" toml:"status" yaml:"status"` Currency string `boil:"currency" json:"currency" toml:"currency" yaml:"currency"` Amount float64 `boil:"amount" json:"amount" toml:"amount" yaml:"amount"` Description null.String `boil:"description" json:"description,omitempty" toml:"description" yaml:"description,omitempty"` WithdrawType int `boil:"withdraw_type" json:"withdraw_type" toml:"withdraw_type" yaml:"withdraw_type"` CreatedAt time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"` UpdatedAt time.Time `boil:"updated_at" json:"updated_at" toml:"updated_at" yaml:"updated_at"` ExchangeNameID string `boil:"exchange_name_id" json:"exchange_name_id" toml:"exchange_name_id" yaml:"exchange_name_id"` R *withdrawalHistoryR `boil:"-" json:"-" toml:"-" yaml:"-"` L withdrawalHistoryL `boil:"-" json:"-" toml:"-" yaml:"-"` } var WithdrawalHistoryColumns = struct { ID string ExchangeID string Status string Currency string Amount string Description string WithdrawType string CreatedAt string UpdatedAt string ExchangeNameID string }{ ID: "id", ExchangeID: "exchange_id", Status: "status", Currency: "currency", Amount: "amount", Description: "description", WithdrawType: "withdraw_type", CreatedAt: "created_at", UpdatedAt: "updated_at", ExchangeNameID: "exchange_name_id", } // Generated where type whereHelperint struct{ field string } func (w whereHelperint) EQ(x int) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) } func (w whereHelperint) NEQ(x int) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) } func (w whereHelperint) LT(x int) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) } func (w whereHelperint) LTE(x int) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) } func (w whereHelperint) GT(x int) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) } func (w whereHelperint) GTE(x int) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) } func (w whereHelperint) IN(slice []int) qm.QueryMod { values := make([]interface{}, 0, len(slice)) for _, value := range slice { values = append(values, value) } return qm.WhereIn(fmt.Sprintf("%s IN ?", w.field), values...) } var WithdrawalHistoryWhere = struct { ID whereHelperstring ExchangeID whereHelperstring Status whereHelperstring Currency whereHelperstring Amount whereHelperfloat64 Description whereHelpernull_String WithdrawType whereHelperint CreatedAt whereHelpertime_Time UpdatedAt whereHelpertime_Time ExchangeNameID whereHelperstring }{ ID: whereHelperstring{field: "\"withdrawal_history\".\"id\""}, ExchangeID: whereHelperstring{field: "\"withdrawal_history\".\"exchange_id\""}, Status: whereHelperstring{field: "\"withdrawal_history\".\"status\""}, Currency: whereHelperstring{field: "\"withdrawal_history\".\"currency\""}, Amount: whereHelperfloat64{field: "\"withdrawal_history\".\"amount\""}, Description: whereHelpernull_String{field: "\"withdrawal_history\".\"description\""}, WithdrawType: whereHelperint{field: "\"withdrawal_history\".\"withdraw_type\""}, CreatedAt: whereHelpertime_Time{field: "\"withdrawal_history\".\"created_at\""}, UpdatedAt: whereHelpertime_Time{field: "\"withdrawal_history\".\"updated_at\""}, ExchangeNameID: whereHelperstring{field: "\"withdrawal_history\".\"exchange_name_id\""}, } // WithdrawalHistoryRels is where relationship names are stored. var WithdrawalHistoryRels = struct { ExchangeName string WithdrawalCryptoWithdrawalCryptos string WithdrawalFiatWithdrawalFiats string }{ ExchangeName: "ExchangeName", WithdrawalCryptoWithdrawalCryptos: "WithdrawalCryptoWithdrawalCryptos", WithdrawalFiatWithdrawalFiats: "WithdrawalFiatWithdrawalFiats", } // withdrawalHistoryR is where relationships are stored. type withdrawalHistoryR struct { ExchangeName *Exchange WithdrawalCryptoWithdrawalCryptos WithdrawalCryptoSlice WithdrawalFiatWithdrawalFiats WithdrawalFiatSlice } // NewStruct creates a new relationship struct func (*withdrawalHistoryR) NewStruct() *withdrawalHistoryR { return &withdrawalHistoryR{} } // withdrawalHistoryL is where Load methods for each relationship are stored. type withdrawalHistoryL struct{} var ( withdrawalHistoryAllColumns = []string{"id", "exchange_id", "status", "currency", "amount", "description", "withdraw_type", "created_at", "updated_at", "exchange_name_id"} withdrawalHistoryColumnsWithoutDefault = []string{"exchange_id", "status", "currency", "amount", "description", "withdraw_type", "exchange_name_id"} withdrawalHistoryColumnsWithDefault = []string{"id", "created_at", "updated_at"} withdrawalHistoryPrimaryKeyColumns = []string{"id"} ) type ( // WithdrawalHistorySlice is an alias for a slice of pointers to WithdrawalHistory. // This should generally be used opposed to []WithdrawalHistory. WithdrawalHistorySlice []*WithdrawalHistory // WithdrawalHistoryHook is the signature for custom WithdrawalHistory hook methods WithdrawalHistoryHook func(context.Context, boil.ContextExecutor, *WithdrawalHistory) error withdrawalHistoryQuery struct { *queries.Query } ) // Cache for insert, update and upsert var ( withdrawalHistoryType = reflect.TypeOf(&WithdrawalHistory{}) withdrawalHistoryMapping = queries.MakeStructMapping(withdrawalHistoryType) withdrawalHistoryPrimaryKeyMapping, _ = queries.BindMapping(withdrawalHistoryType, withdrawalHistoryMapping, withdrawalHistoryPrimaryKeyColumns) withdrawalHistoryInsertCacheMut sync.RWMutex withdrawalHistoryInsertCache = make(map[string]insertCache) withdrawalHistoryUpdateCacheMut sync.RWMutex withdrawalHistoryUpdateCache = make(map[string]updateCache) withdrawalHistoryUpsertCacheMut sync.RWMutex withdrawalHistoryUpsertCache = make(map[string]insertCache) ) var ( // Force time package dependency for automated UpdatedAt/CreatedAt. _ = time.Second // Force qmhelper dependency for where clause generation (which doesn't // always happen) _ = qmhelper.Where ) var withdrawalHistoryBeforeInsertHooks []WithdrawalHistoryHook var withdrawalHistoryBeforeUpdateHooks []WithdrawalHistoryHook var withdrawalHistoryBeforeDeleteHooks []WithdrawalHistoryHook var withdrawalHistoryBeforeUpsertHooks []WithdrawalHistoryHook var withdrawalHistoryAfterInsertHooks []WithdrawalHistoryHook var withdrawalHistoryAfterSelectHooks []WithdrawalHistoryHook var withdrawalHistoryAfterUpdateHooks []WithdrawalHistoryHook var withdrawalHistoryAfterDeleteHooks []WithdrawalHistoryHook var withdrawalHistoryAfterUpsertHooks []WithdrawalHistoryHook // doBeforeInsertHooks executes all "before insert" hooks. func (o *WithdrawalHistory) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryBeforeInsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doBeforeUpdateHooks executes all "before Update" hooks. func (o *WithdrawalHistory) doBeforeUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryBeforeUpdateHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doBeforeDeleteHooks executes all "before Delete" hooks. func (o *WithdrawalHistory) doBeforeDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryBeforeDeleteHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doBeforeUpsertHooks executes all "before Upsert" hooks. func (o *WithdrawalHistory) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryBeforeUpsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterInsertHooks executes all "after Insert" hooks. func (o *WithdrawalHistory) doAfterInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryAfterInsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterSelectHooks executes all "after Select" hooks. func (o *WithdrawalHistory) doAfterSelectHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryAfterSelectHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterUpdateHooks executes all "after Update" hooks. func (o *WithdrawalHistory) doAfterUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryAfterUpdateHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterDeleteHooks executes all "after Delete" hooks. func (o *WithdrawalHistory) doAfterDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryAfterDeleteHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterUpsertHooks executes all "after Upsert" hooks. func (o *WithdrawalHistory) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range withdrawalHistoryAfterUpsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // AddWithdrawalHistoryHook registers your hook function for all future operations. func AddWithdrawalHistoryHook(hookPoint boil.HookPoint, withdrawalHistoryHook WithdrawalHistoryHook) { switch hookPoint { case boil.BeforeInsertHook: withdrawalHistoryBeforeInsertHooks = append(withdrawalHistoryBeforeInsertHooks, withdrawalHistoryHook) case boil.BeforeUpdateHook: withdrawalHistoryBeforeUpdateHooks = append(withdrawalHistoryBeforeUpdateHooks, withdrawalHistoryHook) case boil.BeforeDeleteHook: withdrawalHistoryBeforeDeleteHooks = append(withdrawalHistoryBeforeDeleteHooks, withdrawalHistoryHook) case boil.BeforeUpsertHook: withdrawalHistoryBeforeUpsertHooks = append(withdrawalHistoryBeforeUpsertHooks, withdrawalHistoryHook) case boil.AfterInsertHook: withdrawalHistoryAfterInsertHooks = append(withdrawalHistoryAfterInsertHooks, withdrawalHistoryHook) case boil.AfterSelectHook: withdrawalHistoryAfterSelectHooks = append(withdrawalHistoryAfterSelectHooks, withdrawalHistoryHook) case boil.AfterUpdateHook: withdrawalHistoryAfterUpdateHooks = append(withdrawalHistoryAfterUpdateHooks, withdrawalHistoryHook) case boil.AfterDeleteHook: withdrawalHistoryAfterDeleteHooks = append(withdrawalHistoryAfterDeleteHooks, withdrawalHistoryHook) case boil.AfterUpsertHook: withdrawalHistoryAfterUpsertHooks = append(withdrawalHistoryAfterUpsertHooks, withdrawalHistoryHook) } } // One returns a single withdrawalHistory record from the query. func (q withdrawalHistoryQuery) One(ctx context.Context, exec boil.ContextExecutor) (*WithdrawalHistory, error) { o := &WithdrawalHistory{} queries.SetLimit(q.Query, 1) err := q.Bind(ctx, exec, o) if err != nil { if errors.Cause(err) == sql.ErrNoRows { return nil, sql.ErrNoRows } return nil, errors.Wrap(err, "postgres: failed to execute a one query for withdrawal_history") } if err := o.doAfterSelectHooks(ctx, exec); err != nil { return o, err } return o, nil } // All returns all WithdrawalHistory records from the query. func (q withdrawalHistoryQuery) All(ctx context.Context, exec boil.ContextExecutor) (WithdrawalHistorySlice, error) { var o []*WithdrawalHistory err := q.Bind(ctx, exec, &o) if err != nil { return nil, errors.Wrap(err, "postgres: failed to assign all query results to WithdrawalHistory slice") } if len(withdrawalHistoryAfterSelectHooks) != 0 { for _, obj := range o { if err := obj.doAfterSelectHooks(ctx, exec); err != nil { return o, err } } } return o, nil } // Count returns the count of all WithdrawalHistory records in the query. func (q withdrawalHistoryQuery) Count(ctx context.Context, exec boil.ContextExecutor) (int64, error) { var count int64 queries.SetSelect(q.Query, nil) queries.SetCount(q.Query) err := q.Query.QueryRowContext(ctx, exec).Scan(&count) if err != nil { return 0, errors.Wrap(err, "postgres: failed to count withdrawal_history rows") } return count, nil } // Exists checks if the row exists in the table. func (q withdrawalHistoryQuery) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) { var count int64 queries.SetSelect(q.Query, nil) queries.SetCount(q.Query) queries.SetLimit(q.Query, 1) err := q.Query.QueryRowContext(ctx, exec).Scan(&count) if err != nil { return false, errors.Wrap(err, "postgres: failed to check if withdrawal_history exists") } return count > 0, nil } // ExchangeName pointed to by the foreign key. func (o *WithdrawalHistory) ExchangeName(mods ...qm.QueryMod) exchangeQuery { queryMods := []qm.QueryMod{ qm.Where("\"id\" = ?", o.ExchangeNameID), } queryMods = append(queryMods, mods...) query := Exchanges(queryMods...) queries.SetFrom(query.Query, "\"exchange\"") return query } // WithdrawalCryptoWithdrawalCryptos retrieves all the withdrawal_crypto's WithdrawalCryptos with an executor via withdrawal_crypto_id column. func (o *WithdrawalHistory) WithdrawalCryptoWithdrawalCryptos(mods ...qm.QueryMod) withdrawalCryptoQuery { var queryMods []qm.QueryMod if len(mods) != 0 { queryMods = append(queryMods, mods...) } queryMods = append(queryMods, qm.Where("\"withdrawal_crypto\".\"withdrawal_crypto_id\"=?", o.ID), ) query := WithdrawalCryptos(queryMods...) queries.SetFrom(query.Query, "\"withdrawal_crypto\"") if len(queries.GetSelect(query.Query)) == 0 { queries.SetSelect(query.Query, []string{"\"withdrawal_crypto\".*"}) } return query } // WithdrawalFiatWithdrawalFiats retrieves all the withdrawal_fiat's WithdrawalFiats with an executor via withdrawal_fiat_id column. func (o *WithdrawalHistory) WithdrawalFiatWithdrawalFiats(mods ...qm.QueryMod) withdrawalFiatQuery { var queryMods []qm.QueryMod if len(mods) != 0 { queryMods = append(queryMods, mods...) } queryMods = append(queryMods, qm.Where("\"withdrawal_fiat\".\"withdrawal_fiat_id\"=?", o.ID), ) query := WithdrawalFiats(queryMods...) queries.SetFrom(query.Query, "\"withdrawal_fiat\"") if len(queries.GetSelect(query.Query)) == 0 { queries.SetSelect(query.Query, []string{"\"withdrawal_fiat\".*"}) } return query } // LoadExchangeName allows an eager lookup of values, cached into the // loaded structs of the objects. This is for an N-1 relationship. func (withdrawalHistoryL) LoadExchangeName(ctx context.Context, e boil.ContextExecutor, singular bool, maybeWithdrawalHistory interface{}, mods queries.Applicator) error { var slice []*WithdrawalHistory var object *WithdrawalHistory if singular { object = maybeWithdrawalHistory.(*WithdrawalHistory) } else { slice = *maybeWithdrawalHistory.(*[]*WithdrawalHistory) } args := make([]interface{}, 0, 1) if singular { if object.R == nil { object.R = &withdrawalHistoryR{} } args = append(args, object.ExchangeNameID) } else { Outer: for _, obj := range slice { if obj.R == nil { obj.R = &withdrawalHistoryR{} } for _, a := range args { if a == obj.ExchangeNameID { continue Outer } } args = append(args, obj.ExchangeNameID) } } if len(args) == 0 { return nil } query := NewQuery(qm.From(`exchange`), qm.WhereIn(`exchange.id in ?`, args...)) if mods != nil { mods.Apply(query) } results, err := query.QueryContext(ctx, e) if err != nil { return errors.Wrap(err, "failed to eager load Exchange") } var resultSlice []*Exchange if err = queries.Bind(results, &resultSlice); err != nil { return errors.Wrap(err, "failed to bind eager loaded slice Exchange") } if err = results.Close(); err != nil { return errors.Wrap(err, "failed to close results of eager load for exchange") } if err = results.Err(); err != nil { return errors.Wrap(err, "error occurred during iteration of eager loaded relations for exchange") } if len(withdrawalHistoryAfterSelectHooks) != 0 { for _, obj := range resultSlice { if err := obj.doAfterSelectHooks(ctx, e); err != nil { return err } } } if len(resultSlice) == 0 { return nil } if singular { foreign := resultSlice[0] object.R.ExchangeName = foreign if foreign.R == nil { foreign.R = &exchangeR{} } foreign.R.ExchangeNameWithdrawalHistories = append(foreign.R.ExchangeNameWithdrawalHistories, object) return nil } for _, local := range slice { for _, foreign := range resultSlice { if local.ExchangeNameID == foreign.ID { local.R.ExchangeName = foreign if foreign.R == nil { foreign.R = &exchangeR{} } foreign.R.ExchangeNameWithdrawalHistories = append(foreign.R.ExchangeNameWithdrawalHistories, local) break } } } return nil } // LoadWithdrawalCryptoWithdrawalCryptos allows an eager lookup of values, cached into the // loaded structs of the objects. This is for a 1-M or N-M relationship. func (withdrawalHistoryL) LoadWithdrawalCryptoWithdrawalCryptos(ctx context.Context, e boil.ContextExecutor, singular bool, maybeWithdrawalHistory interface{}, mods queries.Applicator) error { var slice []*WithdrawalHistory var object *WithdrawalHistory if singular { object = maybeWithdrawalHistory.(*WithdrawalHistory) } else { slice = *maybeWithdrawalHistory.(*[]*WithdrawalHistory) } args := make([]interface{}, 0, 1) if singular { if object.R == nil { object.R = &withdrawalHistoryR{} } args = append(args, object.ID) } else { Outer: for _, obj := range slice { if obj.R == nil { obj.R = &withdrawalHistoryR{} } for _, a := range args { if queries.Equal(a, obj.ID) { continue Outer } } args = append(args, obj.ID) } } if len(args) == 0 { return nil } query := NewQuery(qm.From(`withdrawal_crypto`), qm.WhereIn(`withdrawal_crypto.withdrawal_crypto_id in ?`, args...)) if mods != nil { mods.Apply(query) } results, err := query.QueryContext(ctx, e) if err != nil { return errors.Wrap(err, "failed to eager load withdrawal_crypto") } var resultSlice []*WithdrawalCrypto if err = queries.Bind(results, &resultSlice); err != nil { return errors.Wrap(err, "failed to bind eager loaded slice withdrawal_crypto") } if err = results.Close(); err != nil { return errors.Wrap(err, "failed to close results in eager load on withdrawal_crypto") } if err = results.Err(); err != nil { return errors.Wrap(err, "error occurred during iteration of eager loaded relations for withdrawal_crypto") } if len(withdrawalCryptoAfterSelectHooks) != 0 { for _, obj := range resultSlice { if err := obj.doAfterSelectHooks(ctx, e); err != nil { return err } } } if singular { object.R.WithdrawalCryptoWithdrawalCryptos = resultSlice for _, foreign := range resultSlice { if foreign.R == nil { foreign.R = &withdrawalCryptoR{} } foreign.R.WithdrawalCrypto = object } return nil } for _, foreign := range resultSlice { for _, local := range slice { if queries.Equal(local.ID, foreign.WithdrawalCryptoID) { local.R.WithdrawalCryptoWithdrawalCryptos = append(local.R.WithdrawalCryptoWithdrawalCryptos, foreign) if foreign.R == nil { foreign.R = &withdrawalCryptoR{} } foreign.R.WithdrawalCrypto = local break } } } return nil } // LoadWithdrawalFiatWithdrawalFiats allows an eager lookup of values, cached into the // loaded structs of the objects. This is for a 1-M or N-M relationship. func (withdrawalHistoryL) LoadWithdrawalFiatWithdrawalFiats(ctx context.Context, e boil.ContextExecutor, singular bool, maybeWithdrawalHistory interface{}, mods queries.Applicator) error { var slice []*WithdrawalHistory var object *WithdrawalHistory if singular { object = maybeWithdrawalHistory.(*WithdrawalHistory) } else { slice = *maybeWithdrawalHistory.(*[]*WithdrawalHistory) } args := make([]interface{}, 0, 1) if singular { if object.R == nil { object.R = &withdrawalHistoryR{} } args = append(args, object.ID) } else { Outer: for _, obj := range slice { if obj.R == nil { obj.R = &withdrawalHistoryR{} } for _, a := range args { if queries.Equal(a, obj.ID) { continue Outer } } args = append(args, obj.ID) } } if len(args) == 0 { return nil } query := NewQuery(qm.From(`withdrawal_fiat`), qm.WhereIn(`withdrawal_fiat.withdrawal_fiat_id in ?`, args...)) if mods != nil { mods.Apply(query) } results, err := query.QueryContext(ctx, e) if err != nil { return errors.Wrap(err, "failed to eager load withdrawal_fiat") } var resultSlice []*WithdrawalFiat if err = queries.Bind(results, &resultSlice); err != nil { return errors.Wrap(err, "failed to bind eager loaded slice withdrawal_fiat") } if err = results.Close(); err != nil { return errors.Wrap(err, "failed to close results in eager load on withdrawal_fiat") } if err = results.Err(); err != nil { return errors.Wrap(err, "error occurred during iteration of eager loaded relations for withdrawal_fiat") } if len(withdrawalFiatAfterSelectHooks) != 0 { for _, obj := range resultSlice { if err := obj.doAfterSelectHooks(ctx, e); err != nil { return err } } } if singular { object.R.WithdrawalFiatWithdrawalFiats = resultSlice for _, foreign := range resultSlice { if foreign.R == nil { foreign.R = &withdrawalFiatR{} } foreign.R.WithdrawalFiat = object } return nil } for _, foreign := range resultSlice { for _, local := range slice { if queries.Equal(local.ID, foreign.WithdrawalFiatID) { local.R.WithdrawalFiatWithdrawalFiats = append(local.R.WithdrawalFiatWithdrawalFiats, foreign) if foreign.R == nil { foreign.R = &withdrawalFiatR{} } foreign.R.WithdrawalFiat = local break } } } return nil } // SetExchangeName of the withdrawalHistory to the related item. // Sets o.R.ExchangeName to related. // Adds o to related.R.ExchangeNameWithdrawalHistories. func (o *WithdrawalHistory) SetExchangeName(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Exchange) error { var err error if insert { if err = related.Insert(ctx, exec, boil.Infer()); err != nil { return errors.Wrap(err, "failed to insert into foreign table") } } updateQuery := fmt.Sprintf( "UPDATE \"withdrawal_history\" SET %s WHERE %s", strmangle.SetParamNames("\"", "\"", 1, []string{"exchange_name_id"}), strmangle.WhereClause("\"", "\"", 2, withdrawalHistoryPrimaryKeyColumns), ) values := []interface{}{related.ID, o.ID} if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, updateQuery) fmt.Fprintln(boil.DebugWriter, values) } if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil { return errors.Wrap(err, "failed to update local table") } o.ExchangeNameID = related.ID if o.R == nil { o.R = &withdrawalHistoryR{ ExchangeName: related, } } else { o.R.ExchangeName = related } if related.R == nil { related.R = &exchangeR{ ExchangeNameWithdrawalHistories: WithdrawalHistorySlice{o}, } } else { related.R.ExchangeNameWithdrawalHistories = append(related.R.ExchangeNameWithdrawalHistories, o) } return nil } // AddWithdrawalCryptoWithdrawalCryptos adds the given related objects to the existing relationships // of the withdrawal_history, optionally inserting them as new records. // Appends related to o.R.WithdrawalCryptoWithdrawalCryptos. // Sets related.R.WithdrawalCrypto appropriately. func (o *WithdrawalHistory) AddWithdrawalCryptoWithdrawalCryptos(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*WithdrawalCrypto) error { var err error for _, rel := range related { if insert { queries.Assign(&rel.WithdrawalCryptoID, o.ID) if err = rel.Insert(ctx, exec, boil.Infer()); err != nil { return errors.Wrap(err, "failed to insert into foreign table") } } else { updateQuery := fmt.Sprintf( "UPDATE \"withdrawal_crypto\" SET %s WHERE %s", strmangle.SetParamNames("\"", "\"", 1, []string{"withdrawal_crypto_id"}), strmangle.WhereClause("\"", "\"", 2, withdrawalCryptoPrimaryKeyColumns), ) values := []interface{}{o.ID, rel.ID} if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, updateQuery) fmt.Fprintln(boil.DebugWriter, values) } if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil { return errors.Wrap(err, "failed to update foreign table") } queries.Assign(&rel.WithdrawalCryptoID, o.ID) } } if o.R == nil { o.R = &withdrawalHistoryR{ WithdrawalCryptoWithdrawalCryptos: related, } } else { o.R.WithdrawalCryptoWithdrawalCryptos = append(o.R.WithdrawalCryptoWithdrawalCryptos, related...) } for _, rel := range related { if rel.R == nil { rel.R = &withdrawalCryptoR{ WithdrawalCrypto: o, } } else { rel.R.WithdrawalCrypto = o } } return nil } // SetWithdrawalCryptoWithdrawalCryptos removes all previously related items of the // withdrawal_history replacing them completely with the passed // in related items, optionally inserting them as new records. // Sets o.R.WithdrawalCrypto's WithdrawalCryptoWithdrawalCryptos accordingly. // Replaces o.R.WithdrawalCryptoWithdrawalCryptos with related. // Sets related.R.WithdrawalCrypto's WithdrawalCryptoWithdrawalCryptos accordingly. func (o *WithdrawalHistory) SetWithdrawalCryptoWithdrawalCryptos(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*WithdrawalCrypto) error { query := "update \"withdrawal_crypto\" set \"withdrawal_crypto_id\" = null where \"withdrawal_crypto_id\" = $1" values := []interface{}{o.ID} if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, query) fmt.Fprintln(boil.DebugWriter, values) } _, err := exec.ExecContext(ctx, query, values...) if err != nil { return errors.Wrap(err, "failed to remove relationships before set") } if o.R != nil { for _, rel := range o.R.WithdrawalCryptoWithdrawalCryptos { queries.SetScanner(&rel.WithdrawalCryptoID, nil) if rel.R == nil { continue } rel.R.WithdrawalCrypto = nil } o.R.WithdrawalCryptoWithdrawalCryptos = nil } return o.AddWithdrawalCryptoWithdrawalCryptos(ctx, exec, insert, related...) } // RemoveWithdrawalCryptoWithdrawalCryptos relationships from objects passed in. // Removes related items from R.WithdrawalCryptoWithdrawalCryptos (uses pointer comparison, removal does not keep order) // Sets related.R.WithdrawalCrypto. func (o *WithdrawalHistory) RemoveWithdrawalCryptoWithdrawalCryptos(ctx context.Context, exec boil.ContextExecutor, related ...*WithdrawalCrypto) error { var err error for _, rel := range related { queries.SetScanner(&rel.WithdrawalCryptoID, nil) if rel.R != nil { rel.R.WithdrawalCrypto = nil } if _, err = rel.Update(ctx, exec, boil.Whitelist("withdrawal_crypto_id")); err != nil { return err } } if o.R == nil { return nil } for _, rel := range related { for i, ri := range o.R.WithdrawalCryptoWithdrawalCryptos { if rel != ri { continue } ln := len(o.R.WithdrawalCryptoWithdrawalCryptos) if ln > 1 && i < ln-1 { o.R.WithdrawalCryptoWithdrawalCryptos[i] = o.R.WithdrawalCryptoWithdrawalCryptos[ln-1] } o.R.WithdrawalCryptoWithdrawalCryptos = o.R.WithdrawalCryptoWithdrawalCryptos[:ln-1] break } } return nil } // AddWithdrawalFiatWithdrawalFiats adds the given related objects to the existing relationships // of the withdrawal_history, optionally inserting them as new records. // Appends related to o.R.WithdrawalFiatWithdrawalFiats. // Sets related.R.WithdrawalFiat appropriately. func (o *WithdrawalHistory) AddWithdrawalFiatWithdrawalFiats(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*WithdrawalFiat) error { var err error for _, rel := range related { if insert { queries.Assign(&rel.WithdrawalFiatID, o.ID) if err = rel.Insert(ctx, exec, boil.Infer()); err != nil { return errors.Wrap(err, "failed to insert into foreign table") } } else { updateQuery := fmt.Sprintf( "UPDATE \"withdrawal_fiat\" SET %s WHERE %s", strmangle.SetParamNames("\"", "\"", 1, []string{"withdrawal_fiat_id"}), strmangle.WhereClause("\"", "\"", 2, withdrawalFiatPrimaryKeyColumns), ) values := []interface{}{o.ID, rel.ID} if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, updateQuery) fmt.Fprintln(boil.DebugWriter, values) } if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil { return errors.Wrap(err, "failed to update foreign table") } queries.Assign(&rel.WithdrawalFiatID, o.ID) } } if o.R == nil { o.R = &withdrawalHistoryR{ WithdrawalFiatWithdrawalFiats: related, } } else { o.R.WithdrawalFiatWithdrawalFiats = append(o.R.WithdrawalFiatWithdrawalFiats, related...) } for _, rel := range related { if rel.R == nil { rel.R = &withdrawalFiatR{ WithdrawalFiat: o, } } else { rel.R.WithdrawalFiat = o } } return nil } // SetWithdrawalFiatWithdrawalFiats removes all previously related items of the // withdrawal_history replacing them completely with the passed // in related items, optionally inserting them as new records. // Sets o.R.WithdrawalFiat's WithdrawalFiatWithdrawalFiats accordingly. // Replaces o.R.WithdrawalFiatWithdrawalFiats with related. // Sets related.R.WithdrawalFiat's WithdrawalFiatWithdrawalFiats accordingly. func (o *WithdrawalHistory) SetWithdrawalFiatWithdrawalFiats(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*WithdrawalFiat) error { query := "update \"withdrawal_fiat\" set \"withdrawal_fiat_id\" = null where \"withdrawal_fiat_id\" = $1" values := []interface{}{o.ID} if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, query) fmt.Fprintln(boil.DebugWriter, values) } _, err := exec.ExecContext(ctx, query, values...) if err != nil { return errors.Wrap(err, "failed to remove relationships before set") } if o.R != nil { for _, rel := range o.R.WithdrawalFiatWithdrawalFiats { queries.SetScanner(&rel.WithdrawalFiatID, nil) if rel.R == nil { continue } rel.R.WithdrawalFiat = nil } o.R.WithdrawalFiatWithdrawalFiats = nil } return o.AddWithdrawalFiatWithdrawalFiats(ctx, exec, insert, related...) } // RemoveWithdrawalFiatWithdrawalFiats relationships from objects passed in. // Removes related items from R.WithdrawalFiatWithdrawalFiats (uses pointer comparison, removal does not keep order) // Sets related.R.WithdrawalFiat. func (o *WithdrawalHistory) RemoveWithdrawalFiatWithdrawalFiats(ctx context.Context, exec boil.ContextExecutor, related ...*WithdrawalFiat) error { var err error for _, rel := range related { queries.SetScanner(&rel.WithdrawalFiatID, nil) if rel.R != nil { rel.R.WithdrawalFiat = nil } if _, err = rel.Update(ctx, exec, boil.Whitelist("withdrawal_fiat_id")); err != nil { return err } } if o.R == nil { return nil } for _, rel := range related { for i, ri := range o.R.WithdrawalFiatWithdrawalFiats { if rel != ri { continue } ln := len(o.R.WithdrawalFiatWithdrawalFiats) if ln > 1 && i < ln-1 { o.R.WithdrawalFiatWithdrawalFiats[i] = o.R.WithdrawalFiatWithdrawalFiats[ln-1] } o.R.WithdrawalFiatWithdrawalFiats = o.R.WithdrawalFiatWithdrawalFiats[:ln-1] break } } return nil } // WithdrawalHistories retrieves all the records using an executor. func WithdrawalHistories(mods ...qm.QueryMod) withdrawalHistoryQuery { mods = append(mods, qm.From("\"withdrawal_history\"")) return withdrawalHistoryQuery{NewQuery(mods...)} } // FindWithdrawalHistory retrieves a single record by ID with an executor. // If selectCols is empty Find will return all columns. func FindWithdrawalHistory(ctx context.Context, exec boil.ContextExecutor, iD string, selectCols ...string) (*WithdrawalHistory, error) { withdrawalHistoryObj := &WithdrawalHistory{} sel := "*" if len(selectCols) > 0 { sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",") } query := fmt.Sprintf( "select %s from \"withdrawal_history\" where \"id\"=$1", sel, ) q := queries.Raw(query, iD) err := q.Bind(ctx, exec, withdrawalHistoryObj) if err != nil { if errors.Cause(err) == sql.ErrNoRows { return nil, sql.ErrNoRows } return nil, errors.Wrap(err, "postgres: unable to select from withdrawal_history") } return withdrawalHistoryObj, nil } // Insert a single record using an executor. // See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts. func (o *WithdrawalHistory) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error { if o == nil { return errors.New("postgres: no withdrawal_history provided for insertion") } var err error if err := o.doBeforeInsertHooks(ctx, exec); err != nil { return err } nzDefaults := queries.NonZeroDefaultSet(withdrawalHistoryColumnsWithDefault, o) key := makeCacheKey(columns, nzDefaults) withdrawalHistoryInsertCacheMut.RLock() cache, cached := withdrawalHistoryInsertCache[key] withdrawalHistoryInsertCacheMut.RUnlock() if !cached { wl, returnColumns := columns.InsertColumnSet( withdrawalHistoryAllColumns, withdrawalHistoryColumnsWithDefault, withdrawalHistoryColumnsWithoutDefault, nzDefaults, ) cache.valueMapping, err = queries.BindMapping(withdrawalHistoryType, withdrawalHistoryMapping, wl) if err != nil { return err } cache.retMapping, err = queries.BindMapping(withdrawalHistoryType, withdrawalHistoryMapping, returnColumns) if err != nil { return err } if len(wl) != 0 { cache.query = fmt.Sprintf("INSERT INTO \"withdrawal_history\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1)) } else { cache.query = "INSERT INTO \"withdrawal_history\" %sDEFAULT VALUES%s" } var queryOutput, queryReturning string if len(cache.retMapping) != 0 { queryReturning = fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\"")) } 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) } if len(cache.retMapping) != 0 { err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...) } else { _, err = exec.ExecContext(ctx, cache.query, vals...) } if err != nil { return errors.Wrap(err, "postgres: unable to insert into withdrawal_history") } if !cached { withdrawalHistoryInsertCacheMut.Lock() withdrawalHistoryInsertCache[key] = cache withdrawalHistoryInsertCacheMut.Unlock() } return o.doAfterInsertHooks(ctx, exec) } // Update uses an executor to update the WithdrawalHistory. // See boil.Columns.UpdateColumnSet documentation to understand column list inference for updates. // Update does not automatically update the record in case of default values. Use .Reload() to refresh the records. func (o *WithdrawalHistory) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error) { var err error if err = o.doBeforeUpdateHooks(ctx, exec); err != nil { return 0, err } key := makeCacheKey(columns, nil) withdrawalHistoryUpdateCacheMut.RLock() cache, cached := withdrawalHistoryUpdateCache[key] withdrawalHistoryUpdateCacheMut.RUnlock() if !cached { wl := columns.UpdateColumnSet( withdrawalHistoryAllColumns, withdrawalHistoryPrimaryKeyColumns, ) if len(wl) == 0 { return 0, errors.New("postgres: unable to update withdrawal_history, could not build whitelist") } cache.query = fmt.Sprintf("UPDATE \"withdrawal_history\" SET %s WHERE %s", strmangle.SetParamNames("\"", "\"", 1, wl), strmangle.WhereClause("\"", "\"", len(wl)+1, withdrawalHistoryPrimaryKeyColumns), ) cache.valueMapping, err = queries.BindMapping(withdrawalHistoryType, withdrawalHistoryMapping, append(wl, withdrawalHistoryPrimaryKeyColumns...)) if err != nil { return 0, 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) } var result sql.Result result, err = exec.ExecContext(ctx, cache.query, values...) if err != nil { return 0, errors.Wrap(err, "postgres: unable to update withdrawal_history row") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "postgres: failed to get rows affected by update for withdrawal_history") } if !cached { withdrawalHistoryUpdateCacheMut.Lock() withdrawalHistoryUpdateCache[key] = cache withdrawalHistoryUpdateCacheMut.Unlock() } return rowsAff, o.doAfterUpdateHooks(ctx, exec) } // UpdateAll updates all rows with the specified column values. func (q withdrawalHistoryQuery) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) { queries.SetUpdate(q.Query, cols) result, err := q.Query.ExecContext(ctx, exec) if err != nil { return 0, errors.Wrap(err, "postgres: unable to update all for withdrawal_history") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "postgres: unable to retrieve rows affected for withdrawal_history") } return rowsAff, nil } // UpdateAll updates all rows with the specified column values, using an executor. func (o WithdrawalHistorySlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) { ln := int64(len(o)) if ln == 0 { return 0, nil } if len(cols) == 0 { return 0, errors.New("postgres: update all requires at least one column argument") } colNames := make([]string, len(cols)) args := make([]interface{}, len(cols)) i := 0 for name, value := range cols { colNames[i] = name args[i] = value i++ } // Append all of the primary key values for each column for _, obj := range o { pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), withdrawalHistoryPrimaryKeyMapping) args = append(args, pkeyArgs...) } sql := fmt.Sprintf("UPDATE \"withdrawal_history\" SET %s WHERE %s", strmangle.SetParamNames("\"", "\"", 1, colNames), strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, withdrawalHistoryPrimaryKeyColumns, len(o))) if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, sql) fmt.Fprintln(boil.DebugWriter, args...) } result, err := exec.ExecContext(ctx, sql, args...) if err != nil { return 0, errors.Wrap(err, "postgres: unable to update all in withdrawalHistory slice") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "postgres: unable to retrieve rows affected all in update all withdrawalHistory") } return rowsAff, nil } // Upsert attempts an insert using an executor, and does an update or ignore on conflict. // See boil.Columns documentation for how to properly use updateColumns and insertColumns. func (o *WithdrawalHistory) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error { if o == nil { return errors.New("postgres: no withdrawal_history provided for upsert") } if err := o.doBeforeUpsertHooks(ctx, exec); err != nil { return err } nzDefaults := queries.NonZeroDefaultSet(withdrawalHistoryColumnsWithDefault, o) // Build cache key in-line uglily - mysql vs psql problems buf := strmangle.GetBuffer() if updateOnConflict { buf.WriteByte('t') } else { buf.WriteByte('f') } buf.WriteByte('.') for _, c := range conflictColumns { buf.WriteString(c) } buf.WriteByte('.') buf.WriteString(strconv.Itoa(updateColumns.Kind)) for _, c := range updateColumns.Cols { buf.WriteString(c) } buf.WriteByte('.') buf.WriteString(strconv.Itoa(insertColumns.Kind)) for _, c := range insertColumns.Cols { buf.WriteString(c) } buf.WriteByte('.') for _, c := range nzDefaults { buf.WriteString(c) } key := buf.String() strmangle.PutBuffer(buf) withdrawalHistoryUpsertCacheMut.RLock() cache, cached := withdrawalHistoryUpsertCache[key] withdrawalHistoryUpsertCacheMut.RUnlock() var err error if !cached { insert, ret := insertColumns.InsertColumnSet( withdrawalHistoryAllColumns, withdrawalHistoryColumnsWithDefault, withdrawalHistoryColumnsWithoutDefault, nzDefaults, ) update := updateColumns.UpdateColumnSet( withdrawalHistoryAllColumns, withdrawalHistoryPrimaryKeyColumns, ) if updateOnConflict && len(update) == 0 { return errors.New("postgres: unable to upsert withdrawal_history, could not build update column list") } conflict := conflictColumns if len(conflict) == 0 { conflict = make([]string, len(withdrawalHistoryPrimaryKeyColumns)) copy(conflict, withdrawalHistoryPrimaryKeyColumns) } cache.query = buildUpsertQueryPostgres(dialect, "\"withdrawal_history\"", updateOnConflict, ret, update, conflict, insert) cache.valueMapping, err = queries.BindMapping(withdrawalHistoryType, withdrawalHistoryMapping, insert) if err != nil { return err } if len(ret) != 0 { cache.retMapping, err = queries.BindMapping(withdrawalHistoryType, withdrawalHistoryMapping, ret) if err != nil { return err } } } value := reflect.Indirect(reflect.ValueOf(o)) vals := queries.ValuesFromMapping(value, cache.valueMapping) var returns []interface{} if len(cache.retMapping) != 0 { returns = queries.PtrsFromMapping(value, cache.retMapping) } if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, cache.query) fmt.Fprintln(boil.DebugWriter, vals) } if len(cache.retMapping) != 0 { err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(returns...) if err == sql.ErrNoRows { err = nil // Postgres doesn't return anything when there's no update } } else { _, err = exec.ExecContext(ctx, cache.query, vals...) } if err != nil { return errors.Wrap(err, "postgres: unable to upsert withdrawal_history") } if !cached { withdrawalHistoryUpsertCacheMut.Lock() withdrawalHistoryUpsertCache[key] = cache withdrawalHistoryUpsertCacheMut.Unlock() } return o.doAfterUpsertHooks(ctx, exec) } // Delete deletes a single WithdrawalHistory record with an executor. // Delete will match against the primary key column to find the record to delete. func (o *WithdrawalHistory) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error) { if o == nil { return 0, errors.New("postgres: no WithdrawalHistory provided for delete") } if err := o.doBeforeDeleteHooks(ctx, exec); err != nil { return 0, err } args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), withdrawalHistoryPrimaryKeyMapping) sql := "DELETE FROM \"withdrawal_history\" WHERE \"id\"=$1" if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, sql) fmt.Fprintln(boil.DebugWriter, args...) } result, err := exec.ExecContext(ctx, sql, args...) if err != nil { return 0, errors.Wrap(err, "postgres: unable to delete from withdrawal_history") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "postgres: failed to get rows affected by delete for withdrawal_history") } if err := o.doAfterDeleteHooks(ctx, exec); err != nil { return 0, err } return rowsAff, nil } // DeleteAll deletes all matching rows. func (q withdrawalHistoryQuery) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) { if q.Query == nil { return 0, errors.New("postgres: no withdrawalHistoryQuery provided for delete all") } queries.SetDelete(q.Query) result, err := q.Query.ExecContext(ctx, exec) if err != nil { return 0, errors.Wrap(err, "postgres: unable to delete all from withdrawal_history") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "postgres: failed to get rows affected by deleteall for withdrawal_history") } return rowsAff, nil } // DeleteAll deletes all rows in the slice, using an executor. func (o WithdrawalHistorySlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) { if len(o) == 0 { return 0, nil } if len(withdrawalHistoryBeforeDeleteHooks) != 0 { for _, obj := range o { if err := obj.doBeforeDeleteHooks(ctx, exec); err != nil { return 0, err } } } var args []interface{} for _, obj := range o { pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), withdrawalHistoryPrimaryKeyMapping) args = append(args, pkeyArgs...) } sql := "DELETE FROM \"withdrawal_history\" WHERE " + strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 1, withdrawalHistoryPrimaryKeyColumns, len(o)) if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, sql) fmt.Fprintln(boil.DebugWriter, args) } result, err := exec.ExecContext(ctx, sql, args...) if err != nil { return 0, errors.Wrap(err, "postgres: unable to delete all from withdrawalHistory slice") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "postgres: failed to get rows affected by deleteall for withdrawal_history") } if len(withdrawalHistoryAfterDeleteHooks) != 0 { for _, obj := range o { if err := obj.doAfterDeleteHooks(ctx, exec); err != nil { return 0, err } } } return rowsAff, nil } // Reload refetches the object from the database // using the primary keys with an executor. func (o *WithdrawalHistory) Reload(ctx context.Context, exec boil.ContextExecutor) error { ret, err := FindWithdrawalHistory(ctx, exec, o.ID) if err != nil { return err } *o = *ret return nil } // ReloadAll refetches every row with matching primary key column values // and overwrites the original object slice with the newly updated slice. func (o *WithdrawalHistorySlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error { if o == nil || len(*o) == 0 { return nil } slice := WithdrawalHistorySlice{} var args []interface{} for _, obj := range *o { pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), withdrawalHistoryPrimaryKeyMapping) args = append(args, pkeyArgs...) } sql := "SELECT \"withdrawal_history\".* FROM \"withdrawal_history\" WHERE " + strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 1, withdrawalHistoryPrimaryKeyColumns, len(*o)) q := queries.Raw(sql, args...) err := q.Bind(ctx, exec, &slice) if err != nil { return errors.Wrap(err, "postgres: unable to reload all in WithdrawalHistorySlice") } *o = slice return nil } // WithdrawalHistoryExists checks if the WithdrawalHistory row exists. func WithdrawalHistoryExists(ctx context.Context, exec boil.ContextExecutor, iD string) (bool, error) { var exists bool sql := "select exists(select 1 from \"withdrawal_history\" where \"id\"=$1 limit 1)" if boil.DebugMode { fmt.Fprintln(boil.DebugWriter, sql) fmt.Fprintln(boil.DebugWriter, iD) } row := exec.QueryRowContext(ctx, sql, iD) err := row.Scan(&exists) if err != nil { return false, errors.Wrap(err, "postgres: unable to check if withdrawal_history exists") } return exists, nil }