func FindPersonG(id int, selectCols ...string) (*Person, error) {
	return FindPerson(boil.GetDB(), id, selectCols...)
}
FindPersonG retrieves a single record by ID.
package models
import (
	"bytes"
	"database/sql"
	"fmt"
	"reflect"
	"strings"
	"sync"
	"time"
	"github.com/pkg/errors"
	"github.com/vattle/sqlboiler/boil"
	"github.com/vattle/sqlboiler/queries"
	"github.com/vattle/sqlboiler/queries/qm"
	"github.com/vattle/sqlboiler/strmangle"
	"gopkg.in/nullbio/null.v6"
)
type Person struct {
	ID   int         `boil:"id" json:"id" toml:"id" yaml:"id"`
	Name null.String `boil:"name" json:"name,omitempty" toml:"name" yaml:"name,omitempty"`
	R *personR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L personL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
type personR struct {
	Pets PetSlice
}
type personL struct{}
var (
	personColumns               = []string{"id", "name"}
	personColumnsWithoutDefault = []string{"name"}
	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, "models: failed to execute a one query for people")
	}
	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, "models: 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, "models: failed to count people 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, "models: failed to check if people exists")
	}
	return count > 0, nil
}
func (o *Person) PetsG(mods ...qm.QueryMod) petQuery {
	return o.Pets(boil.GetDB(), mods...)
}
func (o *Person) Pets(exec boil.Executor, mods ...qm.QueryMod) petQuery {
	queryMods := []qm.QueryMod{
		qm.Select("\"a\".*"),
	}
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.Where("\"a\".\"person_id\"=?", o.ID),
	)
	query := Pets(exec, queryMods...)
	queries.SetFrom(query.Query, "\"pets\" as \"a\"")
	return query
}
func (personL) LoadPets(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 \"pets\" 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 pets")
	}
	defer results.Close()
	var resultSlice []*Pet
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice pets")
	}
	if singular {
		object.R.Pets = resultSlice
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.PersonID.Int {
				local.R.Pets = append(local.R.Pets, foreign)
				break
			}
		}
	}
	return nil
}
func (o *Person) AddPetsG(insert bool, related ...*Pet) error {
	return o.AddPets(boil.GetDB(), insert, related...)
}
func (o *Person) AddPetsP(exec boil.Executor, insert bool, related ...*Pet) {
	if err := o.AddPets(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) AddPetsGP(insert bool, related ...*Pet) {
	if err := o.AddPets(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) AddPets(exec boil.Executor, insert bool, related ...*Pet) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.PersonID.Int = o.ID
			rel.PersonID.Valid = true
			if err = rel.Insert(exec); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"pets\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"person_id"}),
				strmangle.WhereClause("\"", "\"", 2, petPrimaryKeyColumns),
			)
			values := []interface{}{o.ID, rel.ID}
			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.Int = o.ID
			rel.PersonID.Valid = true
		}
	}
	if o.R == nil {
		o.R = &personR{
			Pets: related,
		}
	} else {
		o.R.Pets = append(o.R.Pets, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &petR{
				Person: o,
			}
		} else {
			rel.R.Person = o
		}
	}
	return nil
}
func (o *Person) SetPetsG(insert bool, related ...*Pet) error {
	return o.SetPets(boil.GetDB(), insert, related...)
}
func (o *Person) SetPetsP(exec boil.Executor, insert bool, related ...*Pet) {
	if err := o.SetPets(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) SetPetsGP(insert bool, related ...*Pet) {
	if err := o.SetPets(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) SetPets(exec boil.Executor, insert bool, related ...*Pet) error {
	query := "update \"pets\" set \"person_id\" = null where \"person_id\" = $1"
	values := []interface{}{o.ID}
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, query)
		fmt.Fprintln(boil.DebugWriter, values)
	}
	_, err := exec.Exec(query, values...)
	if err != nil {
		return errors.Wrap(err, "failed to remove relationships before set")
	}
	if o.R != nil {
		for _, rel := range o.R.Pets {
			rel.PersonID.Valid = false
			if rel.R == nil {
				continue
			}
			rel.R.Person = nil
		}
		o.R.Pets = nil
	}
	return o.AddPets(exec, insert, related...)
}
func (o *Person) RemovePetsG(related ...*Pet) error {
	return o.RemovePets(boil.GetDB(), related...)
}
func (o *Person) RemovePetsP(exec boil.Executor, related ...*Pet) {
	if err := o.RemovePets(exec, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) RemovePetsGP(related ...*Pet) {
	if err := o.RemovePets(boil.GetDB(), related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Person) RemovePets(exec boil.Executor, related ...*Pet) error {
	var err error
	for _, rel := range related {
		rel.PersonID.Valid = false
		if rel.R != nil {
			rel.R.Person = nil
		}
		if err = rel.Update(exec, "person_id"); err != nil {
			return err
		}
	}
	if o.R == nil {
		return nil
	}
	for _, rel := range related {
		for i, ri := range o.R.Pets {
			if rel != ri {
				continue
			}
			ln := len(o.R.Pets)
			if ln > 1 && i < ln-1 {
				o.R.Pets[i] = o.R.Pets[ln-1]
			}
			o.R.Pets = o.R.Pets[:ln-1]
			break
		}
	}
	return nil
}
func PeopleG(mods ...qm.QueryMod) personQuery {
	return People(boil.GetDB(), mods...)
}
func People(exec boil.Executor, mods ...qm.QueryMod) personQuery {
	mods = append(mods, qm.From("\"people\""))
	return personQuery{NewQuery(exec, mods...)}
}