func (o *Publisher) AddContentUnitsGP(insert bool, related ...*ContentUnit) {
	if err := o.AddContentUnits(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
AddContentUnitsGP adds the given related objects to the existing relationships
of the publisher, optionally inserting them as new records.
Appends related to o.R.ContentUnits.
Sets related.R.Publishers appropriately.
Uses the global database handle and panics on error.
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"
	"gopkg.in/volatiletech/null.v6"
)
type Publisher struct {
	ID      int64       `boil:"id" json:"id" toml:"id" yaml:"id"`
	UID     string      `boil:"uid" json:"uid" toml:"uid" yaml:"uid"`
	Pattern null.String `boil:"pattern" json:"pattern,omitempty" toml:"pattern" yaml:"pattern,omitempty"`
	R *publisherR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L publisherL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var PublisherColumns = struct {
	ID      string
	UID     string
	Pattern string
}{
	ID:      "id",
	UID:     "uid",
	Pattern: "pattern",
}
type publisherR struct {
	ContentUnits   ContentUnitSlice
	PublisherI18ns PublisherI18nSlice
}
type publisherL struct{}
var (
	publisherColumns               = []string{"id", "uid", "pattern"}
	publisherColumnsWithoutDefault = []string{"uid", "pattern"}
	publisherColumnsWithDefault    = []string{"id"}
	publisherPrimaryKeyColumns     = []string{"id"}
)
type (
	PublisherSlice []*Publisher
	publisherQuery struct {
		*queries.Query
	}
)
var (
	publisherType                 = reflect.TypeOf(&Publisher{})
	publisherMapping              = queries.MakeStructMapping(publisherType)
	publisherPrimaryKeyMapping, _ = queries.BindMapping(publisherType, publisherMapping, publisherPrimaryKeyColumns)
	publisherInsertCacheMut       sync.RWMutex
	publisherInsertCache          = make(map[string]insertCache)
	publisherUpdateCacheMut       sync.RWMutex
	publisherUpdateCache          = make(map[string]updateCache)
	publisherUpsertCacheMut       sync.RWMutex
	publisherUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = bytes.MinRead
)
func (q publisherQuery) OneP() *Publisher {
	o, err := q.One()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q publisherQuery) One() (*Publisher, error) {
	o := &Publisher{}
	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 publishers")
	}
	return o, nil
}
func (q publisherQuery) AllP() PublisherSlice {
	o, err := q.All()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q publisherQuery) All() (PublisherSlice, error) {
	var o []*Publisher
	err := q.Bind(&o)
	if err != nil {
		return nil, errors.Wrap(err, "mdbmodels: failed to assign all query results to Publisher slice")
	}
	return o, nil
}
func (q publisherQuery) CountP() int64 {
	c, err := q.Count()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q publisherQuery) 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 publishers rows")
	}
	return count, nil
}
func (q publisherQuery) ExistsP() bool {
	e, err := q.Exists()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q publisherQuery) 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 publishers exists")
	}
	return count > 0, nil
}
func (o *Publisher) ContentUnitsG(mods ...qm.QueryMod) contentUnitQuery {
	return o.ContentUnits(boil.GetDB(), mods...)
}
func (o *Publisher) ContentUnits(exec boil.Executor, mods ...qm.QueryMod) contentUnitQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.InnerJoin("\"content_units_publishers\" on \"content_units\".\"id\" = \"content_units_publishers\".\"content_unit_id\""),
		qm.Where("\"content_units_publishers\".\"publisher_id\"=?", o.ID),
	)
	query := ContentUnits(exec, queryMods...)
	queries.SetFrom(query.Query, "\"content_units\"")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"\"content_units\".*"})
	}
	return query
}
func (o *Publisher) PublisherI18nsG(mods ...qm.QueryMod) publisherI18nQuery {
	return o.PublisherI18ns(boil.GetDB(), mods...)
}
func (o *Publisher) PublisherI18ns(exec boil.Executor, mods ...qm.QueryMod) publisherI18nQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.Where("\"publisher_i18n\".\"publisher_id\"=?", o.ID),
	)
	query := PublisherI18ns(exec, queryMods...)
	queries.SetFrom(query.Query, "\"publisher_i18n\"")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"\"publisher_i18n\".*"})
	}
	return query
}
func (publisherL) LoadContentUnits(e boil.Executor, singular bool, maybePublisher interface{}) error {
	var slice []*Publisher
	var object *Publisher
	count := 1
	if singular {
		object = maybePublisher.(*Publisher)
	} else {
		slice = *maybePublisher.(*[]*Publisher)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &publisherR{}
		}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &publisherR{}
			}
			args[i] = obj.ID
		}
	}
	query := fmt.Sprintf(
		"select \"a\".*, \"b\".\"publisher_id\" from \"content_units\" as \"a\" inner join \"content_units_publishers\" as \"b\" on \"a\".\"id\" = \"b\".\"content_unit_id\" where \"b\".\"publisher_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 content_units")
	}
	defer results.Close()
	var resultSlice []*ContentUnit
	var localJoinCols []int64
	for results.Next() {
		one := new(ContentUnit)
		var localJoinCol int64
		err = results.Scan(&one.ID, &one.UID, &one.TypeID, &one.CreatedAt, &one.Properties, &one.Secure, &one.Published, &localJoinCol)
		if err = results.Err(); err != nil {
			return errors.Wrap(err, "failed to plebian-bind eager loaded slice content_units")
		}
		resultSlice = append(resultSlice, one)
		localJoinCols = append(localJoinCols, localJoinCol)
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "failed to plebian-bind eager loaded slice content_units")
	}
	if singular {
		object.R.ContentUnits = resultSlice
		return nil
	}
	for i, foreign := range resultSlice {
		localJoinCol := localJoinCols[i]
		for _, local := range slice {
			if local.ID == localJoinCol {
				local.R.ContentUnits = append(local.R.ContentUnits, foreign)
				break
			}
		}
	}
	return nil
}
func (publisherL) LoadPublisherI18ns(e boil.Executor, singular bool, maybePublisher interface{}) error {
	var slice []*Publisher
	var object *Publisher
	count := 1
	if singular {
		object = maybePublisher.(*Publisher)
	} else {
		slice = *maybePublisher.(*[]*Publisher)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &publisherR{}
		}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &publisherR{}
			}
			args[i] = obj.ID
		}
	}
	query := fmt.Sprintf(
		"select * from \"publisher_i18n\" where \"publisher_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 publisher_i18n")
	}
	defer results.Close()
	var resultSlice []*PublisherI18n
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice publisher_i18n")
	}
	if singular {
		object.R.PublisherI18ns = resultSlice
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.PublisherID {
				local.R.PublisherI18ns = append(local.R.PublisherI18ns, foreign)
				break
			}
		}
	}
	return nil
}
func (o *Publisher) AddContentUnitsG(insert bool, related ...*ContentUnit) error {
	return o.AddContentUnits(boil.GetDB(), insert, related...)
}
func (o *Publisher) AddContentUnitsP(exec boil.Executor, insert bool, related ...*ContentUnit) {
	if err := o.AddContentUnits(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}