func (q authorI18nQuery) DeleteAllP() {
	if err := q.DeleteAll(); err != nil {
		panic(boil.WrapErr(err))
	}
}
DeleteAllP deletes all rows, and panics on error.
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 AuthorI18n struct {
	AuthorID  int64       `boil:"author_id" json:"author_id" toml:"author_id" yaml:"author_id"`
	Language  string      `boil:"language" json:"language" toml:"language" yaml:"language"`
	Name      null.String `boil:"name" json:"name,omitempty" toml:"name" yaml:"name,omitempty"`
	FullName  null.String `boil:"full_name" json:"full_name,omitempty" toml:"full_name" yaml:"full_name,omitempty"`
	CreatedAt time.Time   `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"`
	R *authorI18nR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L authorI18nL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var AuthorI18nColumns = struct {
	AuthorID  string
	Language  string
	Name      string
	FullName  string
	CreatedAt string
}{
	AuthorID:  "author_id",
	Language:  "language",
	Name:      "name",
	FullName:  "full_name",
	CreatedAt: "created_at",
}
type authorI18nR struct {
	Author *Author
}
type authorI18nL struct{}
var (
	authorI18nColumns               = []string{"author_id", "language", "name", "full_name", "created_at"}
	authorI18nColumnsWithoutDefault = []string{"author_id", "language", "name", "full_name"}
	authorI18nColumnsWithDefault    = []string{"created_at"}
	authorI18nPrimaryKeyColumns     = []string{"author_id", "language"}
)
type (
	AuthorI18nSlice []*AuthorI18n
	authorI18nQuery struct {
		*queries.Query
	}
)
var (
	authorI18nType                 = reflect.TypeOf(&AuthorI18n{})
	authorI18nMapping              = queries.MakeStructMapping(authorI18nType)
	authorI18nPrimaryKeyMapping, _ = queries.BindMapping(authorI18nType, authorI18nMapping, authorI18nPrimaryKeyColumns)
	authorI18nInsertCacheMut       sync.RWMutex
	authorI18nInsertCache          = make(map[string]insertCache)
	authorI18nUpdateCacheMut       sync.RWMutex
	authorI18nUpdateCache          = make(map[string]updateCache)
	authorI18nUpsertCacheMut       sync.RWMutex
	authorI18nUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = bytes.MinRead
)
func (q authorI18nQuery) OneP() *AuthorI18n {
	o, err := q.One()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q authorI18nQuery) One() (*AuthorI18n, error) {
	o := &AuthorI18n{}
	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 author_i18n")
	}
	return o, nil
}
func (q authorI18nQuery) AllP() AuthorI18nSlice {
	o, err := q.All()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q authorI18nQuery) All() (AuthorI18nSlice, error) {
	var o []*AuthorI18n
	err := q.Bind(&o)
	if err != nil {
		return nil, errors.Wrap(err, "mdbmodels: failed to assign all query results to AuthorI18n slice")
	}
	return o, nil
}
func (q authorI18nQuery) CountP() int64 {
	c, err := q.Count()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q authorI18nQuery) 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 author_i18n rows")
	}
	return count, nil
}
func (q authorI18nQuery) ExistsP() bool {
	e, err := q.Exists()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q authorI18nQuery) 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 author_i18n exists")
	}
	return count > 0, nil
}
func (o *AuthorI18n) AuthorG(mods ...qm.QueryMod) authorQuery {
	return o.Author(boil.GetDB(), mods...)
}
func (o *AuthorI18n) Author(exec boil.Executor, mods ...qm.QueryMod) authorQuery {
	queryMods := []qm.QueryMod{
		qm.Where("id=?", o.AuthorID),
	}
	queryMods = append(queryMods, mods...)
	query := Authors(exec, queryMods...)
	queries.SetFrom(query.Query, "\"authors\"")
	return query
}  
func (authorI18nL) LoadAuthor(e boil.Executor, singular bool, maybeAuthorI18n interface{}) error {
	var slice []*AuthorI18n
	var object *AuthorI18n
	count := 1
	if singular {
		object = maybeAuthorI18n.(*AuthorI18n)
	} else {
		slice = *maybeAuthorI18n.(*[]*AuthorI18n)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &authorI18nR{}
		}
		args[0] = object.AuthorID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &authorI18nR{}
			}
			args[i] = obj.AuthorID
		}
	}
	query := fmt.Sprintf(
		"select * from \"authors\" where \"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 Author")
	}
	defer results.Close()
	var resultSlice []*Author
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Author")
	}
	if len(resultSlice) == 0 {
		return nil
	}
	if singular {
		object.R.Author = resultSlice[0]
		return nil
	}
	for _, local := range slice {
		for _, foreign := range resultSlice {
			if local.AuthorID == foreign.ID {
				local.R.Author = foreign
				break
			}
		}
	}
	return nil
}
func (o *AuthorI18n) SetAuthorG(insert bool, related *Author) error {
	return o.SetAuthor(boil.GetDB(), insert, related)
}
func (o *AuthorI18n) SetAuthorP(exec boil.Executor, insert bool, related *Author) {
	if err := o.SetAuthor(exec, insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) SetAuthorGP(insert bool, related *Author) {
	if err := o.SetAuthor(boil.GetDB(), insert, related); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) SetAuthor(exec boil.Executor, insert bool, related *Author) error {
	var err error
	if insert {
		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}
	updateQuery := fmt.Sprintf(
		"UPDATE \"author_i18n\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"author_id"}),
		strmangle.WhereClause("\"", "\"", 2, authorI18nPrimaryKeyColumns),
	)
	values := []interface{}{related.ID, o.AuthorID, o.Language}
	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.AuthorID = related.ID
	if o.R == nil {
		o.R = &authorI18nR{
			Author: related,
		}
	} else {
		o.R.Author = related
	}
	if related.R == nil {
		related.R = &authorR{
			AuthorI18ns: AuthorI18nSlice{o},
		}
	} else {
		related.R.AuthorI18ns = append(related.R.AuthorI18ns, o)
	}
	return nil
}
func AuthorI18nsG(mods ...qm.QueryMod) authorI18nQuery {
	return AuthorI18ns(boil.GetDB(), mods...)
}
func AuthorI18ns(exec boil.Executor, mods ...qm.QueryMod) authorI18nQuery {
	mods = append(mods, qm.From("\"author_i18n\""))
	return authorI18nQuery{NewQuery(exec, mods...)}
}
func FindAuthorI18nG(authorID int64, language string, selectCols ...string) (*AuthorI18n, error) {
	return FindAuthorI18n(boil.GetDB(), authorID, language, selectCols...)
}
func FindAuthorI18nGP(authorID int64, language string, selectCols ...string) *AuthorI18n {
	retobj, err := FindAuthorI18n(boil.GetDB(), authorID, language, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func FindAuthorI18n(exec boil.Executor, authorID int64, language string, selectCols ...string) (*AuthorI18n, error) {
	authorI18nObj := &AuthorI18n{}
	sel := "*"
	if len(selectCols) > 0 {
		sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
	}
	query := fmt.Sprintf(
		"select %s from \"author_i18n\" where \"author_id\"=$1 AND \"language\"=$2", sel,
	)
	q := queries.Raw(exec, query, authorID, language)
	err := q.Bind(authorI18nObj)
	if err != nil {
		if errors.Cause(err) == sql.ErrNoRows {
			return nil, sql.ErrNoRows
		}
		return nil, errors.Wrap(err, "mdbmodels: unable to select from author_i18n")
	}
	return authorI18nObj, nil
}
func FindAuthorI18nP(exec boil.Executor, authorID int64, language string, selectCols ...string) *AuthorI18n {
	retobj, err := FindAuthorI18n(exec, authorID, language, selectCols...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return retobj
}
func (o *AuthorI18n) InsertG(whitelist ...string) error {
	return o.Insert(boil.GetDB(), whitelist...)
}
func (o *AuthorI18n) InsertGP(whitelist ...string) {
	if err := o.Insert(boil.GetDB(), whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) InsertP(exec boil.Executor, whitelist ...string) {
	if err := o.Insert(exec, whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) Insert(exec boil.Executor, whitelist ...string) error {
	if o == nil {
		return errors.New("mdbmodels: no author_i18n provided for insertion")
	}
	var err error
	nzDefaults := queries.NonZeroDefaultSet(authorI18nColumnsWithDefault, o)
	key := makeCacheKey(whitelist, nzDefaults)
	authorI18nInsertCacheMut.RLock()
	cache, cached := authorI18nInsertCache[key]
	authorI18nInsertCacheMut.RUnlock()
	if !cached {
		wl, returnColumns := strmangle.InsertColumnSet(
			authorI18nColumns,
			authorI18nColumnsWithDefault,
			authorI18nColumnsWithoutDefault,
			nzDefaults,
			whitelist,
		)
		cache.valueMapping, err = queries.BindMapping(authorI18nType, authorI18nMapping, wl)
		if err != nil {
			return err
		}
		cache.retMapping, err = queries.BindMapping(authorI18nType, authorI18nMapping, returnColumns)
		if err != nil {
			return err
		}
		if len(wl) != 0 {
			cache.query = fmt.Sprintf("INSERT INTO \"author_i18n\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.IndexPlaceholders, len(wl), 1, 1))
		} else {
			cache.query = "INSERT INTO \"author_i18n\" DEFAULT VALUES"
		}
		var queryOutput, queryReturning string
		if len(cache.retMapping) != 0 {
			queryReturning = fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\""))
		}
		if len(wl) != 0 {
			cache.query = fmt.Sprintf(cache.query, queryOutput, queryReturning)
		}
	}
	value := reflect.Indirect(reflect.ValueOf(o))
	vals := queries.ValuesFromMapping(value, cache.valueMapping)
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, vals)
	}
	if len(cache.retMapping) != 0 {
		err = exec.QueryRow(cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
	} else {
		_, err = exec.Exec(cache.query, vals...)
	}
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to insert into author_i18n")
	}
	if !cached {
		authorI18nInsertCacheMut.Lock()
		authorI18nInsertCache[key] = cache
		authorI18nInsertCacheMut.Unlock()
	}
	return nil
}
func (o *AuthorI18n) UpdateG(whitelist ...string) error {
	return o.Update(boil.GetDB(), whitelist...)
}
func (o *AuthorI18n) UpdateGP(whitelist ...string) {
	if err := o.Update(boil.GetDB(), whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) UpdateP(exec boil.Executor, whitelist ...string) {
	err := o.Update(exec, whitelist...)
	if err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) Update(exec boil.Executor, whitelist ...string) error {
	var err error
	key := makeCacheKey(whitelist, nil)
	authorI18nUpdateCacheMut.RLock()
	cache, cached := authorI18nUpdateCache[key]
	authorI18nUpdateCacheMut.RUnlock()
	if !cached {
		wl := strmangle.UpdateColumnSet(
			authorI18nColumns,
			authorI18nPrimaryKeyColumns,
			whitelist,
		)
		if len(wl) == 0 {
			return errors.New("mdbmodels: unable to update author_i18n, could not build whitelist")
		}
		cache.query = fmt.Sprintf("UPDATE \"author_i18n\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, wl),
			strmangle.WhereClause("\"", "\"", len(wl)+1, authorI18nPrimaryKeyColumns),
		)
		cache.valueMapping, err = queries.BindMapping(authorI18nType, authorI18nMapping, append(wl, authorI18nPrimaryKeyColumns...))
		if err != nil {
			return err
		}
	}
	values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping)
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, values)
	}
	_, err = exec.Exec(cache.query, values...)
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to update author_i18n row")
	}
	if !cached {
		authorI18nUpdateCacheMut.Lock()
		authorI18nUpdateCache[key] = cache
		authorI18nUpdateCacheMut.Unlock()
	}
	return nil
}
func (q authorI18nQuery) UpdateAllP(cols M) {
	if err := q.UpdateAll(cols); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (q authorI18nQuery) UpdateAll(cols M) error {
	queries.SetUpdate(q.Query, cols)
	_, err := q.Query.Exec()
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to update all for author_i18n")
	}
	return nil
}
func (o AuthorI18nSlice) UpdateAllG(cols M) error {
	return o.UpdateAll(boil.GetDB(), cols)
}
func (o AuthorI18nSlice) UpdateAllGP(cols M) {
	if err := o.UpdateAll(boil.GetDB(), cols); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o AuthorI18nSlice) UpdateAllP(exec boil.Executor, cols M) {
	if err := o.UpdateAll(exec, cols); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o AuthorI18nSlice) UpdateAll(exec boil.Executor, cols M) error {
	ln := int64(len(o))
	if ln == 0 {
		return nil
	}
	if len(cols) == 0 {
		return errors.New("mdbmodels: 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)), authorI18nPrimaryKeyMapping)
		args = append(args, pkeyArgs...)
	}
	sql := fmt.Sprintf("UPDATE \"author_i18n\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, colNames),
		strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, authorI18nPrimaryKeyColumns, len(o)))
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, sql)
		fmt.Fprintln(boil.DebugWriter, args...)
	}
	_, err := exec.Exec(sql, args...)
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to update all in authorI18n slice")
	}
	return nil
}
func (o *AuthorI18n) UpsertG(updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) error {
	return o.Upsert(boil.GetDB(), updateOnConflict, conflictColumns, updateColumns, whitelist...)
}
func (o *AuthorI18n) UpsertGP(updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) {
	if err := o.Upsert(boil.GetDB(), updateOnConflict, conflictColumns, updateColumns, whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) UpsertP(exec boil.Executor, updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) {
	if err := o.Upsert(exec, updateOnConflict, conflictColumns, updateColumns, whitelist...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) Upsert(exec boil.Executor, updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) error {
	if o == nil {
		return errors.New("mdbmodels: no author_i18n provided for upsert")
	}
	nzDefaults := queries.NonZeroDefaultSet(authorI18nColumnsWithDefault, o)
	buf := strmangle.GetBuffer()
	if updateOnConflict {
		buf.WriteByte('t')
	} else {
		buf.WriteByte('f')
	}
	buf.WriteByte('.')
	for _, c := range conflictColumns {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range updateColumns {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range whitelist {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range nzDefaults {
		buf.WriteString(c)
	}
	key := buf.String()
	strmangle.PutBuffer(buf)
	authorI18nUpsertCacheMut.RLock()
	cache, cached := authorI18nUpsertCache[key]
	authorI18nUpsertCacheMut.RUnlock()
	var err error
	if !cached {
		insert, ret := strmangle.InsertColumnSet(
			authorI18nColumns,
			authorI18nColumnsWithDefault,
			authorI18nColumnsWithoutDefault,
			nzDefaults,
			whitelist,
		)
		update := strmangle.UpdateColumnSet(
			authorI18nColumns,
			authorI18nPrimaryKeyColumns,
			updateColumns,
		)
		if len(update) == 0 {
			return errors.New("mdbmodels: unable to upsert author_i18n, could not build update column list")
		}
		conflict := conflictColumns
		if len(conflict) == 0 {
			conflict = make([]string, len(authorI18nPrimaryKeyColumns))
			copy(conflict, authorI18nPrimaryKeyColumns)
		}
		cache.query = queries.BuildUpsertQueryPostgres(dialect, "\"author_i18n\"", updateOnConflict, ret, update, conflict, insert)
		cache.valueMapping, err = queries.BindMapping(authorI18nType, authorI18nMapping, insert)
		if err != nil {
			return err
		}
		if len(ret) != 0 {
			cache.retMapping, err = queries.BindMapping(authorI18nType, authorI18nMapping, 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.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, vals)
	}
	if len(cache.retMapping) != 0 {
		err = exec.QueryRow(cache.query, vals...).Scan(returns...)
		if err == sql.ErrNoRows {
			err = nil  
		}
	} else {
		_, err = exec.Exec(cache.query, vals...)
	}
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to upsert author_i18n")
	}
	if !cached {
		authorI18nUpsertCacheMut.Lock()
		authorI18nUpsertCache[key] = cache
		authorI18nUpsertCacheMut.Unlock()
	}
	return nil
}
func (o *AuthorI18n) DeleteP(exec boil.Executor) {
	if err := o.Delete(exec); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) DeleteG() error {
	if o == nil {
		return errors.New("mdbmodels: no AuthorI18n provided for deletion")
	}
	return o.Delete(boil.GetDB())
}
func (o *AuthorI18n) DeleteGP() {
	if err := o.DeleteG(); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *AuthorI18n) Delete(exec boil.Executor) error {
	if o == nil {
		return errors.New("mdbmodels: no AuthorI18n provided for delete")
	}
	args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), authorI18nPrimaryKeyMapping)
	sql := "DELETE FROM \"author_i18n\" WHERE \"author_id\"=$1 AND \"language\"=$2"
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, sql)
		fmt.Fprintln(boil.DebugWriter, args...)
	}
	_, err := exec.Exec(sql, args...)
	if err != nil {
		return errors.Wrap(err, "mdbmodels: unable to delete from author_i18n")
	}
	return nil
}