func (o *ClaimInList) InsertG(columns boil.Columns) error {
	return o.Insert(boil.GetDB(), columns)
}
InsertG a single record. See Insert for whitelist behavior description.
package model
import (
	"database/sql"
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/pkg/errors"
	"github.com/volatiletech/null"
	"github.com/volatiletech/sqlboiler/boil"
	"github.com/volatiletech/sqlboiler/queries"
	"github.com/volatiletech/sqlboiler/queries/qm"
	"github.com/volatiletech/sqlboiler/queries/qmhelper"
	"github.com/volatiletech/sqlboiler/strmangle"
)
type ClaimInList struct {
	ID          uint64      `boil:"id" json:"id" toml:"id" yaml:"id"`
	ListClaimID string      `boil:"list_claim_id" json:"list_claim_id" toml:"list_claim_id" yaml:"list_claim_id"`
	ClaimID     null.String `boil:"claim_id" json:"claim_id,omitempty" toml:"claim_id" yaml:"claim_id,omitempty"`
	CreatedAt   time.Time   `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"`
	ModifiedAt  time.Time   `boil:"modified_at" json:"modified_at" toml:"modified_at" yaml:"modified_at"`
	R *claimInListR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L claimInListL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var ClaimInListColumns = struct {
	ID          string
	ListClaimID string
	ClaimID     string
	CreatedAt   string
	ModifiedAt  string
}{
	ID:          "id",
	ListClaimID: "list_claim_id",
	ClaimID:     "claim_id",
	CreatedAt:   "created_at",
	ModifiedAt:  "modified_at",
}
var ClaimInListWhere = struct {
	ID          whereHelperuint64
	ListClaimID whereHelperstring
	ClaimID     whereHelpernull_String
	CreatedAt   whereHelpertime_Time
	ModifiedAt  whereHelpertime_Time
}{
	ID:          whereHelperuint64{field: "`claim_in_list`.`id`"},
	ListClaimID: whereHelperstring{field: "`claim_in_list`.`list_claim_id`"},
	ClaimID:     whereHelpernull_String{field: "`claim_in_list`.`claim_id`"},
	CreatedAt:   whereHelpertime_Time{field: "`claim_in_list`.`created_at`"},
	ModifiedAt:  whereHelpertime_Time{field: "`claim_in_list`.`modified_at`"},
}
var ClaimInListRels = struct {
	ListClaim string
}{
	ListClaim: "ListClaim",
}
type claimInListR struct {
	ListClaim *Claim
}
func (*claimInListR) NewStruct() *claimInListR {
	return &claimInListR{}
}
type claimInListL struct{}
var (
	claimInListAllColumns            = []string{"id", "list_claim_id", "claim_id", "created_at", "modified_at"}
	claimInListColumnsWithoutDefault = []string{"list_claim_id", "claim_id"}
	claimInListColumnsWithDefault    = []string{"id", "created_at", "modified_at"}
	claimInListPrimaryKeyColumns     = []string{"id"}
)
type (
	ClaimInListSlice []*ClaimInList
	claimInListQuery struct {
		*queries.Query
	}
)
var (
	claimInListType                 = reflect.TypeOf(&ClaimInList{})
	claimInListMapping              = queries.MakeStructMapping(claimInListType)
	claimInListPrimaryKeyMapping, _ = queries.BindMapping(claimInListType, claimInListMapping, claimInListPrimaryKeyColumns)
	claimInListInsertCacheMut       sync.RWMutex
	claimInListInsertCache          = make(map[string]insertCache)
	claimInListUpdateCacheMut       sync.RWMutex
	claimInListUpdateCache          = make(map[string]updateCache)
	claimInListUpsertCacheMut       sync.RWMutex
	claimInListUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = qmhelper.Where
)
func (q claimInListQuery) OneG() (*ClaimInList, error) {
	return q.One(boil.GetDB())
}
func (q claimInListQuery) OneGP() *ClaimInList {
	o, err := q.One(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q claimInListQuery) OneP(exec boil.Executor) *ClaimInList {
	o, err := q.One(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q claimInListQuery) One(exec boil.Executor) (*ClaimInList, error) {
	o := &ClaimInList{}
	queries.SetLimit(q.Query, 1)
	err := q.Bind(nil, exec, o)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "model: failed to execute a one query for claim_in_list")
	}
	return o, nil
}
func (q claimInListQuery) AllG() (ClaimInListSlice, error) {
	return q.All(boil.GetDB())
}
func (q claimInListQuery) AllGP() ClaimInListSlice {
	o, err := q.All(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q claimInListQuery) AllP(exec boil.Executor) ClaimInListSlice {
	o, err := q.All(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q claimInListQuery) All(exec boil.Executor) (ClaimInListSlice, error) {
	var o []*ClaimInList
	err := q.Bind(nil, exec, &o)
	if err != nil {
		return nil, errors.Wrap(err, "model: failed to assign all query results to ClaimInList slice")
	}
	return o, nil
}
func (q claimInListQuery) CountG() (int64, error) {
	return q.Count(boil.GetDB())
}
func (q claimInListQuery) CountGP() int64 {
	c, err := q.Count(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q claimInListQuery) CountP(exec boil.Executor) int64 {
	c, err := q.Count(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q claimInListQuery) Count(exec boil.Executor) (int64, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	err := q.Query.QueryRow(exec).Scan(&count)
	if err != nil {
		return 0, errors.Wrap(err, "model: failed to count claim_in_list rows")
	}
	return count, nil
}
func (q claimInListQuery) ExistsG() (bool, error) {
	return q.Exists(boil.GetDB())
}
func (q claimInListQuery) ExistsGP() bool {
	e, err := q.Exists(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q claimInListQuery) ExistsP(exec boil.Executor) bool {
	e, err := q.Exists(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q claimInListQuery) Exists(exec boil.Executor) (bool, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	queries.SetLimit(q.Query, 1)
	err := q.Query.QueryRow(exec).Scan(&count)
	if err != nil {
		return false, errors.Wrap(err, "model: failed to check if claim_in_list exists")
	}
	return count > 0, nil
}
func (o *ClaimInList) ListClaim(mods ...qm.QueryMod) claimQuery {
	queryMods := []qm.QueryMod{
		qm.Where("claim_id=?", o.ListClaimID),
	}
	queryMods = append(queryMods, mods...)
	query := Claims(queryMods...)
	queries.SetFrom(query.Query, "`claim`")
	return query
}
func (claimInListL) LoadListClaim(e boil.Executor, singular bool, maybeClaimInList interface{}, mods queries.Applicator) error {
	var slice []*ClaimInList
	var object *ClaimInList
	if singular {
		object = maybeClaimInList.(*ClaimInList)
	} else {
		slice = *maybeClaimInList.(*[]*ClaimInList)
	}
	args := make([]interface{}, 0, 1)
	if singular {
		if object.R == nil {
			object.R = &claimInListR{}
		}
		args = append(args, object.ListClaimID)
	} else {
	Outer:
		for _, obj := range slice {
			if obj.R == nil {
				obj.R = &claimInListR{}
			}
			for _, a := range args {
				if a == obj.ListClaimID {
					continue Outer
				}
			}
			args = append(args, obj.ListClaimID)
		}
	}
	if len(args) == 0 {
		return nil
	}
	query := NewQuery(qm.From(`claim`), qm.WhereIn(`claim_id in ?`, args...))
	if mods != nil {
		mods.Apply(query)
	}
	results, err := query.Query(e)
	if err != nil {
		return errors.Wrap(err, "failed to eager load Claim")
	}
	var resultSlice []*Claim
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Claim")
	}
	if err = results.Close(); err != nil {
		return errors.Wrap(err, "failed to close results of eager load for claim")
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "error occurred during iteration of eager loaded relations for claim")
	}
	if len(resultSlice) == 0 {
		return nil
	}
	if singular {
		foreign := resultSlice[0]
		object.R.ListClaim = foreign
		if foreign.R == nil {
			foreign.R = &claimR{}
		}
		foreign.R.ListClaimClaimInLists = append(foreign.R.ListClaimClaimInLists, object)
		return nil
	}
	for _, local := range slice {
		for _, foreign := range resultSlice {
			if local.ListClaimID == foreign.ClaimID {
				local.R.ListClaim = foreign
				if foreign.R == nil {
					foreign.R = &claimR{}
				}
				foreign.R.ListClaimClaimInLists = append(foreign.R.ListClaimClaimInLists, local)
				break
			}
		}
	}
	return nil
}
func (o *ClaimInList) SetListClaimG(insert bool, related *Claim) error {
	return o.SetListClaim(boil.GetDB(), insert, related)
}
func (o *ClaimInList) SetListClaimP(exec boil.Executor, insert bool, related *Claim) {
	if err := o.SetListClaim(exec, insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *ClaimInList) SetListClaimGP(insert bool, related *Claim) {
	if err := o.SetListClaim(boil.GetDB(), insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *ClaimInList) SetListClaim(exec boil.Executor, insert bool, related *Claim) error {
	var err error
	if insert {
		if err = related.Insert(exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}
	updateQuery := fmt.Sprintf(
		"UPDATE `claim_in_list` SET %s WHERE %s",
		strmangle.SetParamNames("`", "`", 0, []string{"list_claim_id"}),
		strmangle.WhereClause("`", "`", 0, claimInListPrimaryKeyColumns),
	)
	values := []interface{}{related.ClaimID, o.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 local table")
	}
	o.ListClaimID = related.ClaimID
	if o.R == nil {
		o.R = &claimInListR{
			ListClaim: related,
		}
	} else {
		o.R.ListClaim = related
	}
	if related.R == nil {
		related.R = &claimR{
			ListClaimClaimInLists: ClaimInListSlice{o},
		}
	} else {
		related.R.ListClaimClaimInLists = append(related.R.ListClaimClaimInLists, o)
	}
	return nil
}
func ClaimInLists(mods ...qm.QueryMod) claimInListQuery {
	mods = append(mods, qm.From("`claim_in_list`"))
	return claimInListQuery{NewQuery(mods...)}
}
func FindClaimInListG(iD uint64, selectCols ...string) (*ClaimInList, error) {
	return FindClaimInList(boil.GetDB(), iD, selectCols...)
}
func FindClaimInListP(exec boil.Executor, iD uint64, selectCols ...string) *ClaimInList {
	retobj, err := FindClaimInList(exec, iD, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindClaimInListGP(iD uint64, selectCols ...string) *ClaimInList {
	retobj, err := FindClaimInList(boil.GetDB(), iD, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindClaimInList(exec boil.Executor, iD uint64, selectCols ...string) (*ClaimInList, error) {
	claimInListObj := &ClaimInList{}
	sel := "*"
	if len(selectCols) > 0 {
		sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
	}
	query := fmt.Sprintf(
		"select %s from `claim_in_list` where `id`=?", sel,
	)
	q := queries.Raw(query, iD)
	err := q.Bind(nil, exec, claimInListObj)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "model: unable to select from claim_in_list")
	}
	return claimInListObj, nil
}