func (o *ContentRoleType) AddRoleContentUnitsPersonsP(exec boil.Executor, insert bool, related ...*ContentUnitsPerson) {
	if err := o.AddRoleContentUnitsPersons(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
AddRoleContentUnitsPersonsP adds the given related objects to the existing relationships
of the content_role_type, optionally inserting them as new records.
Appends related to o.R.RoleContentUnitsPersons.
Sets related.R.Role appropriately.
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 ContentRoleType struct {
	ID          int64       `boil:"id" json:"id" toml:"id" yaml:"id"`
	Name        string      `boil:"name" json:"name" toml:"name" yaml:"name"`
	Description null.String `boil:"description" json:"description,omitempty" toml:"description" yaml:"description,omitempty"`
	R *contentRoleTypeR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L contentRoleTypeL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var ContentRoleTypeColumns = struct {
	ID          string
	Name        string
	Description string
}{
	ID:          "id",
	Name:        "name",
	Description: "description",
}
type contentRoleTypeR struct {
	RoleContentUnitsPersons ContentUnitsPersonSlice
}
type contentRoleTypeL struct{}
var (
	contentRoleTypeColumns               = []string{"id", "name", "description"}
	contentRoleTypeColumnsWithoutDefault = []string{"name", "description"}
	contentRoleTypeColumnsWithDefault    = []string{"id"}
	contentRoleTypePrimaryKeyColumns     = []string{"id"}
)
type (
	ContentRoleTypeSlice []*ContentRoleType
	contentRoleTypeQuery struct {
		*queries.Query
	}
)
var (
	contentRoleTypeType                 = reflect.TypeOf(&ContentRoleType{})
	contentRoleTypeMapping              = queries.MakeStructMapping(contentRoleTypeType)
	contentRoleTypePrimaryKeyMapping, _ = queries.BindMapping(contentRoleTypeType, contentRoleTypeMapping, contentRoleTypePrimaryKeyColumns)
	contentRoleTypeInsertCacheMut       sync.RWMutex
	contentRoleTypeInsertCache          = make(map[string]insertCache)
	contentRoleTypeUpdateCacheMut       sync.RWMutex
	contentRoleTypeUpdateCache          = make(map[string]updateCache)
	contentRoleTypeUpsertCacheMut       sync.RWMutex
	contentRoleTypeUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = bytes.MinRead
)
func (q contentRoleTypeQuery) OneP() *ContentRoleType {
	o, err := q.One()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q contentRoleTypeQuery) One() (*ContentRoleType, error) {
	o := &ContentRoleType{}
	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 content_role_types")
	}
	return o, nil
}
func (q contentRoleTypeQuery) AllP() ContentRoleTypeSlice {
	o, err := q.All()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q contentRoleTypeQuery) All() (ContentRoleTypeSlice, error) {
	var o []*ContentRoleType
	err := q.Bind(&o)
	if err != nil {
		return nil, errors.Wrap(err, "mdbmodels: failed to assign all query results to ContentRoleType slice")
	}
	return o, nil
}
func (q contentRoleTypeQuery) CountP() int64 {
	c, err := q.Count()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q contentRoleTypeQuery) 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 content_role_types rows")
	}
	return count, nil
}
func (q contentRoleTypeQuery) ExistsP() bool {
	e, err := q.Exists()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q contentRoleTypeQuery) 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 content_role_types exists")
	}
	return count > 0, nil
}
func (o *ContentRoleType) RoleContentUnitsPersonsG(mods ...qm.QueryMod) contentUnitsPersonQuery {
	return o.RoleContentUnitsPersons(boil.GetDB(), mods...)
}
func (o *ContentRoleType) RoleContentUnitsPersons(exec boil.Executor, mods ...qm.QueryMod) contentUnitsPersonQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.Where("\"content_units_persons\".\"role_id\"=?", o.ID),
	)
	query := ContentUnitsPersons(exec, queryMods...)
	queries.SetFrom(query.Query, "\"content_units_persons\"")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"\"content_units_persons\".*"})
	}
	return query
}
func (contentRoleTypeL) LoadRoleContentUnitsPersons(e boil.Executor, singular bool, maybeContentRoleType interface{}) error {
	var slice []*ContentRoleType
	var object *ContentRoleType
	count := 1
	if singular {
		object = maybeContentRoleType.(*ContentRoleType)
	} else {
		slice = *maybeContentRoleType.(*[]*ContentRoleType)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &contentRoleTypeR{}
		}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &contentRoleTypeR{}
			}
			args[i] = obj.ID
		}
	}
	query := fmt.Sprintf(
		"select * from \"content_units_persons\" where \"role_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_persons")
	}
	defer results.Close()
	var resultSlice []*ContentUnitsPerson
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice content_units_persons")
	}
	if singular {
		object.R.RoleContentUnitsPersons = resultSlice
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.RoleID {
				local.R.RoleContentUnitsPersons = append(local.R.RoleContentUnitsPersons, foreign)
				break
			}
		}
	}
	return nil
}
func (o *ContentRoleType) AddRoleContentUnitsPersonsG(insert bool, related ...*ContentUnitsPerson) error {
	return o.AddRoleContentUnitsPersons(boil.GetDB(), insert, related...)
}