func (o *Person) AddPersonI18nsG(insert bool, related ...*PersonI18n) error {
	return o.AddPersonI18ns(boil.GetDB(), insert, related...)
}
AddPersonI18nsG adds the given related objects to the existing relationships
of the person, optionally inserting them as new records.
Appends related to o.R.PersonI18ns.
Sets related.R.Person appropriately.
Uses the global database handle.
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 Person 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 *personR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L personL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var PersonColumns = struct {
	ID      string
	UID     string
	Pattern string
}{
	ID:      "id",
	UID:     "uid",
	Pattern: "pattern",
}
type personR struct {
	ContentUnitsPersons ContentUnitsPersonSlice
	PersonI18ns         PersonI18nSlice
}
type personL struct{}
var (
	personColumns               = []string{"id", "uid", "pattern"}
	personColumnsWithoutDefault = []string{"uid", "pattern"}
	personColumnsWithDefault    = []string{"id"}
	personPrimaryKeyColumns     = []string{"id"}
)
type (
	PersonSlice []*Person
	personQuery struct {
		*queries.Query
	}
)
var (
	personType                 = reflect.TypeOf(&Person{})
	personMapping              = queries.MakeStructMapping(personType)
	personPrimaryKeyMapping, _ = queries.BindMapping(personType, personMapping, personPrimaryKeyColumns)
	personInsertCacheMut       sync.RWMutex
	personInsertCache          = make(map[string]insertCache)
	personUpdateCacheMut       sync.RWMutex
	personUpdateCache          = make(map[string]updateCache)
	personUpsertCacheMut       sync.RWMutex
	personUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = bytes.MinRead
)
func (q personQuery) OneP() *Person {
	o, err := q.One()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q personQuery) One() (*Person, error) {
	o := &Person{}
	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 persons")
	}
	return o, nil
}
func (q personQuery) AllP() PersonSlice {
	o, err := q.All()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q personQuery) All() (PersonSlice, error) {
	var o []*Person
	err := q.Bind(&o)
	if err != nil {
		return nil, errors.Wrap(err, "mdbmodels: failed to assign all query results to Person slice")
	}
	return o, nil
}
func (q personQuery) CountP() int64 {
	c, err := q.Count()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q personQuery) 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 persons rows")
	}
	return count, nil
}
func (q personQuery) ExistsP() bool {
	e, err := q.Exists()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q personQuery) 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 persons exists")
	}
	return count > 0, nil
}
func (o *Person) ContentUnitsPersonsG(mods ...qm.QueryMod) contentUnitsPersonQuery {
	return o.ContentUnitsPersons(boil.GetDB(), mods...)
}
func (o *Person) ContentUnitsPersons(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\".\"person_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 (o *Person) PersonI18nsG(mods ...qm.QueryMod) personI18nQuery {
	return o.PersonI18ns(boil.GetDB(), mods...)
}
func (o *Person) PersonI18ns(exec boil.Executor, mods ...qm.QueryMod) personI18nQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.Where("\"person_i18n\".\"person_id\"=?", o.ID),
	)
	query := PersonI18ns(exec, queryMods...)
	queries.SetFrom(query.Query, "\"person_i18n\"")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"\"person_i18n\".*"})
	}
	return query
}
func (personL) LoadContentUnitsPersons(e boil.Executor, singular bool, maybePerson interface{}) error {
	var slice []*Person
	var object *Person
	count := 1
	if singular {
		object = maybePerson.(*Person)
	} else {
		slice = *maybePerson.(*[]*Person)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &personR{}
		}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &personR{}
			}
			args[i] = obj.ID
		}
	}
	query := fmt.Sprintf(
		"select * from \"content_units_persons\" where \"person_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.ContentUnitsPersons = resultSlice
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.PersonID {
				local.R.ContentUnitsPersons = append(local.R.ContentUnitsPersons, foreign)
				break
			}
		}
	}
	return nil
}
func (personL) LoadPersonI18ns(e boil.Executor, singular bool, maybePerson interface{}) error {
	var slice []*Person
	var object *Person
	count := 1
	if singular {
		object = maybePerson.(*Person)
	} else {
		slice = *maybePerson.(*[]*Person)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &personR{}
		}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &personR{}
			}
			args[i] = obj.ID
		}
	}
	query := fmt.Sprintf(
		"select * from \"person_i18n\" where \"person_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 person_i18n")
	}
	defer results.Close()
	var resultSlice []*PersonI18n
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice person_i18n")
	}
	if singular {
		object.R.PersonI18ns = resultSlice
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.PersonID {
				local.R.PersonI18ns = append(local.R.PersonI18ns, foreign)
				break
			}
		}
	}
	return nil
}
func (o *Person) AddContentUnitsPersonsG(insert bool, related ...*ContentUnitsPerson) error {
	return o.AddContentUnitsPersons(boil.GetDB(), insert, related...)
}
func (o *Person) AddContentUnitsPersonsP(exec boil.Executor, insert bool, related ...*ContentUnitsPerson) {
	if err := o.AddContentUnitsPersons(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) AddContentUnitsPersonsGP(insert bool, related ...*ContentUnitsPerson) {
	if err := o.AddContentUnitsPersons(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) AddContentUnitsPersons(exec boil.Executor, insert bool, related ...*ContentUnitsPerson) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.PersonID = o.ID
			if err = rel.Insert(exec); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"content_units_persons\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"person_id"}),
				strmangle.WhereClause("\"", "\"", 2, contentUnitsPersonPrimaryKeyColumns),
			)
			values := []interface{}{o.ID, rel.ContentUnitID, rel.PersonID}
			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 foreign table")
			}
			rel.PersonID = o.ID
		}
	}
	if o.R == nil {
		o.R = &personR{
			ContentUnitsPersons: related,
		}
	} else {
		o.R.ContentUnitsPersons = append(o.R.ContentUnitsPersons, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &contentUnitsPersonR{
				Person: o,
			}
		} else {
			rel.R.Person = o
		}
	}
	return nil
}