Files
gocryptotrader/database/models/postgres/candle.go
Scott 48434dfd46 Feature: Candle conversion & Candle validation (#716)
* Remove old concept. Introduce new job types and candle scaling

* Adds extra processing, commands

* new concept for queued jobs. Jobs can pause. New commands to manage status

* =End of day commit designing tables and implementing prerequisites further.

* Adds postgres data history relations

* Fixes table design for sqlite. Fixes all issues from merge

* Fixes craziness of database design. Adds some functions to get related jobs

* Fixes errors

* Updates some documentation, manages prerequisite jobs a little better, adds rpc funcs

* Fixes database design and adjust repo functions

* Tests database relationship

* Test coverage of new job functions

* Finishes coverage of new functions

* Commands and RPC coverage

* New database modifications for new job types

* Adds db support of new columns. Adds conversion validation. lint

* command blurb changes

* Allows websocket test to pass consistently

* Fixes merge issue preventing datahistorymanager from starting via config

* Minor fixes for different job type processing

* Fixes rangeholder issue, fixes validation, does not address jobs not starting or wrong status

* Fixes database tests, but at what cost. Fixes dhm tests

* Fixes dhj completion issue. Adds prerequisite by nickname

* Fixes validation processing. Adds db tests and validation

* Fixes validation job processing range

* Fixes trade sql. Reduces defaults. Validation processing and errors

* Updates cli job commands. adds validation decimal. fix job validation

* Expands run job handling and tests

* Validation work

* Fixes validation processing

* candle relations. new job type. updating database design

* Adds secondary exchange support. Sets stage for candle override

* Re adds accidentally deleted relationship

* Updates loading and saving candles to have relationship data when relevant

* Now validates and replaces candle data appropriately

* Fixes getting and setting datahistory data. Neatens DHM

* Test coverage

* Updates proto for new db types. New test coverage. Secondary exchange work

* Investigation into never-ending validation jobs. Now that intervals are ruled out, now need to complete the job....

* Fixes issues with validation job completion. Fixes validation volume issue for secondary exchange

* Adds candle warning support to the backtester

* Fixes warnings

* lint and begin docs

* Documentation updates. Final testing changes

* Minor fixes

* docs, prerequisite checks, more testing

* Fixes binance trade test. Rename err

* Documentation fixes. Figure fixes

* documentation update

* Fixes remote PSQL tests

* Fix binance mock test

* Remove unnecessary JSON

* regen proto

* Some minor nit fixes

* Var usage, query sorting, log improving, sql mirroring

* Extra coverage

* Experimental removal of m.jobs and mutex. Fix messaging

* Fixes error

* Lint fixes, command description improvements. More isRunning gates

* description improvements

* Lint

* BUFF regenerate

* Rough concept to fix insertions taking up long periods of time

* New calculation for trade data. Adds batch saving

This also adds an experimental request feature to shut down lingering requests. However, its uncertain whether or not this is having any impact. Initially thought it was the trades that was taking time and not SQL. Will investigate further

* Removes experimental requester. Adds documentation. Fixes typo

* rm unused error

* re-adds more forgotten contributors

* Now with proper commit count
2021-08-05 10:27:27 +10:00

1535 lines
42 KiB
Go

// 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"
)
// Candle is an object representing the database table.
type Candle struct {
ID string `boil:"id" json:"id" toml:"id" yaml:"id"`
ExchangeNameID string `boil:"exchange_name_id" json:"exchange_name_id" toml:"exchange_name_id" yaml:"exchange_name_id"`
Base string `boil:"base" json:"base" toml:"base" yaml:"base"`
Quote string `boil:"quote" json:"quote" toml:"quote" yaml:"quote"`
Interval int64 `boil:"interval" json:"interval" toml:"interval" yaml:"interval"`
Timestamp time.Time `boil:"timestamp" json:"timestamp" toml:"timestamp" yaml:"timestamp"`
Open float64 `boil:"open" json:"open" toml:"open" yaml:"open"`
High float64 `boil:"high" json:"high" toml:"high" yaml:"high"`
Low float64 `boil:"low" json:"low" toml:"low" yaml:"low"`
Close float64 `boil:"close" json:"close" toml:"close" yaml:"close"`
Volume float64 `boil:"volume" json:"volume" toml:"volume" yaml:"volume"`
Asset string `boil:"asset" json:"asset" toml:"asset" yaml:"asset"`
SourceJobID null.String `boil:"source_job_id" json:"source_job_id,omitempty" toml:"source_job_id" yaml:"source_job_id,omitempty"`
ValidationJobID null.String `boil:"validation_job_id" json:"validation_job_id,omitempty" toml:"validation_job_id" yaml:"validation_job_id,omitempty"`
ValidationIssues null.String `boil:"validation_issues" json:"validation_issues,omitempty" toml:"validation_issues" yaml:"validation_issues,omitempty"`
R *candleR `boil:"-" json:"-" toml:"-" yaml:"-"`
L candleL `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var CandleColumns = struct {
ID string
ExchangeNameID string
Base string
Quote string
Interval string
Timestamp string
Open string
High string
Low string
Close string
Volume string
Asset string
SourceJobID string
ValidationJobID string
ValidationIssues string
}{
ID: "id",
ExchangeNameID: "exchange_name_id",
Base: "base",
Quote: "quote",
Interval: "interval",
Timestamp: "timestamp",
Open: "open",
High: "high",
Low: "low",
Close: "close",
Volume: "volume",
Asset: "asset",
SourceJobID: "source_job_id",
ValidationJobID: "validation_job_id",
ValidationIssues: "validation_issues",
}
// Generated where
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)
}
type whereHelpernull_String struct{ field string }
func (w whereHelpernull_String) EQ(x null.String) qm.QueryMod {
return qmhelper.WhereNullEQ(w.field, false, x)
}
func (w whereHelpernull_String) NEQ(x null.String) qm.QueryMod {
return qmhelper.WhereNullEQ(w.field, true, x)
}
func (w whereHelpernull_String) IsNull() qm.QueryMod { return qmhelper.WhereIsNull(w.field) }
func (w whereHelpernull_String) IsNotNull() qm.QueryMod { return qmhelper.WhereIsNotNull(w.field) }
func (w whereHelpernull_String) LT(x null.String) qm.QueryMod {
return qmhelper.Where(w.field, qmhelper.LT, x)
}
func (w whereHelpernull_String) LTE(x null.String) qm.QueryMod {
return qmhelper.Where(w.field, qmhelper.LTE, x)
}
func (w whereHelpernull_String) GT(x null.String) qm.QueryMod {
return qmhelper.Where(w.field, qmhelper.GT, x)
}
func (w whereHelpernull_String) GTE(x null.String) qm.QueryMod {
return qmhelper.Where(w.field, qmhelper.GTE, x)
}
var CandleWhere = struct {
ID whereHelperstring
ExchangeNameID whereHelperstring
Base whereHelperstring
Quote whereHelperstring
Interval whereHelperint64
Timestamp whereHelpertime_Time
Open whereHelperfloat64
High whereHelperfloat64
Low whereHelperfloat64
Close whereHelperfloat64
Volume whereHelperfloat64
Asset whereHelperstring
SourceJobID whereHelpernull_String
ValidationJobID whereHelpernull_String
ValidationIssues whereHelpernull_String
}{
ID: whereHelperstring{field: "\"candle\".\"id\""},
ExchangeNameID: whereHelperstring{field: "\"candle\".\"exchange_name_id\""},
Base: whereHelperstring{field: "\"candle\".\"base\""},
Quote: whereHelperstring{field: "\"candle\".\"quote\""},
Interval: whereHelperint64{field: "\"candle\".\"interval\""},
Timestamp: whereHelpertime_Time{field: "\"candle\".\"timestamp\""},
Open: whereHelperfloat64{field: "\"candle\".\"open\""},
High: whereHelperfloat64{field: "\"candle\".\"high\""},
Low: whereHelperfloat64{field: "\"candle\".\"low\""},
Close: whereHelperfloat64{field: "\"candle\".\"close\""},
Volume: whereHelperfloat64{field: "\"candle\".\"volume\""},
Asset: whereHelperstring{field: "\"candle\".\"asset\""},
SourceJobID: whereHelpernull_String{field: "\"candle\".\"source_job_id\""},
ValidationJobID: whereHelpernull_String{field: "\"candle\".\"validation_job_id\""},
ValidationIssues: whereHelpernull_String{field: "\"candle\".\"validation_issues\""},
}
// CandleRels is where relationship names are stored.
var CandleRels = struct {
ExchangeName string
SourceJob string
ValidationJob string
}{
ExchangeName: "ExchangeName",
SourceJob: "SourceJob",
ValidationJob: "ValidationJob",
}
// candleR is where relationships are stored.
type candleR struct {
ExchangeName *Exchange
SourceJob *Datahistoryjob
ValidationJob *Datahistoryjob
}
// NewStruct creates a new relationship struct
func (*candleR) NewStruct() *candleR {
return &candleR{}
}
// candleL is where Load methods for each relationship are stored.
type candleL struct{}
var (
candleAllColumns = []string{"id", "exchange_name_id", "base", "quote", "interval", "timestamp", "open", "high", "low", "close", "volume", "asset", "source_job_id", "validation_job_id", "validation_issues"}
candleColumnsWithoutDefault = []string{"exchange_name_id", "base", "quote", "interval", "timestamp", "open", "high", "low", "close", "volume", "asset", "source_job_id", "validation_job_id", "validation_issues"}
candleColumnsWithDefault = []string{"id"}
candlePrimaryKeyColumns = []string{"id"}
)
type (
// CandleSlice is an alias for a slice of pointers to Candle.
// This should generally be used opposed to []Candle.
CandleSlice []*Candle
// CandleHook is the signature for custom Candle hook methods
CandleHook func(context.Context, boil.ContextExecutor, *Candle) error
candleQuery struct {
*queries.Query
}
)
// Cache for insert, update and upsert
var (
candleType = reflect.TypeOf(&Candle{})
candleMapping = queries.MakeStructMapping(candleType)
candlePrimaryKeyMapping, _ = queries.BindMapping(candleType, candleMapping, candlePrimaryKeyColumns)
candleInsertCacheMut sync.RWMutex
candleInsertCache = make(map[string]insertCache)
candleUpdateCacheMut sync.RWMutex
candleUpdateCache = make(map[string]updateCache)
candleUpsertCacheMut sync.RWMutex
candleUpsertCache = 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 candleBeforeInsertHooks []CandleHook
var candleBeforeUpdateHooks []CandleHook
var candleBeforeDeleteHooks []CandleHook
var candleBeforeUpsertHooks []CandleHook
var candleAfterInsertHooks []CandleHook
var candleAfterSelectHooks []CandleHook
var candleAfterUpdateHooks []CandleHook
var candleAfterDeleteHooks []CandleHook
var candleAfterUpsertHooks []CandleHook
// doBeforeInsertHooks executes all "before insert" hooks.
func (o *Candle) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleBeforeInsertHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doBeforeUpdateHooks executes all "before Update" hooks.
func (o *Candle) doBeforeUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleBeforeUpdateHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doBeforeDeleteHooks executes all "before Delete" hooks.
func (o *Candle) doBeforeDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleBeforeDeleteHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doBeforeUpsertHooks executes all "before Upsert" hooks.
func (o *Candle) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleBeforeUpsertHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doAfterInsertHooks executes all "after Insert" hooks.
func (o *Candle) doAfterInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleAfterInsertHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doAfterSelectHooks executes all "after Select" hooks.
func (o *Candle) doAfterSelectHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleAfterSelectHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doAfterUpdateHooks executes all "after Update" hooks.
func (o *Candle) doAfterUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleAfterUpdateHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doAfterDeleteHooks executes all "after Delete" hooks.
func (o *Candle) doAfterDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleAfterDeleteHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// doAfterUpsertHooks executes all "after Upsert" hooks.
func (o *Candle) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
if boil.HooksAreSkipped(ctx) {
return nil
}
for _, hook := range candleAfterUpsertHooks {
if err := hook(ctx, exec, o); err != nil {
return err
}
}
return nil
}
// AddCandleHook registers your hook function for all future operations.
func AddCandleHook(hookPoint boil.HookPoint, candleHook CandleHook) {
switch hookPoint {
case boil.BeforeInsertHook:
candleBeforeInsertHooks = append(candleBeforeInsertHooks, candleHook)
case boil.BeforeUpdateHook:
candleBeforeUpdateHooks = append(candleBeforeUpdateHooks, candleHook)
case boil.BeforeDeleteHook:
candleBeforeDeleteHooks = append(candleBeforeDeleteHooks, candleHook)
case boil.BeforeUpsertHook:
candleBeforeUpsertHooks = append(candleBeforeUpsertHooks, candleHook)
case boil.AfterInsertHook:
candleAfterInsertHooks = append(candleAfterInsertHooks, candleHook)
case boil.AfterSelectHook:
candleAfterSelectHooks = append(candleAfterSelectHooks, candleHook)
case boil.AfterUpdateHook:
candleAfterUpdateHooks = append(candleAfterUpdateHooks, candleHook)
case boil.AfterDeleteHook:
candleAfterDeleteHooks = append(candleAfterDeleteHooks, candleHook)
case boil.AfterUpsertHook:
candleAfterUpsertHooks = append(candleAfterUpsertHooks, candleHook)
}
}
// One returns a single candle record from the query.
func (q candleQuery) One(ctx context.Context, exec boil.ContextExecutor) (*Candle, error) {
o := &Candle{}
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 candle")
}
if err := o.doAfterSelectHooks(ctx, exec); err != nil {
return o, err
}
return o, nil
}
// All returns all Candle records from the query.
func (q candleQuery) All(ctx context.Context, exec boil.ContextExecutor) (CandleSlice, error) {
var o []*Candle
err := q.Bind(ctx, exec, &o)
if err != nil {
return nil, errors.Wrap(err, "postgres: failed to assign all query results to Candle slice")
}
if len(candleAfterSelectHooks) != 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 Candle records in the query.
func (q candleQuery) 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 candle rows")
}
return count, nil
}
// Exists checks if the row exists in the table.
func (q candleQuery) 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 candle exists")
}
return count > 0, nil
}
// ExchangeName pointed to by the foreign key.
func (o *Candle) 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
}
// SourceJob pointed to by the foreign key.
func (o *Candle) SourceJob(mods ...qm.QueryMod) datahistoryjobQuery {
queryMods := []qm.QueryMod{
qm.Where("\"id\" = ?", o.SourceJobID),
}
queryMods = append(queryMods, mods...)
query := Datahistoryjobs(queryMods...)
queries.SetFrom(query.Query, "\"datahistoryjob\"")
return query
}
// ValidationJob pointed to by the foreign key.
func (o *Candle) ValidationJob(mods ...qm.QueryMod) datahistoryjobQuery {
queryMods := []qm.QueryMod{
qm.Where("\"id\" = ?", o.ValidationJobID),
}
queryMods = append(queryMods, mods...)
query := Datahistoryjobs(queryMods...)
queries.SetFrom(query.Query, "\"datahistoryjob\"")
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 (candleL) LoadExchangeName(ctx context.Context, e boil.ContextExecutor, singular bool, maybeCandle interface{}, mods queries.Applicator) error {
var slice []*Candle
var object *Candle
if singular {
object = maybeCandle.(*Candle)
} else {
slice = *maybeCandle.(*[]*Candle)
}
args := make([]interface{}, 0, 1)
if singular {
if object.R == nil {
object.R = &candleR{}
}
args = append(args, object.ExchangeNameID)
} else {
Outer:
for _, obj := range slice {
if obj.R == nil {
obj.R = &candleR{}
}
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(candleAfterSelectHooks) != 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.ExchangeNameCandles = append(foreign.R.ExchangeNameCandles, 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.ExchangeNameCandles = append(foreign.R.ExchangeNameCandles, local)
break
}
}
}
return nil
}
// LoadSourceJob allows an eager lookup of values, cached into the
// loaded structs of the objects. This is for an N-1 relationship.
func (candleL) LoadSourceJob(ctx context.Context, e boil.ContextExecutor, singular bool, maybeCandle interface{}, mods queries.Applicator) error {
var slice []*Candle
var object *Candle
if singular {
object = maybeCandle.(*Candle)
} else {
slice = *maybeCandle.(*[]*Candle)
}
args := make([]interface{}, 0, 1)
if singular {
if object.R == nil {
object.R = &candleR{}
}
if !queries.IsNil(object.SourceJobID) {
args = append(args, object.SourceJobID)
}
} else {
Outer:
for _, obj := range slice {
if obj.R == nil {
obj.R = &candleR{}
}
for _, a := range args {
if queries.Equal(a, obj.SourceJobID) {
continue Outer
}
}
if !queries.IsNil(obj.SourceJobID) {
args = append(args, obj.SourceJobID)
}
}
}
if len(args) == 0 {
return nil
}
query := NewQuery(qm.From(`datahistoryjob`), qm.WhereIn(`datahistoryjob.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 Datahistoryjob")
}
var resultSlice []*Datahistoryjob
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice Datahistoryjob")
}
if err = results.Close(); err != nil {
return errors.Wrap(err, "failed to close results of eager load for datahistoryjob")
}
if err = results.Err(); err != nil {
return errors.Wrap(err, "error occurred during iteration of eager loaded relations for datahistoryjob")
}
if len(candleAfterSelectHooks) != 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.SourceJob = foreign
if foreign.R == nil {
foreign.R = &datahistoryjobR{}
}
foreign.R.SourceJobCandles = append(foreign.R.SourceJobCandles, object)
return nil
}
for _, local := range slice {
for _, foreign := range resultSlice {
if queries.Equal(local.SourceJobID, foreign.ID) {
local.R.SourceJob = foreign
if foreign.R == nil {
foreign.R = &datahistoryjobR{}
}
foreign.R.SourceJobCandles = append(foreign.R.SourceJobCandles, local)
break
}
}
}
return nil
}
// LoadValidationJob allows an eager lookup of values, cached into the
// loaded structs of the objects. This is for an N-1 relationship.
func (candleL) LoadValidationJob(ctx context.Context, e boil.ContextExecutor, singular bool, maybeCandle interface{}, mods queries.Applicator) error {
var slice []*Candle
var object *Candle
if singular {
object = maybeCandle.(*Candle)
} else {
slice = *maybeCandle.(*[]*Candle)
}
args := make([]interface{}, 0, 1)
if singular {
if object.R == nil {
object.R = &candleR{}
}
if !queries.IsNil(object.ValidationJobID) {
args = append(args, object.ValidationJobID)
}
} else {
Outer:
for _, obj := range slice {
if obj.R == nil {
obj.R = &candleR{}
}
for _, a := range args {
if queries.Equal(a, obj.ValidationJobID) {
continue Outer
}
}
if !queries.IsNil(obj.ValidationJobID) {
args = append(args, obj.ValidationJobID)
}
}
}
if len(args) == 0 {
return nil
}
query := NewQuery(qm.From(`datahistoryjob`), qm.WhereIn(`datahistoryjob.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 Datahistoryjob")
}
var resultSlice []*Datahistoryjob
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice Datahistoryjob")
}
if err = results.Close(); err != nil {
return errors.Wrap(err, "failed to close results of eager load for datahistoryjob")
}
if err = results.Err(); err != nil {
return errors.Wrap(err, "error occurred during iteration of eager loaded relations for datahistoryjob")
}
if len(candleAfterSelectHooks) != 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.ValidationJob = foreign
if foreign.R == nil {
foreign.R = &datahistoryjobR{}
}
foreign.R.ValidationJobCandles = append(foreign.R.ValidationJobCandles, object)
return nil
}
for _, local := range slice {
for _, foreign := range resultSlice {
if queries.Equal(local.ValidationJobID, foreign.ID) {
local.R.ValidationJob = foreign
if foreign.R == nil {
foreign.R = &datahistoryjobR{}
}
foreign.R.ValidationJobCandles = append(foreign.R.ValidationJobCandles, local)
break
}
}
}
return nil
}
// SetExchangeName of the candle to the related item.
// Sets o.R.ExchangeName to related.
// Adds o to related.R.ExchangeNameCandles.
func (o *Candle) 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 \"candle\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, []string{"exchange_name_id"}),
strmangle.WhereClause("\"", "\"", 2, candlePrimaryKeyColumns),
)
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 = &candleR{
ExchangeName: related,
}
} else {
o.R.ExchangeName = related
}
if related.R == nil {
related.R = &exchangeR{
ExchangeNameCandles: CandleSlice{o},
}
} else {
related.R.ExchangeNameCandles = append(related.R.ExchangeNameCandles, o)
}
return nil
}
// SetSourceJob of the candle to the related item.
// Sets o.R.SourceJob to related.
// Adds o to related.R.SourceJobCandles.
func (o *Candle) SetSourceJob(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Datahistoryjob) 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 \"candle\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, []string{"source_job_id"}),
strmangle.WhereClause("\"", "\"", 2, candlePrimaryKeyColumns),
)
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")
}
queries.Assign(&o.SourceJobID, related.ID)
if o.R == nil {
o.R = &candleR{
SourceJob: related,
}
} else {
o.R.SourceJob = related
}
if related.R == nil {
related.R = &datahistoryjobR{
SourceJobCandles: CandleSlice{o},
}
} else {
related.R.SourceJobCandles = append(related.R.SourceJobCandles, o)
}
return nil
}
// RemoveSourceJob relationship.
// Sets o.R.SourceJob to nil.
// Removes o from all passed in related items' relationships struct (Optional).
func (o *Candle) RemoveSourceJob(ctx context.Context, exec boil.ContextExecutor, related *Datahistoryjob) error {
var err error
queries.SetScanner(&o.SourceJobID, nil)
if _, err = o.Update(ctx, exec, boil.Whitelist("source_job_id")); err != nil {
return errors.Wrap(err, "failed to update local table")
}
o.R.SourceJob = nil
if related == nil || related.R == nil {
return nil
}
for i, ri := range related.R.SourceJobCandles {
if queries.Equal(o.SourceJobID, ri.SourceJobID) {
continue
}
ln := len(related.R.SourceJobCandles)
if ln > 1 && i < ln-1 {
related.R.SourceJobCandles[i] = related.R.SourceJobCandles[ln-1]
}
related.R.SourceJobCandles = related.R.SourceJobCandles[:ln-1]
break
}
return nil
}
// SetValidationJob of the candle to the related item.
// Sets o.R.ValidationJob to related.
// Adds o to related.R.ValidationJobCandles.
func (o *Candle) SetValidationJob(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Datahistoryjob) 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 \"candle\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, []string{"validation_job_id"}),
strmangle.WhereClause("\"", "\"", 2, candlePrimaryKeyColumns),
)
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")
}
queries.Assign(&o.ValidationJobID, related.ID)
if o.R == nil {
o.R = &candleR{
ValidationJob: related,
}
} else {
o.R.ValidationJob = related
}
if related.R == nil {
related.R = &datahistoryjobR{
ValidationJobCandles: CandleSlice{o},
}
} else {
related.R.ValidationJobCandles = append(related.R.ValidationJobCandles, o)
}
return nil
}
// RemoveValidationJob relationship.
// Sets o.R.ValidationJob to nil.
// Removes o from all passed in related items' relationships struct (Optional).
func (o *Candle) RemoveValidationJob(ctx context.Context, exec boil.ContextExecutor, related *Datahistoryjob) error {
var err error
queries.SetScanner(&o.ValidationJobID, nil)
if _, err = o.Update(ctx, exec, boil.Whitelist("validation_job_id")); err != nil {
return errors.Wrap(err, "failed to update local table")
}
o.R.ValidationJob = nil
if related == nil || related.R == nil {
return nil
}
for i, ri := range related.R.ValidationJobCandles {
if queries.Equal(o.ValidationJobID, ri.ValidationJobID) {
continue
}
ln := len(related.R.ValidationJobCandles)
if ln > 1 && i < ln-1 {
related.R.ValidationJobCandles[i] = related.R.ValidationJobCandles[ln-1]
}
related.R.ValidationJobCandles = related.R.ValidationJobCandles[:ln-1]
break
}
return nil
}
// Candles retrieves all the records using an executor.
func Candles(mods ...qm.QueryMod) candleQuery {
mods = append(mods, qm.From("\"candle\""))
return candleQuery{NewQuery(mods...)}
}
// FindCandle retrieves a single record by ID with an executor.
// If selectCols is empty Find will return all columns.
func FindCandle(ctx context.Context, exec boil.ContextExecutor, iD string, selectCols ...string) (*Candle, error) {
candleObj := &Candle{}
sel := "*"
if len(selectCols) > 0 {
sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
}
query := fmt.Sprintf(
"select %s from \"candle\" where \"id\"=$1", sel,
)
q := queries.Raw(query, iD)
err := q.Bind(ctx, exec, candleObj)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
return nil, sql.ErrNoRows
}
return nil, errors.Wrap(err, "postgres: unable to select from candle")
}
return candleObj, nil
}
// Insert a single record using an executor.
// See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts.
func (o *Candle) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error {
if o == nil {
return errors.New("postgres: no candle provided for insertion")
}
var err error
if err := o.doBeforeInsertHooks(ctx, exec); err != nil {
return err
}
nzDefaults := queries.NonZeroDefaultSet(candleColumnsWithDefault, o)
key := makeCacheKey(columns, nzDefaults)
candleInsertCacheMut.RLock()
cache, cached := candleInsertCache[key]
candleInsertCacheMut.RUnlock()
if !cached {
wl, returnColumns := columns.InsertColumnSet(
candleAllColumns,
candleColumnsWithDefault,
candleColumnsWithoutDefault,
nzDefaults,
)
cache.valueMapping, err = queries.BindMapping(candleType, candleMapping, wl)
if err != nil {
return err
}
cache.retMapping, err = queries.BindMapping(candleType, candleMapping, returnColumns)
if err != nil {
return err
}
if len(wl) != 0 {
cache.query = fmt.Sprintf("INSERT INTO \"candle\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1))
} else {
cache.query = "INSERT INTO \"candle\" %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 candle")
}
if !cached {
candleInsertCacheMut.Lock()
candleInsertCache[key] = cache
candleInsertCacheMut.Unlock()
}
return o.doAfterInsertHooks(ctx, exec)
}
// Update uses an executor to update the Candle.
// 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 *Candle) 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)
candleUpdateCacheMut.RLock()
cache, cached := candleUpdateCache[key]
candleUpdateCacheMut.RUnlock()
if !cached {
wl := columns.UpdateColumnSet(
candleAllColumns,
candlePrimaryKeyColumns,
)
if len(wl) == 0 {
return 0, errors.New("postgres: unable to update candle, could not build whitelist")
}
cache.query = fmt.Sprintf("UPDATE \"candle\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, wl),
strmangle.WhereClause("\"", "\"", len(wl)+1, candlePrimaryKeyColumns),
)
cache.valueMapping, err = queries.BindMapping(candleType, candleMapping, append(wl, candlePrimaryKeyColumns...))
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 candle row")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "postgres: failed to get rows affected by update for candle")
}
if !cached {
candleUpdateCacheMut.Lock()
candleUpdateCache[key] = cache
candleUpdateCacheMut.Unlock()
}
return rowsAff, o.doAfterUpdateHooks(ctx, exec)
}
// UpdateAll updates all rows with the specified column values.
func (q candleQuery) 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 candle")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "postgres: unable to retrieve rows affected for candle")
}
return rowsAff, nil
}
// UpdateAll updates all rows with the specified column values, using an executor.
func (o CandleSlice) 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)), candlePrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := fmt.Sprintf("UPDATE \"candle\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, colNames),
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, candlePrimaryKeyColumns, 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 candle slice")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "postgres: unable to retrieve rows affected all in update all candle")
}
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 *Candle) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error {
if o == nil {
return errors.New("postgres: no candle provided for upsert")
}
if err := o.doBeforeUpsertHooks(ctx, exec); err != nil {
return err
}
nzDefaults := queries.NonZeroDefaultSet(candleColumnsWithDefault, 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)
candleUpsertCacheMut.RLock()
cache, cached := candleUpsertCache[key]
candleUpsertCacheMut.RUnlock()
var err error
if !cached {
insert, ret := insertColumns.InsertColumnSet(
candleAllColumns,
candleColumnsWithDefault,
candleColumnsWithoutDefault,
nzDefaults,
)
update := updateColumns.UpdateColumnSet(
candleAllColumns,
candlePrimaryKeyColumns,
)
if updateOnConflict && len(update) == 0 {
return errors.New("postgres: unable to upsert candle, could not build update column list")
}
conflict := conflictColumns
if len(conflict) == 0 {
conflict = make([]string, len(candlePrimaryKeyColumns))
copy(conflict, candlePrimaryKeyColumns)
}
cache.query = buildUpsertQueryPostgres(dialect, "\"candle\"", updateOnConflict, ret, update, conflict, insert)
cache.valueMapping, err = queries.BindMapping(candleType, candleMapping, insert)
if err != nil {
return err
}
if len(ret) != 0 {
cache.retMapping, err = queries.BindMapping(candleType, candleMapping, 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 candle")
}
if !cached {
candleUpsertCacheMut.Lock()
candleUpsertCache[key] = cache
candleUpsertCacheMut.Unlock()
}
return o.doAfterUpsertHooks(ctx, exec)
}
// Delete deletes a single Candle record with an executor.
// Delete will match against the primary key column to find the record to delete.
func (o *Candle) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
if o == nil {
return 0, errors.New("postgres: no Candle provided for delete")
}
if err := o.doBeforeDeleteHooks(ctx, exec); err != nil {
return 0, err
}
args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), candlePrimaryKeyMapping)
sql := "DELETE FROM \"candle\" 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 candle")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "postgres: failed to get rows affected by delete for candle")
}
if err := o.doAfterDeleteHooks(ctx, exec); err != nil {
return 0, err
}
return rowsAff, nil
}
// DeleteAll deletes all matching rows.
func (q candleQuery) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
if q.Query == nil {
return 0, errors.New("postgres: no candleQuery 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 candle")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "postgres: failed to get rows affected by deleteall for candle")
}
return rowsAff, nil
}
// DeleteAll deletes all rows in the slice, using an executor.
func (o CandleSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
if len(o) == 0 {
return 0, nil
}
if len(candleBeforeDeleteHooks) != 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)), candlePrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := "DELETE FROM \"candle\" WHERE " +
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 1, candlePrimaryKeyColumns, 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 candle slice")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "postgres: failed to get rows affected by deleteall for candle")
}
if len(candleAfterDeleteHooks) != 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 *Candle) Reload(ctx context.Context, exec boil.ContextExecutor) error {
ret, err := FindCandle(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 *CandleSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error {
if o == nil || len(*o) == 0 {
return nil
}
slice := CandleSlice{}
var args []interface{}
for _, obj := range *o {
pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), candlePrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := "SELECT \"candle\".* FROM \"candle\" WHERE " +
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 1, candlePrimaryKeyColumns, 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 CandleSlice")
}
*o = slice
return nil
}
// CandleExists checks if the Candle row exists.
func CandleExists(ctx context.Context, exec boil.ContextExecutor, iD string) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"candle\" 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 candle exists")
}
return exists, nil
}