1135 lines
34 KiB
Go
1135 lines
34 KiB
Go
|
// Code generated by SQLBoiler 3.7.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
|
||
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
||
|
|
||
|
package model
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
"fmt"
|
||
|
"reflect"
|
||
|
"strconv"
|
||
|
"strings"
|
||
|
"sync"
|
||
|
"time"
|
||
|
|
||
|
"github.com/friendsofgo/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"
|
||
|
)
|
||
|
|
||
|
// Thumbnail is an object representing the database table.
|
||
|
type Thumbnail struct {
|
||
|
ID uint64 `boil:"id" json:"id" toml:"id" yaml:"id"`
|
||
|
Name string `boil:"name" json:"name" toml:"name" yaml:"name"`
|
||
|
CompressedName null.String `boil:"compressed_name" json:"compressed_name,omitempty" toml:"compressed_name" yaml:"compressed_name,omitempty"`
|
||
|
CompressedMimeType null.String `boil:"compressed_mime_type" json:"compressed_mime_type,omitempty" toml:"compressed_mime_type" yaml:"compressed_mime_type,omitempty"`
|
||
|
Compressed bool `boil:"compressed" json:"compressed" toml:"compressed" yaml:"compressed"`
|
||
|
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"`
|
||
|
|
||
|
R *thumbnailR `boil:"-" json:"-" toml:"-" yaml:"-"`
|
||
|
L thumbnailL `boil:"-" json:"-" toml:"-" yaml:"-"`
|
||
|
}
|
||
|
|
||
|
var ThumbnailColumns = struct {
|
||
|
ID string
|
||
|
Name string
|
||
|
CompressedName string
|
||
|
CompressedMimeType string
|
||
|
Compressed string
|
||
|
CreatedAt string
|
||
|
UpdatedAt string
|
||
|
}{
|
||
|
ID: "id",
|
||
|
Name: "name",
|
||
|
CompressedName: "compressed_name",
|
||
|
CompressedMimeType: "compressed_mime_type",
|
||
|
Compressed: "compressed",
|
||
|
CreatedAt: "created_at",
|
||
|
UpdatedAt: "updated_at",
|
||
|
}
|
||
|
|
||
|
// Generated where
|
||
|
|
||
|
type whereHelperuint64 struct{ field string }
|
||
|
|
||
|
func (w whereHelperuint64) EQ(x uint64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) }
|
||
|
func (w whereHelperuint64) NEQ(x uint64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) }
|
||
|
func (w whereHelperuint64) LT(x uint64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) }
|
||
|
func (w whereHelperuint64) LTE(x uint64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) }
|
||
|
func (w whereHelperuint64) GT(x uint64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) }
|
||
|
func (w whereHelperuint64) GTE(x uint64) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) }
|
||
|
func (w whereHelperuint64) IN(slice []uint64) 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...)
|
||
|
}
|
||
|
|
||
|
type whereHelperstring struct{ field string }
|
||
|
|
||
|
func (w whereHelperstring) EQ(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) }
|
||
|
func (w whereHelperstring) NEQ(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) }
|
||
|
func (w whereHelperstring) LT(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) }
|
||
|
func (w whereHelperstring) LTE(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) }
|
||
|
func (w whereHelperstring) GT(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) }
|
||
|
func (w whereHelperstring) GTE(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) }
|
||
|
func (w whereHelperstring) IN(slice []string) 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...)
|
||
|
}
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
type whereHelperbool struct{ field string }
|
||
|
|
||
|
func (w whereHelperbool) EQ(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) }
|
||
|
func (w whereHelperbool) NEQ(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) }
|
||
|
func (w whereHelperbool) LT(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) }
|
||
|
func (w whereHelperbool) LTE(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) }
|
||
|
func (w whereHelperbool) GT(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) }
|
||
|
func (w whereHelperbool) GTE(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) }
|
||
|
|
||
|
type whereHelpertime_Time struct{ field string }
|
||
|
|
||
|
func (w whereHelpertime_Time) EQ(x time.Time) qm.QueryMod {
|
||
|
return qmhelper.Where(w.field, qmhelper.EQ, x)
|
||
|
}
|
||
|
func (w whereHelpertime_Time) NEQ(x time.Time) qm.QueryMod {
|
||
|
return qmhelper.Where(w.field, qmhelper.NEQ, x)
|
||
|
}
|
||
|
func (w whereHelpertime_Time) LT(x time.Time) qm.QueryMod {
|
||
|
return qmhelper.Where(w.field, qmhelper.LT, x)
|
||
|
}
|
||
|
func (w whereHelpertime_Time) LTE(x time.Time) qm.QueryMod {
|
||
|
return qmhelper.Where(w.field, qmhelper.LTE, x)
|
||
|
}
|
||
|
func (w whereHelpertime_Time) GT(x time.Time) qm.QueryMod {
|
||
|
return qmhelper.Where(w.field, qmhelper.GT, x)
|
||
|
}
|
||
|
func (w whereHelpertime_Time) GTE(x time.Time) qm.QueryMod {
|
||
|
return qmhelper.Where(w.field, qmhelper.GTE, x)
|
||
|
}
|
||
|
|
||
|
var ThumbnailWhere = struct {
|
||
|
ID whereHelperuint64
|
||
|
Name whereHelperstring
|
||
|
CompressedName whereHelpernull_String
|
||
|
CompressedMimeType whereHelpernull_String
|
||
|
Compressed whereHelperbool
|
||
|
CreatedAt whereHelpertime_Time
|
||
|
UpdatedAt whereHelpertime_Time
|
||
|
}{
|
||
|
ID: whereHelperuint64{field: "`thumbnail`.`id`"},
|
||
|
Name: whereHelperstring{field: "`thumbnail`.`name`"},
|
||
|
CompressedName: whereHelpernull_String{field: "`thumbnail`.`compressed_name`"},
|
||
|
CompressedMimeType: whereHelpernull_String{field: "`thumbnail`.`compressed_mime_type`"},
|
||
|
Compressed: whereHelperbool{field: "`thumbnail`.`compressed`"},
|
||
|
CreatedAt: whereHelpertime_Time{field: "`thumbnail`.`created_at`"},
|
||
|
UpdatedAt: whereHelpertime_Time{field: "`thumbnail`.`updated_at`"},
|
||
|
}
|
||
|
|
||
|
// ThumbnailRels is where relationship names are stored.
|
||
|
var ThumbnailRels = struct {
|
||
|
}{}
|
||
|
|
||
|
// thumbnailR is where relationships are stored.
|
||
|
type thumbnailR struct {
|
||
|
}
|
||
|
|
||
|
// NewStruct creates a new relationship struct
|
||
|
func (*thumbnailR) NewStruct() *thumbnailR {
|
||
|
return &thumbnailR{}
|
||
|
}
|
||
|
|
||
|
// thumbnailL is where Load methods for each relationship are stored.
|
||
|
type thumbnailL struct{}
|
||
|
|
||
|
var (
|
||
|
thumbnailAllColumns = []string{"id", "name", "compressed_name", "compressed_mime_type", "compressed", "created_at", "updated_at"}
|
||
|
thumbnailColumnsWithoutDefault = []string{"name", "compressed_name", "compressed_mime_type", "compressed"}
|
||
|
thumbnailColumnsWithDefault = []string{"id", "created_at", "updated_at"}
|
||
|
thumbnailPrimaryKeyColumns = []string{"id"}
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
// ThumbnailSlice is an alias for a slice of pointers to Thumbnail.
|
||
|
// This should generally be used opposed to []Thumbnail.
|
||
|
ThumbnailSlice []*Thumbnail
|
||
|
|
||
|
thumbnailQuery struct {
|
||
|
*queries.Query
|
||
|
}
|
||
|
)
|
||
|
|
||
|
// Cache for insert, update and upsert
|
||
|
var (
|
||
|
thumbnailType = reflect.TypeOf(&Thumbnail{})
|
||
|
thumbnailMapping = queries.MakeStructMapping(thumbnailType)
|
||
|
thumbnailPrimaryKeyMapping, _ = queries.BindMapping(thumbnailType, thumbnailMapping, thumbnailPrimaryKeyColumns)
|
||
|
thumbnailInsertCacheMut sync.RWMutex
|
||
|
thumbnailInsertCache = make(map[string]insertCache)
|
||
|
thumbnailUpdateCacheMut sync.RWMutex
|
||
|
thumbnailUpdateCache = make(map[string]updateCache)
|
||
|
thumbnailUpsertCacheMut sync.RWMutex
|
||
|
thumbnailUpsertCache = 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
|
||
|
)
|
||
|
|
||
|
// OneG returns a single thumbnail record from the query using the global executor.
|
||
|
func (q thumbnailQuery) OneG() (*Thumbnail, error) {
|
||
|
return q.One(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// OneGP returns a single thumbnail record from the query using the global executor, and panics on error.
|
||
|
func (q thumbnailQuery) OneGP() *Thumbnail {
|
||
|
o, err := q.One(boil.GetDB())
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return o
|
||
|
}
|
||
|
|
||
|
// OneP returns a single thumbnail record from the query, and panics on error.
|
||
|
func (q thumbnailQuery) OneP(exec boil.Executor) *Thumbnail {
|
||
|
o, err := q.One(exec)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return o
|
||
|
}
|
||
|
|
||
|
// One returns a single thumbnail record from the query.
|
||
|
func (q thumbnailQuery) One(exec boil.Executor) (*Thumbnail, error) {
|
||
|
o := &Thumbnail{}
|
||
|
|
||
|
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 thumbnail")
|
||
|
}
|
||
|
|
||
|
return o, nil
|
||
|
}
|
||
|
|
||
|
// AllG returns all Thumbnail records from the query using the global executor.
|
||
|
func (q thumbnailQuery) AllG() (ThumbnailSlice, error) {
|
||
|
return q.All(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// AllGP returns all Thumbnail records from the query using the global executor, and panics on error.
|
||
|
func (q thumbnailQuery) AllGP() ThumbnailSlice {
|
||
|
o, err := q.All(boil.GetDB())
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return o
|
||
|
}
|
||
|
|
||
|
// AllP returns all Thumbnail records from the query, and panics on error.
|
||
|
func (q thumbnailQuery) AllP(exec boil.Executor) ThumbnailSlice {
|
||
|
o, err := q.All(exec)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return o
|
||
|
}
|
||
|
|
||
|
// All returns all Thumbnail records from the query.
|
||
|
func (q thumbnailQuery) All(exec boil.Executor) (ThumbnailSlice, error) {
|
||
|
var o []*Thumbnail
|
||
|
|
||
|
err := q.Bind(nil, exec, &o)
|
||
|
if err != nil {
|
||
|
return nil, errors.Wrap(err, "model: failed to assign all query results to Thumbnail slice")
|
||
|
}
|
||
|
|
||
|
return o, nil
|
||
|
}
|
||
|
|
||
|
// CountG returns the count of all Thumbnail records in the query, and panics on error.
|
||
|
func (q thumbnailQuery) CountG() (int64, error) {
|
||
|
return q.Count(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// CountGP returns the count of all Thumbnail records in the query using the global executor, and panics on error.
|
||
|
func (q thumbnailQuery) CountGP() int64 {
|
||
|
c, err := q.Count(boil.GetDB())
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return c
|
||
|
}
|
||
|
|
||
|
// CountP returns the count of all Thumbnail records in the query, and panics on error.
|
||
|
func (q thumbnailQuery) CountP(exec boil.Executor) int64 {
|
||
|
c, err := q.Count(exec)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return c
|
||
|
}
|
||
|
|
||
|
// Count returns the count of all Thumbnail records in the query.
|
||
|
func (q thumbnailQuery) 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 thumbnail rows")
|
||
|
}
|
||
|
|
||
|
return count, nil
|
||
|
}
|
||
|
|
||
|
// ExistsG checks if the row exists in the table, and panics on error.
|
||
|
func (q thumbnailQuery) ExistsG() (bool, error) {
|
||
|
return q.Exists(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// ExistsGP checks if the row exists in the table using the global executor, and panics on error.
|
||
|
func (q thumbnailQuery) ExistsGP() bool {
|
||
|
e, err := q.Exists(boil.GetDB())
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// ExistsP checks if the row exists in the table, and panics on error.
|
||
|
func (q thumbnailQuery) ExistsP(exec boil.Executor) bool {
|
||
|
e, err := q.Exists(exec)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// Exists checks if the row exists in the table.
|
||
|
func (q thumbnailQuery) 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 thumbnail exists")
|
||
|
}
|
||
|
|
||
|
return count > 0, nil
|
||
|
}
|
||
|
|
||
|
// Thumbnails retrieves all the records using an executor.
|
||
|
func Thumbnails(mods ...qm.QueryMod) thumbnailQuery {
|
||
|
mods = append(mods, qm.From("`thumbnail`"))
|
||
|
return thumbnailQuery{NewQuery(mods...)}
|
||
|
}
|
||
|
|
||
|
// FindThumbnailG retrieves a single record by ID.
|
||
|
func FindThumbnailG(iD uint64, selectCols ...string) (*Thumbnail, error) {
|
||
|
return FindThumbnail(boil.GetDB(), iD, selectCols...)
|
||
|
}
|
||
|
|
||
|
// FindThumbnailP retrieves a single record by ID with an executor, and panics on error.
|
||
|
func FindThumbnailP(exec boil.Executor, iD uint64, selectCols ...string) *Thumbnail {
|
||
|
retobj, err := FindThumbnail(exec, iD, selectCols...)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return retobj
|
||
|
}
|
||
|
|
||
|
// FindThumbnailGP retrieves a single record by ID, and panics on error.
|
||
|
func FindThumbnailGP(iD uint64, selectCols ...string) *Thumbnail {
|
||
|
retobj, err := FindThumbnail(boil.GetDB(), iD, selectCols...)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return retobj
|
||
|
}
|
||
|
|
||
|
// FindThumbnail retrieves a single record by ID with an executor.
|
||
|
// If selectCols is empty Find will return all columns.
|
||
|
func FindThumbnail(exec boil.Executor, iD uint64, selectCols ...string) (*Thumbnail, error) {
|
||
|
thumbnailObj := &Thumbnail{}
|
||
|
|
||
|
sel := "*"
|
||
|
if len(selectCols) > 0 {
|
||
|
sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
|
||
|
}
|
||
|
query := fmt.Sprintf(
|
||
|
"select %s from `thumbnail` where `id`=?", sel,
|
||
|
)
|
||
|
|
||
|
q := queries.Raw(query, iD)
|
||
|
|
||
|
err := q.Bind(nil, exec, thumbnailObj)
|
||
|
if err != nil {
|
||
|
if errors.Cause(err) == sql.ErrNoRows {
|
||
|
return nil, sql.ErrNoRows
|
||
|
}
|
||
|
return nil, errors.Wrap(err, "model: unable to select from thumbnail")
|
||
|
}
|
||
|
|
||
|
return thumbnailObj, nil
|
||
|
}
|
||
|
|
||
|
// InsertG a single record. See Insert for whitelist behavior description.
|
||
|
func (o *Thumbnail) InsertG(columns boil.Columns) error {
|
||
|
return o.Insert(boil.GetDB(), columns)
|
||
|
}
|
||
|
|
||
|
// InsertP a single record using an executor, and panics on error. See Insert
|
||
|
// for whitelist behavior description.
|
||
|
func (o *Thumbnail) InsertP(exec boil.Executor, columns boil.Columns) {
|
||
|
if err := o.Insert(exec, columns); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// InsertGP a single record, and panics on error. See Insert for whitelist
|
||
|
// behavior description.
|
||
|
func (o *Thumbnail) InsertGP(columns boil.Columns) {
|
||
|
if err := o.Insert(boil.GetDB(), columns); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Insert a single record using an executor.
|
||
|
// See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts.
|
||
|
func (o *Thumbnail) Insert(exec boil.Executor, columns boil.Columns) error {
|
||
|
if o == nil {
|
||
|
return errors.New("model: no thumbnail provided for insertion")
|
||
|
}
|
||
|
|
||
|
var err error
|
||
|
|
||
|
nzDefaults := queries.NonZeroDefaultSet(thumbnailColumnsWithDefault, o)
|
||
|
|
||
|
key := makeCacheKey(columns, nzDefaults)
|
||
|
thumbnailInsertCacheMut.RLock()
|
||
|
cache, cached := thumbnailInsertCache[key]
|
||
|
thumbnailInsertCacheMut.RUnlock()
|
||
|
|
||
|
if !cached {
|
||
|
wl, returnColumns := columns.InsertColumnSet(
|
||
|
thumbnailAllColumns,
|
||
|
thumbnailColumnsWithDefault,
|
||
|
thumbnailColumnsWithoutDefault,
|
||
|
nzDefaults,
|
||
|
)
|
||
|
|
||
|
cache.valueMapping, err = queries.BindMapping(thumbnailType, thumbnailMapping, wl)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
cache.retMapping, err = queries.BindMapping(thumbnailType, thumbnailMapping, returnColumns)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if len(wl) != 0 {
|
||
|
cache.query = fmt.Sprintf("INSERT INTO `thumbnail` (`%s`) %%sVALUES (%s)%%s", strings.Join(wl, "`,`"), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1))
|
||
|
} else {
|
||
|
cache.query = "INSERT INTO `thumbnail` () VALUES ()%s%s"
|
||
|
}
|
||
|
|
||
|
var queryOutput, queryReturning string
|
||
|
|
||
|
if len(cache.retMapping) != 0 {
|
||
|
cache.retQuery = fmt.Sprintf("SELECT `%s` FROM `thumbnail` WHERE %s", strings.Join(returnColumns, "`,`"), strmangle.WhereClause("`", "`", 0, thumbnailPrimaryKeyColumns))
|
||
|
}
|
||
|
|
||
|
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 thumbnail")
|
||
|
}
|
||
|
|
||
|
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] == thumbnailMapping["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 thumbnail")
|
||
|
}
|
||
|
|
||
|
CacheNoHooks:
|
||
|
if !cached {
|
||
|
thumbnailInsertCacheMut.Lock()
|
||
|
thumbnailInsertCache[key] = cache
|
||
|
thumbnailInsertCacheMut.Unlock()
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// UpdateG a single Thumbnail record using the global executor.
|
||
|
// See Update for more documentation.
|
||
|
func (o *Thumbnail) UpdateG(columns boil.Columns) error {
|
||
|
return o.Update(boil.GetDB(), columns)
|
||
|
}
|
||
|
|
||
|
// UpdateP uses an executor to update the Thumbnail, and panics on error.
|
||
|
// See Update for more documentation.
|
||
|
func (o *Thumbnail) UpdateP(exec boil.Executor, columns boil.Columns) {
|
||
|
err := o.Update(exec, columns)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// UpdateGP a single Thumbnail record using the global executor. Panics on error.
|
||
|
// See Update for more documentation.
|
||
|
func (o *Thumbnail) UpdateGP(columns boil.Columns) {
|
||
|
err := o.Update(boil.GetDB(), columns)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Update uses an executor to update the Thumbnail.
|
||
|
// 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 *Thumbnail) Update(exec boil.Executor, columns boil.Columns) error {
|
||
|
var err error
|
||
|
key := makeCacheKey(columns, nil)
|
||
|
thumbnailUpdateCacheMut.RLock()
|
||
|
cache, cached := thumbnailUpdateCache[key]
|
||
|
thumbnailUpdateCacheMut.RUnlock()
|
||
|
|
||
|
if !cached {
|
||
|
wl := columns.UpdateColumnSet(
|
||
|
thumbnailAllColumns,
|
||
|
thumbnailPrimaryKeyColumns,
|
||
|
)
|
||
|
|
||
|
if len(wl) == 0 {
|
||
|
return errors.New("model: unable to update thumbnail, could not build whitelist")
|
||
|
}
|
||
|
|
||
|
cache.query = fmt.Sprintf("UPDATE `thumbnail` SET %s WHERE %s",
|
||
|
strmangle.SetParamNames("`", "`", 0, wl),
|
||
|
strmangle.WhereClause("`", "`", 0, thumbnailPrimaryKeyColumns),
|
||
|
)
|
||
|
cache.valueMapping, err = queries.BindMapping(thumbnailType, thumbnailMapping, append(wl, thumbnailPrimaryKeyColumns...))
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping)
|
||
|
|
||
|
if boil.DebugMode {
|
||
|
fmt.Fprintln(boil.DebugWriter, cache.query)
|
||
|
fmt.Fprintln(boil.DebugWriter, values)
|
||
|
}
|
||
|
_, err = exec.Exec(cache.query, values...)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to update thumbnail row")
|
||
|
}
|
||
|
|
||
|
if !cached {
|
||
|
thumbnailUpdateCacheMut.Lock()
|
||
|
thumbnailUpdateCache[key] = cache
|
||
|
thumbnailUpdateCacheMut.Unlock()
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// UpdateAllP updates all rows with matching column names, and panics on error.
|
||
|
func (q thumbnailQuery) UpdateAllP(exec boil.Executor, cols M) {
|
||
|
err := q.UpdateAll(exec, cols)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// UpdateAllG updates all rows with the specified column values.
|
||
|
func (q thumbnailQuery) UpdateAllG(cols M) error {
|
||
|
return q.UpdateAll(boil.GetDB(), cols)
|
||
|
}
|
||
|
|
||
|
// UpdateAll updates all rows with the specified column values.
|
||
|
func (q thumbnailQuery) UpdateAll(exec boil.Executor, cols M) error {
|
||
|
queries.SetUpdate(q.Query, cols)
|
||
|
|
||
|
_, err := q.Query.Exec(exec)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to update all for thumbnail")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// UpdateAllG updates all rows with the specified column values.
|
||
|
func (o ThumbnailSlice) UpdateAllG(cols M) error {
|
||
|
return o.UpdateAll(boil.GetDB(), cols)
|
||
|
}
|
||
|
|
||
|
// UpdateAllGP updates all rows with the specified column values, and panics on error.
|
||
|
func (o ThumbnailSlice) UpdateAllGP(cols M) {
|
||
|
err := o.UpdateAll(boil.GetDB(), cols)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// UpdateAllP updates all rows with the specified column values, and panics on error.
|
||
|
func (o ThumbnailSlice) UpdateAllP(exec boil.Executor, cols M) {
|
||
|
err := o.UpdateAll(exec, cols)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// UpdateAll updates all rows with the specified column values, using an executor.
|
||
|
func (o ThumbnailSlice) UpdateAll(exec boil.Executor, cols M) error {
|
||
|
ln := int64(len(o))
|
||
|
if ln == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if len(cols) == 0 {
|
||
|
return errors.New("model: 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)), thumbnailPrimaryKeyMapping)
|
||
|
args = append(args, pkeyArgs...)
|
||
|
}
|
||
|
|
||
|
sql := fmt.Sprintf("UPDATE `thumbnail` SET %s WHERE %s",
|
||
|
strmangle.SetParamNames("`", "`", 0, colNames),
|
||
|
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, thumbnailPrimaryKeyColumns, len(o)))
|
||
|
|
||
|
if boil.DebugMode {
|
||
|
fmt.Fprintln(boil.DebugWriter, sql)
|
||
|
fmt.Fprintln(boil.DebugWriter, args...)
|
||
|
}
|
||
|
_, err := exec.Exec(sql, args...)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to update all in thumbnail slice")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// UpsertG attempts an insert, and does an update or ignore on conflict.
|
||
|
func (o *Thumbnail) UpsertG(updateColumns, insertColumns boil.Columns) error {
|
||
|
return o.Upsert(boil.GetDB(), updateColumns, insertColumns)
|
||
|
}
|
||
|
|
||
|
// UpsertGP attempts an insert, and does an update or ignore on conflict. Panics on error.
|
||
|
func (o *Thumbnail) UpsertGP(updateColumns, insertColumns boil.Columns) {
|
||
|
if err := o.Upsert(boil.GetDB(), updateColumns, insertColumns); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// UpsertP attempts an insert using an executor, and does an update or ignore on conflict.
|
||
|
// UpsertP panics on error.
|
||
|
func (o *Thumbnail) UpsertP(exec boil.Executor, updateColumns, insertColumns boil.Columns) {
|
||
|
if err := o.Upsert(exec, updateColumns, insertColumns); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var mySQLThumbnailUniqueColumns = []string{
|
||
|
"id",
|
||
|
"name",
|
||
|
"compressed_name",
|
||
|
}
|
||
|
|
||
|
// 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 *Thumbnail) Upsert(exec boil.Executor, updateColumns, insertColumns boil.Columns) error {
|
||
|
if o == nil {
|
||
|
return errors.New("model: no thumbnail provided for upsert")
|
||
|
}
|
||
|
|
||
|
nzDefaults := queries.NonZeroDefaultSet(thumbnailColumnsWithDefault, o)
|
||
|
nzUniques := queries.NonZeroDefaultSet(mySQLThumbnailUniqueColumns, o)
|
||
|
|
||
|
if len(nzUniques) == 0 {
|
||
|
return errors.New("cannot upsert with a table that cannot conflict on a unique column")
|
||
|
}
|
||
|
|
||
|
// Build cache key in-line uglily - mysql vs psql problems
|
||
|
buf := strmangle.GetBuffer()
|
||
|
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)
|
||
|
}
|
||
|
buf.WriteByte('.')
|
||
|
for _, c := range nzUniques {
|
||
|
buf.WriteString(c)
|
||
|
}
|
||
|
key := buf.String()
|
||
|
strmangle.PutBuffer(buf)
|
||
|
|
||
|
thumbnailUpsertCacheMut.RLock()
|
||
|
cache, cached := thumbnailUpsertCache[key]
|
||
|
thumbnailUpsertCacheMut.RUnlock()
|
||
|
|
||
|
var err error
|
||
|
|
||
|
if !cached {
|
||
|
insert, ret := insertColumns.InsertColumnSet(
|
||
|
thumbnailAllColumns,
|
||
|
thumbnailColumnsWithDefault,
|
||
|
thumbnailColumnsWithoutDefault,
|
||
|
nzDefaults,
|
||
|
)
|
||
|
update := updateColumns.UpdateColumnSet(
|
||
|
thumbnailAllColumns,
|
||
|
thumbnailPrimaryKeyColumns,
|
||
|
)
|
||
|
|
||
|
if len(update) == 0 {
|
||
|
return errors.New("model: unable to upsert thumbnail, could not build update column list")
|
||
|
}
|
||
|
|
||
|
ret = strmangle.SetComplement(ret, nzUniques)
|
||
|
cache.query = buildUpsertQueryMySQL(dialect, "thumbnail", update, insert)
|
||
|
cache.retQuery = fmt.Sprintf(
|
||
|
"SELECT %s FROM `thumbnail` WHERE %s",
|
||
|
strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, ret), ","),
|
||
|
strmangle.WhereClause("`", "`", 0, nzUniques),
|
||
|
)
|
||
|
|
||
|
cache.valueMapping, err = queries.BindMapping(thumbnailType, thumbnailMapping, insert)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if len(ret) != 0 {
|
||
|
cache.retMapping, err = queries.BindMapping(thumbnailType, thumbnailMapping, 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)
|
||
|
}
|
||
|
result, err := exec.Exec(cache.query, vals...)
|
||
|
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to upsert for thumbnail")
|
||
|
}
|
||
|
|
||
|
var lastID int64
|
||
|
var uniqueMap []uint64
|
||
|
var nzUniqueCols []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] == thumbnailMapping["id"] {
|
||
|
goto CacheNoHooks
|
||
|
}
|
||
|
|
||
|
uniqueMap, err = queries.BindMapping(thumbnailType, thumbnailMapping, nzUniques)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to retrieve unique values for thumbnail")
|
||
|
}
|
||
|
nzUniqueCols = queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), uniqueMap)
|
||
|
|
||
|
if boil.DebugMode {
|
||
|
fmt.Fprintln(boil.DebugWriter, cache.retQuery)
|
||
|
fmt.Fprintln(boil.DebugWriter, nzUniqueCols...)
|
||
|
}
|
||
|
err = exec.QueryRow(cache.retQuery, nzUniqueCols...).Scan(returns...)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to populate default values for thumbnail")
|
||
|
}
|
||
|
|
||
|
CacheNoHooks:
|
||
|
if !cached {
|
||
|
thumbnailUpsertCacheMut.Lock()
|
||
|
thumbnailUpsertCache[key] = cache
|
||
|
thumbnailUpsertCacheMut.Unlock()
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// DeleteG deletes a single Thumbnail record.
|
||
|
// DeleteG will match against the primary key column to find the record to delete.
|
||
|
func (o *Thumbnail) DeleteG() error {
|
||
|
return o.Delete(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// DeleteP deletes a single Thumbnail record with an executor.
|
||
|
// DeleteP will match against the primary key column to find the record to delete.
|
||
|
// Panics on error.
|
||
|
func (o *Thumbnail) DeleteP(exec boil.Executor) {
|
||
|
err := o.Delete(exec)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// DeleteGP deletes a single Thumbnail record.
|
||
|
// DeleteGP will match against the primary key column to find the record to delete.
|
||
|
// Panics on error.
|
||
|
func (o *Thumbnail) DeleteGP() {
|
||
|
err := o.Delete(boil.GetDB())
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Delete deletes a single Thumbnail record with an executor.
|
||
|
// Delete will match against the primary key column to find the record to delete.
|
||
|
func (o *Thumbnail) Delete(exec boil.Executor) error {
|
||
|
if o == nil {
|
||
|
return errors.New("model: no Thumbnail provided for delete")
|
||
|
}
|
||
|
|
||
|
args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), thumbnailPrimaryKeyMapping)
|
||
|
sql := "DELETE FROM `thumbnail` WHERE `id`=?"
|
||
|
|
||
|
if boil.DebugMode {
|
||
|
fmt.Fprintln(boil.DebugWriter, sql)
|
||
|
fmt.Fprintln(boil.DebugWriter, args...)
|
||
|
}
|
||
|
_, err := exec.Exec(sql, args...)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to delete from thumbnail")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// DeleteAllP deletes all rows, and panics on error.
|
||
|
func (q thumbnailQuery) DeleteAllP(exec boil.Executor) {
|
||
|
err := q.DeleteAll(exec)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// DeleteAll deletes all matching rows.
|
||
|
func (q thumbnailQuery) DeleteAll(exec boil.Executor) error {
|
||
|
if q.Query == nil {
|
||
|
return errors.New("model: no thumbnailQuery provided for delete all")
|
||
|
}
|
||
|
|
||
|
queries.SetDelete(q.Query)
|
||
|
|
||
|
_, err := q.Query.Exec(exec)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to delete all from thumbnail")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// DeleteAllG deletes all rows in the slice.
|
||
|
func (o ThumbnailSlice) DeleteAllG() error {
|
||
|
return o.DeleteAll(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// DeleteAllP deletes all rows in the slice, using an executor, and panics on error.
|
||
|
func (o ThumbnailSlice) DeleteAllP(exec boil.Executor) {
|
||
|
err := o.DeleteAll(exec)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// DeleteAllGP deletes all rows in the slice, and panics on error.
|
||
|
func (o ThumbnailSlice) DeleteAllGP() {
|
||
|
err := o.DeleteAll(boil.GetDB())
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// DeleteAll deletes all rows in the slice, using an executor.
|
||
|
func (o ThumbnailSlice) DeleteAll(exec boil.Executor) error {
|
||
|
if len(o) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
var args []interface{}
|
||
|
for _, obj := range o {
|
||
|
pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), thumbnailPrimaryKeyMapping)
|
||
|
args = append(args, pkeyArgs...)
|
||
|
}
|
||
|
|
||
|
sql := "DELETE FROM `thumbnail` WHERE " +
|
||
|
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, thumbnailPrimaryKeyColumns, len(o))
|
||
|
|
||
|
if boil.DebugMode {
|
||
|
fmt.Fprintln(boil.DebugWriter, sql)
|
||
|
fmt.Fprintln(boil.DebugWriter, args)
|
||
|
}
|
||
|
_, err := exec.Exec(sql, args...)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to delete all from thumbnail slice")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ReloadG refetches the object from the database using the primary keys.
|
||
|
func (o *Thumbnail) ReloadG() error {
|
||
|
if o == nil {
|
||
|
return errors.New("model: no Thumbnail provided for reload")
|
||
|
}
|
||
|
|
||
|
return o.Reload(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// ReloadP refetches the object from the database with an executor. Panics on error.
|
||
|
func (o *Thumbnail) ReloadP(exec boil.Executor) {
|
||
|
if err := o.Reload(exec); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ReloadGP refetches the object from the database and panics on error.
|
||
|
func (o *Thumbnail) ReloadGP() {
|
||
|
if err := o.Reload(boil.GetDB()); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Reload refetches the object from the database
|
||
|
// using the primary keys with an executor.
|
||
|
func (o *Thumbnail) Reload(exec boil.Executor) error {
|
||
|
ret, err := FindThumbnail(exec, o.ID)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
*o = *ret
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ReloadAllG refetches every row with matching primary key column values
|
||
|
// and overwrites the original object slice with the newly updated slice.
|
||
|
func (o *ThumbnailSlice) ReloadAllG() error {
|
||
|
if o == nil {
|
||
|
return errors.New("model: empty ThumbnailSlice provided for reload all")
|
||
|
}
|
||
|
|
||
|
return o.ReloadAll(boil.GetDB())
|
||
|
}
|
||
|
|
||
|
// ReloadAllP refetches every row with matching primary key column values
|
||
|
// and overwrites the original object slice with the newly updated slice.
|
||
|
// Panics on error.
|
||
|
func (o *ThumbnailSlice) ReloadAllP(exec boil.Executor) {
|
||
|
if err := o.ReloadAll(exec); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ReloadAllGP refetches every row with matching primary key column values
|
||
|
// and overwrites the original object slice with the newly updated slice.
|
||
|
// Panics on error.
|
||
|
func (o *ThumbnailSlice) ReloadAllGP() {
|
||
|
if err := o.ReloadAll(boil.GetDB()); err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ReloadAll refetches every row with matching primary key column values
|
||
|
// and overwrites the original object slice with the newly updated slice.
|
||
|
func (o *ThumbnailSlice) ReloadAll(exec boil.Executor) error {
|
||
|
if o == nil || len(*o) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
slice := ThumbnailSlice{}
|
||
|
var args []interface{}
|
||
|
for _, obj := range *o {
|
||
|
pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), thumbnailPrimaryKeyMapping)
|
||
|
args = append(args, pkeyArgs...)
|
||
|
}
|
||
|
|
||
|
sql := "SELECT `thumbnail`.* FROM `thumbnail` WHERE " +
|
||
|
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, thumbnailPrimaryKeyColumns, len(*o))
|
||
|
|
||
|
q := queries.Raw(sql, args...)
|
||
|
|
||
|
err := q.Bind(nil, exec, &slice)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "model: unable to reload all in ThumbnailSlice")
|
||
|
}
|
||
|
|
||
|
*o = slice
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ThumbnailExistsG checks if the Thumbnail row exists.
|
||
|
func ThumbnailExistsG(iD uint64) (bool, error) {
|
||
|
return ThumbnailExists(boil.GetDB(), iD)
|
||
|
}
|
||
|
|
||
|
// ThumbnailExistsP checks if the Thumbnail row exists. Panics on error.
|
||
|
func ThumbnailExistsP(exec boil.Executor, iD uint64) bool {
|
||
|
e, err := ThumbnailExists(exec, iD)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// ThumbnailExistsGP checks if the Thumbnail row exists. Panics on error.
|
||
|
func ThumbnailExistsGP(iD uint64) bool {
|
||
|
e, err := ThumbnailExists(boil.GetDB(), iD)
|
||
|
if err != nil {
|
||
|
panic(boil.WrapErr(err))
|
||
|
}
|
||
|
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// ThumbnailExists checks if the Thumbnail row exists.
|
||
|
func ThumbnailExists(exec boil.Executor, iD uint64) (bool, error) {
|
||
|
var exists bool
|
||
|
sql := "select exists(select 1 from `thumbnail` where `id`=? limit 1)"
|
||
|
|
||
|
if boil.DebugMode {
|
||
|
fmt.Fprintln(boil.DebugWriter, sql)
|
||
|
fmt.Fprintln(boil.DebugWriter, iD)
|
||
|
}
|
||
|
row := exec.QueryRow(sql, iD)
|
||
|
|
||
|
err := row.Scan(&exists)
|
||
|
if err != nil {
|
||
|
return false, errors.Wrap(err, "model: unable to check if thumbnail exists")
|
||
|
}
|
||
|
|
||
|
return exists, nil
|
||
|
}
|