func (o *CollectionsContentUnit) DeleteG() error {
	if o == nil {
		return errors.New("mdbmodels: no CollectionsContentUnit provided for deletion")
	}
	return o.Delete(boil.GetDB())
}
DeleteG deletes a single CollectionsContentUnit record.
DeleteG will match against the primary key column to find the record to delete.
package mdbmodels
import (
	"bytes"
	"database/sql"
	"fmt"
	"reflect"
	"strings"
	"sync"
	"time"
	"github.com/Bnei-Baruch/sqlboiler/boil"
	"github.com/Bnei-Baruch/sqlboiler/queries"
	"github.com/Bnei-Baruch/sqlboiler/queries/qm"
	"github.com/Bnei-Baruch/sqlboiler/strmangle"
	"github.com/pkg/errors"
)
type CollectionsContentUnit struct {
	CollectionID  int64  `boil:"collection_id" json:"collection_id" toml:"collection_id" yaml:"collection_id"`
	ContentUnitID int64  `boil:"content_unit_id" json:"content_unit_id" toml:"content_unit_id" yaml:"content_unit_id"`
	Name          string `boil:"name" json:"name" toml:"name" yaml:"name"`
	Position      int    `boil:"position" json:"position" toml:"position" yaml:"position"`
	R *collectionsContentUnitR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L collectionsContentUnitL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var CollectionsContentUnitColumns = struct {
	CollectionID  string
	ContentUnitID string
	Name          string
	Position      string
}{
	CollectionID:  "collection_id",
	ContentUnitID: "content_unit_id",
	Name:          "name",
	Position:      "position",
}
type collectionsContentUnitR struct {
	Collection  *Collection
	ContentUnit *ContentUnit
}
type collectionsContentUnitL struct{}
var (
	collectionsContentUnitColumns               = []string{"collection_id", "content_unit_id", "name", "position"}
	collectionsContentUnitColumnsWithoutDefault = []string{"collection_id", "content_unit_id", "name"}
	collectionsContentUnitColumnsWithDefault    = []string{"position"}
	collectionsContentUnitPrimaryKeyColumns     = []string{"collection_id", "content_unit_id"}
)
type (
	CollectionsContentUnitSlice []*CollectionsContentUnit
	collectionsContentUnitQuery struct {
		*queries.Query
	}
)
var (
	collectionsContentUnitType                 = reflect.TypeOf(&CollectionsContentUnit{})
	collectionsContentUnitMapping              = queries.MakeStructMapping(collectionsContentUnitType)
	collectionsContentUnitPrimaryKeyMapping, _ = queries.BindMapping(collectionsContentUnitType, collectionsContentUnitMapping, collectionsContentUnitPrimaryKeyColumns)
	collectionsContentUnitInsertCacheMut       sync.RWMutex
	collectionsContentUnitInsertCache          = make(map[string]insertCache)
	collectionsContentUnitUpdateCacheMut       sync.RWMutex
	collectionsContentUnitUpdateCache          = make(map[string]updateCache)
	collectionsContentUnitUpsertCacheMut       sync.RWMutex
	collectionsContentUnitUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = bytes.MinRead
)
func (q collectionsContentUnitQuery) OneP() *CollectionsContentUnit {
	o, err := q.One()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q collectionsContentUnitQuery) One() (*CollectionsContentUnit, error) {
	o := &CollectionsContentUnit{}
	queries.SetLimit(q.Query, 1)
	err := q.Bind(o)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "mdbmodels: failed to execute a one query for collections_content_units")
	}
	return o, nil
}
func (q collectionsContentUnitQuery) AllP() CollectionsContentUnitSlice {
	o, err := q.All()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q collectionsContentUnitQuery) All() (CollectionsContentUnitSlice, error) {
	var o []*CollectionsContentUnit
	err := q.Bind(&o)
	if err != nil {
		return nil, errors.Wrap(err, "mdbmodels: failed to assign all query results to CollectionsContentUnit slice")
	}
	return o, nil
}
func (q collectionsContentUnitQuery) CountP() int64 {
	c, err := q.Count()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q collectionsContentUnitQuery) Count() (int64, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	err := q.Query.QueryRow().Scan(&count)
	if err != nil {
		return 0, errors.Wrap(err, "mdbmodels: failed to count collections_content_units rows")
	}
	return count, nil
}
func (q collectionsContentUnitQuery) ExistsP() bool {
	e, err := q.Exists()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q collectionsContentUnitQuery) Exists() (bool, error) {
	var count int64
	queries.SetCount(q.Query)
	queries.SetLimit(q.Query, 1)
	err := q.Query.QueryRow().Scan(&count)
	if err != nil {
		return false, errors.Wrap(err, "mdbmodels: failed to check if collections_content_units exists")
	}
	return count > 0, nil
}
func (o *CollectionsContentUnit) CollectionG(mods ...qm.QueryMod) collectionQuery {
	return o.Collection(boil.GetDB(), mods...)
}
func (o *CollectionsContentUnit) Collection(exec boil.Executor, mods ...qm.QueryMod) collectionQuery {
	queryMods := []qm.QueryMod{
		qm.Where("id=?", o.CollectionID),
	}
	queryMods = append(queryMods, mods...)
	query := Collections(exec, queryMods...)
	queries.SetFrom(query.Query, "\"collections\"")
	return query
}
func (o *CollectionsContentUnit) ContentUnitG(mods ...qm.QueryMod) contentUnitQuery {
	return o.ContentUnit(boil.GetDB(), mods...)
}
func (o *CollectionsContentUnit) ContentUnit(exec boil.Executor, mods ...qm.QueryMod) contentUnitQuery {
	queryMods := []qm.QueryMod{
		qm.Where("id=?", o.ContentUnitID),
	}
	queryMods = append(queryMods, mods...)
	query := ContentUnits(exec, queryMods...)
	queries.SetFrom(query.Query, "\"content_units\"")
	return query
}  
func (collectionsContentUnitL) LoadCollection(e boil.Executor, singular bool, maybeCollectionsContentUnit interface{}) error {
	var slice []*CollectionsContentUnit
	var object *CollectionsContentUnit
	count := 1
	if singular {
		object = maybeCollectionsContentUnit.(*CollectionsContentUnit)
	} else {
		slice = *maybeCollectionsContentUnit.(*[]*CollectionsContentUnit)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &collectionsContentUnitR{}
		}
		args[0] = object.CollectionID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &collectionsContentUnitR{}
			}
			args[i] = obj.CollectionID
		}
	}
	query := fmt.Sprintf(
		"select * from \"collections\" where \"id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)
	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}
	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load Collection")
	}
	defer results.Close()
	var resultSlice []*Collection
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Collection")
	}
	if len(resultSlice) == 0 {
		return nil
	}
	if singular {
		object.R.Collection = resultSlice[0]
		return nil
	}
	for _, local := range slice {
		for _, foreign := range resultSlice {
			if local.CollectionID == foreign.ID {
				local.R.Collection = foreign
				break
			}
		}
	}
	return nil
}
func (collectionsContentUnitL) LoadContentUnit(e boil.Executor, singular bool, maybeCollectionsContentUnit interface{}) error {
	var slice []*CollectionsContentUnit
	var object *CollectionsContentUnit
	count := 1
	if singular {
		object = maybeCollectionsContentUnit.(*CollectionsContentUnit)
	} else {
		slice = *maybeCollectionsContentUnit.(*[]*CollectionsContentUnit)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &collectionsContentUnitR{}
		}
		args[0] = object.ContentUnitID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &collectionsContentUnitR{}
			}
			args[i] = obj.ContentUnitID
		}
	}
	query := fmt.Sprintf(
		"select * from \"content_units\" where \"id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)
	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}
	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load ContentUnit")
	}
	defer results.Close()
	var resultSlice []*ContentUnit
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice ContentUnit")
	}
	if len(resultSlice) == 0 {
		return nil
	}
	if singular {
		object.R.ContentUnit = resultSlice[0]
		return nil
	}
	for _, local := range slice {
		for _, foreign := range resultSlice {
			if local.ContentUnitID == foreign.ID {
				local.R.ContentUnit = foreign
				break
			}
		}
	}
	return nil
}
func (o *CollectionsContentUnit) SetCollectionG(insert bool, related *Collection) error {
	return o.SetCollection(boil.GetDB(), insert, related)
}
func (o *CollectionsContentUnit) SetCollectionP(exec boil.Executor, insert bool, related *Collection) {
	if err := o.SetCollection(exec, insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) SetCollectionGP(insert bool, related *Collection) {
	if err := o.SetCollection(boil.GetDB(), insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) SetCollection(exec boil.Executor, insert bool, related *Collection) error {
	var err error
	if insert {
		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}
	updateQuery := fmt.Sprintf(
		"UPDATE \"collections_content_units\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"collection_id"}),
		strmangle.WhereClause("\"", "\"", 2, collectionsContentUnitPrimaryKeyColumns),
	)
	values := []interface{}{related.ID, o.CollectionID, o.ContentUnitID}
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, updateQuery)
		fmt.Fprintln(boil.DebugWriter, values)
	}
	if _, err = exec.Exec(updateQuery, values...); err != nil {
		return errors.Wrap(err, "failed to update local table")
	}
	o.CollectionID = related.ID
	if o.R == nil {
		o.R = &collectionsContentUnitR{
			Collection: related,
		}
	} else {
		o.R.Collection = related
	}
	if related.R == nil {
		related.R = &collectionR{
			CollectionsContentUnits: CollectionsContentUnitSlice{o},
		}
	} else {
		related.R.CollectionsContentUnits = append(related.R.CollectionsContentUnits, o)
	}
	return nil
}
func (o *CollectionsContentUnit) SetContentUnitG(insert bool, related *ContentUnit) error {
	return o.SetContentUnit(boil.GetDB(), insert, related)
}
func (o *CollectionsContentUnit) SetContentUnitP(exec boil.Executor, insert bool, related *ContentUnit) {
	if err := o.SetContentUnit(exec, insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) SetContentUnitGP(insert bool, related *ContentUnit) {
	if err := o.SetContentUnit(boil.GetDB(), insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) SetContentUnit(exec boil.Executor, insert bool, related *ContentUnit) error {
	var err error
	if insert {
		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}
	updateQuery := fmt.Sprintf(
		"UPDATE \"collections_content_units\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"content_unit_id"}),
		strmangle.WhereClause("\"", "\"", 2, collectionsContentUnitPrimaryKeyColumns),
	)
	values := []interface{}{related.ID, o.CollectionID, o.ContentUnitID}
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, updateQuery)
		fmt.Fprintln(boil.DebugWriter, values)
	}
	if _, err = exec.Exec(updateQuery, values...); err != nil {
		return errors.Wrap(err, "failed to update local table")
	}
	o.ContentUnitID = related.ID
	if o.R == nil {
		o.R = &collectionsContentUnitR{
			ContentUnit: related,
		}
	} else {
		o.R.ContentUnit = related
	}
	if related.R == nil {
		related.R = &contentUnitR{
			CollectionsContentUnits: CollectionsContentUnitSlice{o},
		}
	} else {
		related.R.CollectionsContentUnits = append(related.R.CollectionsContentUnits, o)
	}
	return nil
}
func CollectionsContentUnitsG(mods ...qm.QueryMod) collectionsContentUnitQuery {
	return CollectionsContentUnits(boil.GetDB(), mods...)
}
func CollectionsContentUnits(exec boil.Executor, mods ...qm.QueryMod) collectionsContentUnitQuery {
	mods = append(mods, qm.From("\"collections_content_units\""))
	return collectionsContentUnitQuery{NewQuery(exec, mods...)}
}
func FindCollectionsContentUnitG(collectionID int64, contentUnitID int64, selectCols ...string) (*CollectionsContentUnit, error) {
	return FindCollectionsContentUnit(boil.GetDB(), collectionID, contentUnitID, selectCols...)
}
func FindCollectionsContentUnitGP(collectionID int64, contentUnitID int64, selectCols ...string) *CollectionsContentUnit {
	retobj, err := FindCollectionsContentUnit(boil.GetDB(), collectionID, contentUnitID, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindCollectionsContentUnit(exec boil.Executor, collectionID int64, contentUnitID int64, selectCols ...string) (*CollectionsContentUnit, error) {
	collectionsContentUnitObj := &CollectionsContentUnit{}
	sel := "*"
	if len(selectCols) > 0 {
		sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
	}
	query := fmt.Sprintf(
		"select %s from \"collections_content_units\" where \"collection_id\"=$1 AND \"content_unit_id\"=$2", sel,
	)
	q := queries.Raw(exec, query, collectionID, contentUnitID)
	err := q.Bind(collectionsContentUnitObj)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "mdbmodels: unable to select from collections_content_units")
	}
	return collectionsContentUnitObj, nil
}
func FindCollectionsContentUnitP(exec boil.Executor, collectionID int64, contentUnitID int64, selectCols ...string) *CollectionsContentUnit {
	retobj, err := FindCollectionsContentUnit(exec, collectionID, contentUnitID, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func (o *CollectionsContentUnit) InsertG(whitelist ...string) error {
	return o.Insert(boil.GetDB(), whitelist...)
}
func (o *CollectionsContentUnit) InsertGP(whitelist ...string) {
	if err := o.Insert(boil.GetDB(), whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) InsertP(exec boil.Executor, whitelist ...string) {
	if err := o.Insert(exec, whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) Insert(exec boil.Executor, whitelist ...string) error {
	if o == nil {
		return errors.New("mdbmodels: no collections_content_units provided for insertion")
	}
	var err error
	nzDefaults := queries.NonZeroDefaultSet(collectionsContentUnitColumnsWithDefault, o)
	key := makeCacheKey(whitelist, nzDefaults)
	collectionsContentUnitInsertCacheMut.RLock()
	cache, cached := collectionsContentUnitInsertCache[key]
	collectionsContentUnitInsertCacheMut.RUnlock()
	if !cached {
		wl, returnColumns := strmangle.InsertColumnSet(
			collectionsContentUnitColumns,
			collectionsContentUnitColumnsWithDefault,
			collectionsContentUnitColumnsWithoutDefault,
			nzDefaults,
			whitelist,
		)
		cache.valueMapping, err = queries.BindMapping(collectionsContentUnitType, collectionsContentUnitMapping, wl)
		if err != nil {
			return err
		}
		cache.retMapping, err = queries.BindMapping(collectionsContentUnitType, collectionsContentUnitMapping, returnColumns)
		if err != nil {
			return err
		}
		if len(wl) != 0 {
			cache.query = fmt.Sprintf("INSERT INTO \"collections_content_units\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.IndexPlaceholders, len(wl), 1, 1))
		} else {
			cache.query = "INSERT INTO \"collections_content_units\" DEFAULT VALUES"
		}
		var queryOutput, queryReturning string
		if len(cache.retMapping) != 0 {
			queryReturning = fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\""))
		}
		if len(wl) != 0 {
			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.QueryRow(cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
	} else {
		_, err = exec.Exec(cache.query, vals...)
	}
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to insert into collections_content_units")
	}
	if !cached {
		collectionsContentUnitInsertCacheMut.Lock()
		collectionsContentUnitInsertCache[key] = cache
		collectionsContentUnitInsertCacheMut.Unlock()
	}
	return nil
}
func (o *CollectionsContentUnit) UpdateG(whitelist ...string) error {
	return o.Update(boil.GetDB(), whitelist...)
}
func (o *CollectionsContentUnit) UpdateGP(whitelist ...string) {
	if err := o.Update(boil.GetDB(), whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) UpdateP(exec boil.Executor, whitelist ...string) {
	err := o.Update(exec, whitelist...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) Update(exec boil.Executor, whitelist ...string) error {
	var err error
	key := makeCacheKey(whitelist, nil)
	collectionsContentUnitUpdateCacheMut.RLock()
	cache, cached := collectionsContentUnitUpdateCache[key]
	collectionsContentUnitUpdateCacheMut.RUnlock()
	if !cached {
		wl := strmangle.UpdateColumnSet(
			collectionsContentUnitColumns,
			collectionsContentUnitPrimaryKeyColumns,
			whitelist,
		)
		if len(wl) == 0 {
			return errors.New("mdbmodels: unable to update collections_content_units, could not build whitelist")
		}
		cache.query = fmt.Sprintf("UPDATE \"collections_content_units\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, wl),
			strmangle.WhereClause("\"", "\"", len(wl)+1, collectionsContentUnitPrimaryKeyColumns),
		)
		cache.valueMapping, err = queries.BindMapping(collectionsContentUnitType, collectionsContentUnitMapping, append(wl, collectionsContentUnitPrimaryKeyColumns...))
		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, "mdbmodels: unable to update collections_content_units row")
	}
	if !cached {
		collectionsContentUnitUpdateCacheMut.Lock()
		collectionsContentUnitUpdateCache[key] = cache
		collectionsContentUnitUpdateCacheMut.Unlock()
	}
	return nil
}
func (q collectionsContentUnitQuery) UpdateAllP(cols M) {
	if err := q.UpdateAll(cols); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (q collectionsContentUnitQuery) UpdateAll(cols M) error {
	queries.SetUpdate(q.Query, cols)
	_, err := q.Query.Exec()
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to update all for collections_content_units")
	}
	return nil
}
func (o CollectionsContentUnitSlice) UpdateAllG(cols M) error {
	return o.UpdateAll(boil.GetDB(), cols)
}
func (o CollectionsContentUnitSlice) UpdateAllGP(cols M) {
	if err := o.UpdateAll(boil.GetDB(), cols); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o CollectionsContentUnitSlice) UpdateAllP(exec boil.Executor, cols M) {
	if err := o.UpdateAll(exec, cols); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o CollectionsContentUnitSlice) UpdateAll(exec boil.Executor, cols M) error {
	ln := int64(len(o))
	if ln == 0 {
		return nil
	}
	if len(cols) == 0 {
		return errors.New("mdbmodels: 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++
	}
	for _, obj := range o {
		pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), collectionsContentUnitPrimaryKeyMapping)
		args = append(args, pkeyArgs...)
	}
	sql := fmt.Sprintf("UPDATE \"collections_content_units\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, colNames),
		strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, collectionsContentUnitPrimaryKeyColumns, 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, "mdbmodels: unable to update all in collectionsContentUnit slice")
	}
	return nil
}
func (o *CollectionsContentUnit) UpsertG(updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) error {
	return o.Upsert(boil.GetDB(), updateOnConflict, conflictColumns, updateColumns, whitelist...)
}
func (o *CollectionsContentUnit) UpsertGP(updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) {
	if err := o.Upsert(boil.GetDB(), updateOnConflict, conflictColumns, updateColumns, whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) UpsertP(exec boil.Executor, updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) {
	if err := o.Upsert(exec, updateOnConflict, conflictColumns, updateColumns, whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *CollectionsContentUnit) Upsert(exec boil.Executor, updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) error {
	if o == nil {
		return errors.New("mdbmodels: no collections_content_units provided for upsert")
	}
	nzDefaults := queries.NonZeroDefaultSet(collectionsContentUnitColumnsWithDefault, o)
	buf := strmangle.GetBuffer()
	if updateOnConflict {
		buf.WriteByte('t')
	} else {
		buf.WriteByte('f')
	}
	buf.WriteByte('.')
	for _, c := range conflictColumns {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range updateColumns {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range whitelist {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range nzDefaults {
		buf.WriteString(c)
	}
	key := buf.String()
	strmangle.PutBuffer(buf)
	collectionsContentUnitUpsertCacheMut.RLock()
	cache, cached := collectionsContentUnitUpsertCache[key]
	collectionsContentUnitUpsertCacheMut.RUnlock()
	var err error
	if !cached {
		insert, ret := strmangle.InsertColumnSet(
			collectionsContentUnitColumns,
			collectionsContentUnitColumnsWithDefault,
			collectionsContentUnitColumnsWithoutDefault,
			nzDefaults,
			whitelist,
		)
		update := strmangle.UpdateColumnSet(
			collectionsContentUnitColumns,
			collectionsContentUnitPrimaryKeyColumns,
			updateColumns,
		)
		if len(update) == 0 {
			return errors.New("mdbmodels: unable to upsert collections_content_units, could not build update column list")
		}
		conflict := conflictColumns
		if len(conflict) == 0 {
			conflict = make([]string, len(collectionsContentUnitPrimaryKeyColumns))
			copy(conflict, collectionsContentUnitPrimaryKeyColumns)
		}
		cache.query = queries.BuildUpsertQueryPostgres(dialect, "\"collections_content_units\"", updateOnConflict, ret, update, conflict, insert)
		cache.valueMapping, err = queries.BindMapping(collectionsContentUnitType, collectionsContentUnitMapping, insert)
		if err != nil {
			return err
		}
		if len(ret) != 0 {
			cache.retMapping, err = queries.BindMapping(collectionsContentUnitType, collectionsContentUnitMapping, 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.QueryRow(cache.query, vals...).Scan(returns...)
		if err == sql.ErrNoRows {
			err = nil  
		}
	} else {
		_, err = exec.Exec(cache.query, vals...)
	}
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to upsert collections_content_units")
	}
	if !cached {
		collectionsContentUnitUpsertCacheMut.Lock()
		collectionsContentUnitUpsertCache[key] = cache
		collectionsContentUnitUpsertCacheMut.Unlock()
	}
	return nil
}
func (o *CollectionsContentUnit) DeleteP(exec boil.Executor) {
	if err := o.Delete(exec); err != nil {
		panic(boil.WrapErr(err))
	}
}