func NameExists(ctx context.Context, exec boil.ContextExecutor, nconst string) (bool, error) {
	var exists bool
	sql := "select exists(select 1 from \"names\" where \"nconst\"=$1 limit 1)"
	if boil.IsDebug(ctx) {
		writer := boil.DebugWriterFrom(ctx)
		fmt.Fprintln(writer, sql)
		fmt.Fprintln(writer, nconst)
	}
	row := exec.QueryRowContext(ctx, sql, nconst)
	err := row.Scan(&exists)
	if err != nil {
		return false, errors.Wrap(err, "models: unable to check if names exists")
	}
	return exists, nil
}
NameExists checks if the Name row exists.
package models
import (
	"context"
	"database/sql"
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/friendsofgo/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"
	"github.com/volatiletech/sqlboiler/types"
)
type Name struct {
	Nconst             string            `boil:"nconst" json:"nconst" toml:"nconst" yaml:"nconst"`
	PrimaryName        null.String       `boil:"primary_name" json:"primary_name,omitempty" toml:"primary_name" yaml:"primary_name,omitempty"`
	BirthYear          null.String       `boil:"birth_year" json:"birth_year,omitempty" toml:"birth_year" yaml:"birth_year,omitempty"`
	DeathYear          null.String       `boil:"death_year" json:"death_year,omitempty" toml:"death_year" yaml:"death_year,omitempty"`
	PrimaryProfessions types.StringArray `boil:"primary_professions" json:"primary_professions,omitempty" toml:"primary_professions" yaml:"primary_professions,omitempty"`
	KnownForTitles     types.StringArray `boil:"known_for_titles" json:"known_for_titles,omitempty" toml:"known_for_titles" yaml:"known_for_titles,omitempty"`
	R *nameR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L nameL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var NameColumns = struct {
	Nconst             string
	PrimaryName        string
	BirthYear          string
	DeathYear          string
	PrimaryProfessions string
	KnownForTitles     string
}{
	Nconst:             "nconst",
	PrimaryName:        "primary_name",
	BirthYear:          "birth_year",
	DeathYear:          "death_year",
	PrimaryProfessions: "primary_professions",
	KnownForTitles:     "known_for_titles",
}
type whereHelperstring struct{ field string }
func (w whereHelperstring) EQ(x string) qm.QueryMod  { return qmhelper.Where(w.field, qmhelper.EQ, x) }
func (w whereHelperstring) NEQ(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) }
func (w whereHelperstring) LT(x string) qm.QueryMod  { return qmhelper.Where(w.field, qmhelper.LT, x) }
func (w whereHelperstring) LTE(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) }
func (w whereHelperstring) GT(x string) qm.QueryMod  { return qmhelper.Where(w.field, qmhelper.GT, x) }
func (w whereHelperstring) GTE(x string) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) }
func (w whereHelperstring) IN(slice []string) qm.QueryMod {
	values := make([]interface{}, 0, len(slice))
	for _, value := range slice {
		values = append(values, value)
	}
	return qm.WhereIn(fmt.Sprintf("%s IN ?", w.field), values...)
}
type whereHelpernull_String struct{ field string }
func (w whereHelpernull_String) EQ(x null.String) qm.QueryMod {
	return qmhelper.WhereNullEQ(w.field, false, x)
}
func (w whereHelpernull_String) NEQ(x null.String) qm.QueryMod {
	return qmhelper.WhereNullEQ(w.field, true, x)
}
func (w whereHelpernull_String) IsNull() qm.QueryMod    { return qmhelper.WhereIsNull(w.field) }
func (w whereHelpernull_String) IsNotNull() qm.QueryMod { return qmhelper.WhereIsNotNull(w.field) }
func (w whereHelpernull_String) LT(x null.String) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.LT, x)
}
func (w whereHelpernull_String) LTE(x null.String) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.LTE, x)
}
func (w whereHelpernull_String) GT(x null.String) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.GT, x)
}
func (w whereHelpernull_String) GTE(x null.String) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.GTE, x)
}
type whereHelpertypes_StringArray struct{ field string }
func (w whereHelpertypes_StringArray) EQ(x types.StringArray) qm.QueryMod {
	return qmhelper.WhereNullEQ(w.field, false, x)
}
func (w whereHelpertypes_StringArray) NEQ(x types.StringArray) qm.QueryMod {
	return qmhelper.WhereNullEQ(w.field, true, x)
}
func (w whereHelpertypes_StringArray) IsNull() qm.QueryMod { return qmhelper.WhereIsNull(w.field) }
func (w whereHelpertypes_StringArray) IsNotNull() qm.QueryMod {
	return qmhelper.WhereIsNotNull(w.field)
}
func (w whereHelpertypes_StringArray) LT(x types.StringArray) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.LT, x)
}
func (w whereHelpertypes_StringArray) LTE(x types.StringArray) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.LTE, x)
}
func (w whereHelpertypes_StringArray) GT(x types.StringArray) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.GT, x)
}
func (w whereHelpertypes_StringArray) GTE(x types.StringArray) qm.QueryMod {
	return qmhelper.Where(w.field, qmhelper.GTE, x)
}
var NameWhere = struct {
	Nconst             whereHelperstring
	PrimaryName        whereHelpernull_String
	BirthYear          whereHelpernull_String
	DeathYear          whereHelpernull_String
	PrimaryProfessions whereHelpertypes_StringArray
	KnownForTitles     whereHelpertypes_StringArray
}{
	Nconst:             whereHelperstring{field: "\"names\".\"nconst\""},
	PrimaryName:        whereHelpernull_String{field: "\"names\".\"primary_name\""},
	BirthYear:          whereHelpernull_String{field: "\"names\".\"birth_year\""},
	DeathYear:          whereHelpernull_String{field: "\"names\".\"death_year\""},
	PrimaryProfessions: whereHelpertypes_StringArray{field: "\"names\".\"primary_professions\""},
	KnownForTitles:     whereHelpertypes_StringArray{field: "\"names\".\"known_for_titles\""},
}
var NameRels = struct {
}{}
type nameR struct {
}
func (*nameR) NewStruct() *nameR {
	return &nameR{}
}
type nameL struct{}
var (
	nameAllColumns            = []string{"nconst", "primary_name", "birth_year", "death_year", "primary_professions", "known_for_titles"}
	nameColumnsWithoutDefault = []string{"nconst", "primary_name", "birth_year", "primary_professions", "known_for_titles"}
	nameColumnsWithDefault    = []string{"death_year"}
	namePrimaryKeyColumns     = []string{"nconst"}
)
type (
	NameSlice []*Name
	NameHook func(context.Context, boil.ContextExecutor, *Name) error
	nameQuery struct {
		*queries.Query
	}
)
var (
	nameType                 = reflect.TypeOf(&Name{})
	nameMapping              = queries.MakeStructMapping(nameType)
	namePrimaryKeyMapping, _ = queries.BindMapping(nameType, nameMapping, namePrimaryKeyColumns)
	nameInsertCacheMut       sync.RWMutex
	nameInsertCache          = make(map[string]insertCache)
	nameUpdateCacheMut       sync.RWMutex
	nameUpdateCache          = make(map[string]updateCache)
	nameUpsertCacheMut       sync.RWMutex
	nameUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = qmhelper.Where
)
var nameBeforeInsertHooks []NameHook
var nameBeforeUpdateHooks []NameHook
var nameBeforeDeleteHooks []NameHook
var nameBeforeUpsertHooks []NameHook
var nameAfterInsertHooks []NameHook
var nameAfterSelectHooks []NameHook
var nameAfterUpdateHooks []NameHook
var nameAfterDeleteHooks []NameHook
var nameAfterUpsertHooks []NameHook
func (o *Name) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameBeforeInsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doBeforeUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameBeforeUpdateHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doBeforeDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameBeforeDeleteHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameBeforeUpsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doAfterInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameAfterInsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doAfterSelectHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameAfterSelectHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doAfterUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameAfterUpdateHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doAfterDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameAfterDeleteHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Name) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range nameAfterUpsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func AddNameHook(hookPoint boil.HookPoint, nameHook NameHook) {
	switch hookPoint {
	case boil.BeforeInsertHook:
		nameBeforeInsertHooks = append(nameBeforeInsertHooks, nameHook)
	case boil.BeforeUpdateHook:
		nameBeforeUpdateHooks = append(nameBeforeUpdateHooks, nameHook)
	case boil.BeforeDeleteHook:
		nameBeforeDeleteHooks = append(nameBeforeDeleteHooks, nameHook)
	case boil.BeforeUpsertHook:
		nameBeforeUpsertHooks = append(nameBeforeUpsertHooks, nameHook)
	case boil.AfterInsertHook:
		nameAfterInsertHooks = append(nameAfterInsertHooks, nameHook)
	case boil.AfterSelectHook:
		nameAfterSelectHooks = append(nameAfterSelectHooks, nameHook)
	case boil.AfterUpdateHook:
		nameAfterUpdateHooks = append(nameAfterUpdateHooks, nameHook)
	case boil.AfterDeleteHook:
		nameAfterDeleteHooks = append(nameAfterDeleteHooks, nameHook)
	case boil.AfterUpsertHook:
		nameAfterUpsertHooks = append(nameAfterUpsertHooks, nameHook)
	}
}
func (q nameQuery) One(ctx context.Context, exec boil.ContextExecutor) (*Name, error) {
	o := &Name{}
	queries.SetLimit(q.Query, 1)
	err := q.Bind(ctx, exec, 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 names")
	}
	if err := o.doAfterSelectHooks(ctx, exec); err != nil {
		return o, err
	}
	return o, nil
}
func (q nameQuery) All(ctx context.Context, exec boil.ContextExecutor) (NameSlice, error) {
	var o []*Name
	err := q.Bind(ctx, exec, &o)
	if err != nil {
		return nil, errors.Wrap(err, "models: failed to assign all query results to Name slice")
	}
	if len(nameAfterSelectHooks) != 0 {
		for _, obj := range o {
			if err := obj.doAfterSelectHooks(ctx, exec); err != nil {
				return o, err
			}
		}
	}
	return o, nil
}
func (q nameQuery) Count(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	err := q.Query.QueryRowContext(ctx, exec).Scan(&count)
	if err != nil {
		return 0, errors.Wrap(err, "models: failed to count names rows")
	}
	return count, nil
}
func (q nameQuery) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	queries.SetLimit(q.Query, 1)
	err := q.Query.QueryRowContext(ctx, exec).Scan(&count)
	if err != nil {
		return false, errors.Wrap(err, "models: failed to check if names exists")
	}
	return count > 0, nil
}
func Names(mods ...qm.QueryMod) nameQuery {
	mods = append(mods, qm.From("\"names\""))
	return nameQuery{NewQuery(mods...)}
}
func FindName(ctx context.Context, exec boil.ContextExecutor, nconst string, selectCols ...string) (*Name, error) {
	nameObj := &Name{}
	sel := "*"
	if len(selectCols) > 0 {
		sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
	}
	query := fmt.Sprintf(
		"select %s from \"names\" where \"nconst\"=$1", sel,
	)
	q := queries.Raw(query, nconst)
	err := q.Bind(ctx, exec, nameObj)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "models: unable to select from names")
	}
	return nameObj, nil
}
func (o *Name) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error {
	if o == nil {
		return errors.New("models: no names provided for insertion")
	}
	var err error
	if err := o.doBeforeInsertHooks(ctx, exec); err != nil {
		return err
	}
	nzDefaults := queries.NonZeroDefaultSet(nameColumnsWithDefault, o)
	key := makeCacheKey(columns, nzDefaults)
	nameInsertCacheMut.RLock()
	cache, cached := nameInsertCache[key]
	nameInsertCacheMut.RUnlock()
	if !cached {
		wl, returnColumns := columns.InsertColumnSet(
			nameAllColumns,
			nameColumnsWithDefault,
			nameColumnsWithoutDefault,
			nzDefaults,
		)
		cache.valueMapping, err = queries.BindMapping(nameType, nameMapping, wl)
		if err != nil {
			return err
		}
		cache.retMapping, err = queries.BindMapping(nameType, nameMapping, returnColumns)
		if err != nil {
			return err
		}
		if len(wl) != 0 {
			cache.query = fmt.Sprintf("INSERT INTO \"names\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1))
		} else {
			cache.query = "INSERT INTO \"names\" %sDEFAULT VALUES%s"
		}
		var queryOutput, queryReturning string
		if len(cache.retMapping) != 0 {
			queryReturning = fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\""))
		}
		cache.query = fmt.Sprintf(cache.query, queryOutput, queryReturning)
	}
	value := reflect.Indirect(reflect.ValueOf(o))
	vals := queries.ValuesFromMapping(value, cache.valueMapping)
	if boil.IsDebug(ctx) {
		writer := boil.DebugWriterFrom(ctx)
		fmt.Fprintln(writer, cache.query)
		fmt.Fprintln(writer, vals)
	}
	if len(cache.retMapping) != 0 {
		err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
	} else {
		_, err = exec.ExecContext(ctx, cache.query, vals...)
	}
	if err != nil {
		return errors.Wrap(err, "models: unable to insert into names")
	}
	if !cached {
		nameInsertCacheMut.Lock()
		nameInsertCache[key] = cache
		nameInsertCacheMut.Unlock()
	}
	return o.doAfterInsertHooks(ctx, exec)
}
func (o *Name) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error) {
	var err error
	if err = o.doBeforeUpdateHooks(ctx, exec); err != nil {
		return 0, err
	}
	key := makeCacheKey(columns, nil)
	nameUpdateCacheMut.RLock()
	cache, cached := nameUpdateCache[key]
	nameUpdateCacheMut.RUnlock()
	if !cached {
		wl := columns.UpdateColumnSet(
			nameAllColumns,
			namePrimaryKeyColumns,
		)
		if !columns.IsWhitelist() {
			wl = strmangle.SetComplement(wl, []string{"created_at"})
		}
		if len(wl) == 0 {
			return 0, errors.New("models: unable to update names, could not build whitelist")
		}
		cache.query = fmt.Sprintf("UPDATE \"names\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, wl),
			strmangle.WhereClause("\"", "\"", len(wl)+1, namePrimaryKeyColumns),
		)
		cache.valueMapping, err = queries.BindMapping(nameType, nameMapping, append(wl, namePrimaryKeyColumns...))
		if err != nil {
			return 0, err
		}
	}
	values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping)
	if boil.IsDebug(ctx) {
		writer := boil.DebugWriterFrom(ctx)
		fmt.Fprintln(writer, cache.query)
		fmt.Fprintln(writer, values)
	}
	var result sql.Result
	result, err = exec.ExecContext(ctx, cache.query, values...)
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to update names row")
	}
	rowsAff, err := result.RowsAffected()
	if err != nil {
		return 0, errors.Wrap(err, "models: failed to get rows affected by update for names")
	}
	if !cached {
		nameUpdateCacheMut.Lock()
		nameUpdateCache[key] = cache
		nameUpdateCacheMut.Unlock()
	}
	return rowsAff, o.doAfterUpdateHooks(ctx, exec)
}
func (q nameQuery) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) {
	queries.SetUpdate(q.Query, cols)
	result, err := q.Query.ExecContext(ctx, exec)
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to update all for names")
	}
	rowsAff, err := result.RowsAffected()
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to retrieve rows affected for names")
	}
	return rowsAff, nil
}
func (o NameSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) {
	ln := int64(len(o))
	if ln == 0 {
		return 0, nil
	}
	if len(cols) == 0 {
		return 0, errors.New("models: update all requires at least one column argument")
	}
	colNames := make([]string, len(cols))
	args := make([]interface{}, len(cols))
	i := 0
	for name, value := range cols {
		colNames[i] = name
		args[i] = value
		i++
	}
	for _, obj := range o {
		pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), namePrimaryKeyMapping)
		args = append(args, pkeyArgs...)
	}
	sql := fmt.Sprintf("UPDATE \"names\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, colNames),
		strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, namePrimaryKeyColumns, len(o)))
	if boil.IsDebug(ctx) {
		writer := boil.DebugWriterFrom(ctx)
		fmt.Fprintln(writer, sql)
		fmt.Fprintln(writer, args...)
	}
	result, err := exec.ExecContext(ctx, sql, args...)
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to update all in name slice")
	}
	rowsAff, err := result.RowsAffected()
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to retrieve rows affected all in update all name")
	}
	return rowsAff, nil
}
func (o *Name) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error {
	if o == nil {
		return errors.New("models: no names provided for upsert")
	}
	if err := o.doBeforeUpsertHooks(ctx, exec); err != nil {
		return err
	}
	nzDefaults := queries.NonZeroDefaultSet(nameColumnsWithDefault, o)
	buf := strmangle.GetBuffer()
	if updateOnConflict {
		buf.WriteByte('t')
	} else {
		buf.WriteByte('f')
	}
	buf.WriteByte('.')
	for _, c := range conflictColumns {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	buf.WriteString(strconv.Itoa(updateColumns.Kind))
	for _, c := range updateColumns.Cols {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	buf.WriteString(strconv.Itoa(insertColumns.Kind))
	for _, c := range insertColumns.Cols {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range nzDefaults {
		buf.WriteString(c)
	}
	key := buf.String()
	strmangle.PutBuffer(buf)
	nameUpsertCacheMut.RLock()
	cache, cached := nameUpsertCache[key]
	nameUpsertCacheMut.RUnlock()
	var err error
	if !cached {
		insert, ret := insertColumns.InsertColumnSet(
			nameAllColumns,
			nameColumnsWithDefault,
			nameColumnsWithoutDefault,
			nzDefaults,
		)
		update := updateColumns.UpdateColumnSet(
			nameAllColumns,
			namePrimaryKeyColumns,
		)
		if updateOnConflict && len(update) == 0 {
			return errors.New("models: unable to upsert names, could not build update column list")
		}
		conflict := conflictColumns
		if len(conflict) == 0 {
			conflict = make([]string, len(namePrimaryKeyColumns))
			copy(conflict, namePrimaryKeyColumns)
		}
		cache.query = buildUpsertQueryPostgres(dialect, "\"names\"", updateOnConflict, ret, update, conflict, insert)
		cache.valueMapping, err = queries.BindMapping(nameType, nameMapping, insert)
		if err != nil {
			return err
		}
		if len(ret) != 0 {
			cache.retMapping, err = queries.BindMapping(nameType, nameMapping, ret)
			if err != nil {
				return err
			}
		}
	}
	value := reflect.Indirect(reflect.ValueOf(o))
	vals := queries.ValuesFromMapping(value, cache.valueMapping)
	var returns []interface{}
	if len(cache.retMapping) != 0 {
		returns = queries.PtrsFromMapping(value, cache.retMapping)
	}
	if boil.IsDebug(ctx) {
		writer := boil.DebugWriterFrom(ctx)
		fmt.Fprintln(writer, cache.query)
		fmt.Fprintln(writer, vals)
	}
	if len(cache.retMapping) != 0 {
		err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(returns...)
		if err == sql.ErrNoRows {
			err = nil  
		}
	} else {
		_, err = exec.ExecContext(ctx, cache.query, vals...)
	}
	if err != nil {
		return errors.Wrap(err, "models: unable to upsert names")
	}
	if !cached {
		nameUpsertCacheMut.Lock()
		nameUpsertCache[key] = cache
		nameUpsertCacheMut.Unlock()
	}
	return o.doAfterUpsertHooks(ctx, exec)
}
func (o *Name) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
	if o == nil {
		return 0, errors.New("models: no Name provided for delete")
	}
	if err := o.doBeforeDeleteHooks(ctx, exec); err != nil {
		return 0, err
	}
	args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), namePrimaryKeyMapping)
	sql := "DELETE FROM \"names\" WHERE \"nconst\"=$1"
	if boil.IsDebug(ctx) {
		writer := boil.DebugWriterFrom(ctx)
		fmt.Fprintln(writer, sql)
		fmt.Fprintln(writer, args...)
	}
	result, err := exec.ExecContext(ctx, sql, args...)
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to delete from names")
	}
	rowsAff, err := result.RowsAffected()
	if err != nil {
		return 0, errors.Wrap(err, "models: failed to get rows affected by delete for names")
	}
	if err := o.doAfterDeleteHooks(ctx, exec); err != nil {
		return 0, err
	}
	return rowsAff, nil
}
func (q nameQuery) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
	if q.Query == nil {
		return 0, errors.New("models: no nameQuery provided for delete all")
	}
	queries.SetDelete(q.Query)
	result, err := q.Query.ExecContext(ctx, exec)
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to delete all from names")
	}
	rowsAff, err := result.RowsAffected()
	if err != nil {
		return 0, errors.Wrap(err, "models: failed to get rows affected by deleteall for names")
	}
	return rowsAff, nil
}
func (o NameSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
	if len(o) == 0 {
		return 0, nil
	}
	if len(nameBeforeDeleteHooks) != 0 {
		for _, obj := range o {
			if err := obj.doBeforeDeleteHooks(ctx, exec); err != nil {
				return 0, err
			}
		}
	}
	var args []interface{}
	for _, obj := range o {
		pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), namePrimaryKeyMapping)
		args = append(args, pkeyArgs...)
	}
	sql := "DELETE FROM \"names\" WHERE " +
		strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 1, namePrimaryKeyColumns, len(o))
	if boil.IsDebug(ctx) {
		writer := boil.DebugWriterFrom(ctx)
		fmt.Fprintln(writer, sql)
		fmt.Fprintln(writer, args)
	}
	result, err := exec.ExecContext(ctx, sql, args...)
	if err != nil {
		return 0, errors.Wrap(err, "models: unable to delete all from name slice")
	}
	rowsAff, err := result.RowsAffected()
	if err != nil {
		return 0, errors.Wrap(err, "models: failed to get rows affected by deleteall for names")
	}
	if len(nameAfterDeleteHooks) != 0 {
		for _, obj := range o {
			if err := obj.doAfterDeleteHooks(ctx, exec); err != nil {
				return 0, err
			}
		}
	}
	return rowsAff, nil
}
func (o *Name) Reload(ctx context.Context, exec boil.ContextExecutor) error {
	ret, err := FindName(ctx, exec, o.Nconst)
	if err != nil {
		return err
	}
	*o = *ret
	return nil
}
func (o *NameSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error {
	if o == nil || len(*o) == 0 {
		return nil
	}
	slice := NameSlice{}
	var args []interface{}
	for _, obj := range *o {
		pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), namePrimaryKeyMapping)
		args = append(args, pkeyArgs...)
	}
	sql := "SELECT \"names\".* FROM \"names\" WHERE " +
		strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 1, namePrimaryKeyColumns, len(*o))
	q := queries.Raw(sql, args...)
	err := q.Bind(ctx, exec, &slice)
	if err != nil {
		return errors.Wrap(err, "models: unable to reload all in NameSlice")
	}
	*o = slice
	return nil
}