func (o *Tag) RemoveClaimTagsG(related ...*ClaimTag) error {
	return o.RemoveClaimTags(boil.GetDB(), related...)
}
RemoveClaimTagsG relationships from objects passed in.
Removes related items from R.ClaimTags (uses pointer comparison, removal does not keep order)
Sets related.R.Tag.
Uses the global database handle.
package model
import (
	"database/sql"
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/pkg/errors"
	"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 Tag struct {
	ID         uint64    `boil:"id" json:"id" toml:"id" yaml:"id"`
	Tag        string    `boil:"tag" json:"tag" toml:"tag" yaml:"tag"`
	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 *tagR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L tagL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var TagColumns = struct {
	ID         string
	Tag        string
	CreatedAt  string
	ModifiedAt string
}{
	ID:         "id",
	Tag:        "tag",
	CreatedAt:  "created_at",
	ModifiedAt: "modified_at",
}
var TagWhere = struct {
	ID         whereHelperuint64
	Tag        whereHelperstring
	CreatedAt  whereHelpertime_Time
	ModifiedAt whereHelpertime_Time
}{
	ID:         whereHelperuint64{field: "`tag`.`id`"},
	Tag:        whereHelperstring{field: "`tag`.`tag`"},
	CreatedAt:  whereHelpertime_Time{field: "`tag`.`created_at`"},
	ModifiedAt: whereHelpertime_Time{field: "`tag`.`modified_at`"},
}
var TagRels = struct {
	ClaimTags string
}{
	ClaimTags: "ClaimTags",
}
type tagR struct {
	ClaimTags ClaimTagSlice
}
func (*tagR) NewStruct() *tagR {
	return &tagR{}
}
type tagL struct{}
var (
	tagAllColumns            = []string{"id", "tag", "created_at", "modified_at"}
	tagColumnsWithoutDefault = []string{"tag"}
	tagColumnsWithDefault    = []string{"id", "created_at", "modified_at"}
	tagPrimaryKeyColumns     = []string{"id"}
)
type (
	TagSlice []*Tag
	tagQuery struct {
		*queries.Query
	}
)
var (
	tagType                 = reflect.TypeOf(&Tag{})
	tagMapping              = queries.MakeStructMapping(tagType)
	tagPrimaryKeyMapping, _ = queries.BindMapping(tagType, tagMapping, tagPrimaryKeyColumns)
	tagInsertCacheMut       sync.RWMutex
	tagInsertCache          = make(map[string]insertCache)
	tagUpdateCacheMut       sync.RWMutex
	tagUpdateCache          = make(map[string]updateCache)
	tagUpsertCacheMut       sync.RWMutex
	tagUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = qmhelper.Where
)
func (q tagQuery) OneG() (*Tag, error) {
	return q.One(boil.GetDB())
}
func (q tagQuery) OneGP() *Tag {
	o, err := q.One(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q tagQuery) OneP(exec boil.Executor) *Tag {
	o, err := q.One(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q tagQuery) One(exec boil.Executor) (*Tag, error) {
	o := &Tag{}
	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 tag")
	}
	return o, nil
}
func (q tagQuery) AllG() (TagSlice, error) {
	return q.All(boil.GetDB())
}
func (q tagQuery) AllGP() TagSlice {
	o, err := q.All(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q tagQuery) AllP(exec boil.Executor) TagSlice {
	o, err := q.All(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q tagQuery) All(exec boil.Executor) (TagSlice, error) {
	var o []*Tag
	err := q.Bind(nil, exec, &o)
	if err != nil {
		return nil, errors.Wrap(err, "model: failed to assign all query results to Tag slice")
	}
	return o, nil
}
func (q tagQuery) CountG() (int64, error) {
	return q.Count(boil.GetDB())
}
func (q tagQuery) CountGP() int64 {
	c, err := q.Count(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q tagQuery) CountP(exec boil.Executor) int64 {
	c, err := q.Count(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q tagQuery) 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 tag rows")
	}
	return count, nil
}
func (q tagQuery) ExistsG() (bool, error) {
	return q.Exists(boil.GetDB())
}
func (q tagQuery) ExistsGP() bool {
	e, err := q.Exists(boil.GetDB())
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q tagQuery) ExistsP(exec boil.Executor) bool {
	e, err := q.Exists(exec)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q tagQuery) 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 tag exists")
	}
	return count > 0, nil
}
func (o *Tag) ClaimTags(mods ...qm.QueryMod) claimTagQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.Where("`claim_tag`.`tag_id`=?", o.ID),
	)
	query := ClaimTags(queryMods...)
	queries.SetFrom(query.Query, "`claim_tag`")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"`claim_tag`.*"})
	}
	return query
}
func (tagL) LoadClaimTags(e boil.Executor, singular bool, maybeTag interface{}, mods queries.Applicator) error {
	var slice []*Tag
	var object *Tag
	if singular {
		object = maybeTag.(*Tag)
	} else {
		slice = *maybeTag.(*[]*Tag)
	}
	args := make([]interface{}, 0, 1)
	if singular {
		if object.R == nil {
			object.R = &tagR{}
		}
		args = append(args, object.ID)
	} else {
	Outer:
		for _, obj := range slice {
			if obj.R == nil {
				obj.R = &tagR{}
			}
			for _, a := range args {
				if queries.Equal(a, obj.ID) {
					continue Outer
				}
			}
			args = append(args, obj.ID)
		}
	}
	if len(args) == 0 {
		return nil
	}
	query := NewQuery(qm.From(`claim_tag`), qm.WhereIn(`tag_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_tag")
	}
	var resultSlice []*ClaimTag
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice claim_tag")
	}
	if err = results.Close(); err != nil {
		return errors.Wrap(err, "failed to close results in eager load on claim_tag")
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "error occurred during iteration of eager loaded relations for claim_tag")
	}
	if singular {
		object.R.ClaimTags = resultSlice
		for _, foreign := range resultSlice {
			if foreign.R == nil {
				foreign.R = &claimTagR{}
			}
			foreign.R.Tag = object
		}
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if queries.Equal(local.ID, foreign.TagID) {
				local.R.ClaimTags = append(local.R.ClaimTags, foreign)
				if foreign.R == nil {
					foreign.R = &claimTagR{}
				}
				foreign.R.Tag = local
				break
			}
		}
	}
	return nil
}
func (o *Tag) AddClaimTagsG(insert bool, related ...*ClaimTag) error {
	return o.AddClaimTags(boil.GetDB(), insert, related...)
}
func (o *Tag) AddClaimTagsP(exec boil.Executor, insert bool, related ...*ClaimTag) {
	if err := o.AddClaimTags(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Tag) AddClaimTagsGP(insert bool, related ...*ClaimTag) {
	if err := o.AddClaimTags(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Tag) AddClaimTags(exec boil.Executor, insert bool, related ...*ClaimTag) error {
	var err error
	for _, rel := range related {
		if insert {
			queries.Assign(&rel.TagID, o.ID)
			if err = rel.Insert(exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE `claim_tag` SET %s WHERE %s",
				strmangle.SetParamNames("`", "`", 0, []string{"tag_id"}),
				strmangle.WhereClause("`", "`", 0, claimTagPrimaryKeyColumns),
			)
			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")
			}
			queries.Assign(&rel.TagID, o.ID)
		}
	}
	if o.R == nil {
		o.R = &tagR{
			ClaimTags: related,
		}
	} else {
		o.R.ClaimTags = append(o.R.ClaimTags, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &claimTagR{
				Tag: o,
			}
		} else {
			rel.R.Tag = o
		}
	}
	return nil
}
func (o *Tag) SetClaimTagsG(insert bool, related ...*ClaimTag) error {
	return o.SetClaimTags(boil.GetDB(), insert, related...)
}
func (o *Tag) SetClaimTagsP(exec boil.Executor, insert bool, related ...*ClaimTag) {
	if err := o.SetClaimTags(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Tag) SetClaimTagsGP(insert bool, related ...*ClaimTag) {
	if err := o.SetClaimTags(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Tag) SetClaimTags(exec boil.Executor, insert bool, related ...*ClaimTag) error {
	query := "update `claim_tag` set `tag_id` = null where `tag_id` = ?"
	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.ClaimTags {
			queries.SetScanner(&rel.TagID, nil)
			if rel.R == nil {
				continue
			}
			rel.R.Tag = nil
		}
		o.R.ClaimTags = nil
	}
	return o.AddClaimTags(exec, insert, related...)
}