func Authors(exec boil.Executor, mods ...qm.QueryMod) authorQuery {
	mods = append(mods, qm.From("\"authors\""))
	return authorQuery{NewQuery(exec, mods...)}
}
Authors retrieves all the records using an executor.
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 Author struct {
	ID        int64       `boil:"id" json:"id" toml:"id" yaml:"id"`
	Code      string      `boil:"code" json:"code" toml:"code" yaml:"code"`
	Name      string      `boil:"name" json:"name" toml:"name" yaml:"name"`
	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 *authorR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L authorL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var AuthorColumns = struct {
	ID        string
	Code      string
	Name      string
	FullName  string
	CreatedAt string
}{
	ID:        "id",
	Code:      "code",
	Name:      "name",
	FullName:  "full_name",
	CreatedAt: "created_at",
}
type authorR struct {
	AuthorI18ns AuthorI18nSlice
	Sources     SourceSlice
}
type authorL struct{}
var (
	authorColumns               = []string{"id", "code", "name", "full_name", "created_at"}
	authorColumnsWithoutDefault = []string{"code", "name", "full_name"}
	authorColumnsWithDefault    = []string{"id", "created_at"}
	authorPrimaryKeyColumns     = []string{"id"}
)
type (
	AuthorSlice []*Author
	authorQuery struct {
		*queries.Query
	}
)
var (
	authorType                 = reflect.TypeOf(&Author{})
	authorMapping              = queries.MakeStructMapping(authorType)
	authorPrimaryKeyMapping, _ = queries.BindMapping(authorType, authorMapping, authorPrimaryKeyColumns)
	authorInsertCacheMut       sync.RWMutex
	authorInsertCache          = make(map[string]insertCache)
	authorUpdateCacheMut       sync.RWMutex
	authorUpdateCache          = make(map[string]updateCache)
	authorUpsertCacheMut       sync.RWMutex
	authorUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = bytes.MinRead
)
func (q authorQuery) OneP() *Author {
	o, err := q.One()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q authorQuery) One() (*Author, error) {
	o := &Author{}
	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 authors")
	}
	return o, nil
}
func (q authorQuery) AllP() AuthorSlice {
	o, err := q.All()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return o
}
func (q authorQuery) All() (AuthorSlice, error) {
	var o []*Author
	err := q.Bind(&o)
	if err != nil {
		return nil, errors.Wrap(err, "mdbmodels: failed to assign all query results to Author slice")
	}
	return o, nil
}
func (q authorQuery) CountP() int64 {
	c, err := q.Count()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return c
}
func (q authorQuery) 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 authors rows")
	}
	return count, nil
}
func (q authorQuery) ExistsP() bool {
	e, err := q.Exists()
	if err != nil {
		panic(boil.WrapErr(err))
	}
	return e
}
func (q authorQuery) 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 authors exists")
	}
	return count > 0, nil
}
func (o *Author) AuthorI18nsG(mods ...qm.QueryMod) authorI18nQuery {
	return o.AuthorI18ns(boil.GetDB(), mods...)
}
func (o *Author) AuthorI18ns(exec boil.Executor, mods ...qm.QueryMod) authorI18nQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.Where("\"author_i18n\".\"author_id\"=?", o.ID),
	)
	query := AuthorI18ns(exec, queryMods...)
	queries.SetFrom(query.Query, "\"author_i18n\"")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"\"author_i18n\".*"})
	}
	return query
}
func (o *Author) SourcesG(mods ...qm.QueryMod) sourceQuery {
	return o.Sources(boil.GetDB(), mods...)
}
func (o *Author) Sources(exec boil.Executor, mods ...qm.QueryMod) sourceQuery {
	var queryMods []qm.QueryMod
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}
	queryMods = append(queryMods,
		qm.InnerJoin("\"authors_sources\" on \"sources\".\"id\" = \"authors_sources\".\"source_id\""),
		qm.Where("\"authors_sources\".\"author_id\"=?", o.ID),
	)
	query := Sources(exec, queryMods...)
	queries.SetFrom(query.Query, "\"sources\"")
	if len(queries.GetSelect(query.Query)) == 0 {
		queries.SetSelect(query.Query, []string{"\"sources\".*"})
	}
	return query
}
func (authorL) LoadAuthorI18ns(e boil.Executor, singular bool, maybeAuthor interface{}) error {
	var slice []*Author
	var object *Author
	count := 1
	if singular {
		object = maybeAuthor.(*Author)
	} else {
		slice = *maybeAuthor.(*[]*Author)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &authorR{}
		}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &authorR{}
			}
			args[i] = obj.ID
		}
	}
	query := fmt.Sprintf(
		"select * from \"author_i18n\" where \"author_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_i18n")
	}
	defer results.Close()
	var resultSlice []*AuthorI18n
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice author_i18n")
	}
	if singular {
		object.R.AuthorI18ns = resultSlice
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.AuthorID {
				local.R.AuthorI18ns = append(local.R.AuthorI18ns, foreign)
				break
			}
		}
	}
	return nil
}
func (authorL) LoadSources(e boil.Executor, singular bool, maybeAuthor interface{}) error {
	var slice []*Author
	var object *Author
	count := 1
	if singular {
		object = maybeAuthor.(*Author)
	} else {
		slice = *maybeAuthor.(*[]*Author)
		count = len(slice)
	}
	args := make([]interface{}, count)
	if singular {
		if object.R == nil {
			object.R = &authorR{}
		}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			if obj.R == nil {
				obj.R = &authorR{}
			}
			args[i] = obj.ID
		}
	}
	query := fmt.Sprintf(
		"select \"a\".*, \"b\".\"author_id\" from \"sources\" as \"a\" inner join \"authors_sources\" as \"b\" on \"a\".\"id\" = \"b\".\"source_id\" where \"b\".\"author_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 sources")
	}
	defer results.Close()
	var resultSlice []*Source
	var localJoinCols []int64
	for results.Next() {
		one := new(Source)
		var localJoinCol int64
		err = results.Scan(&one.ID, &one.UID, &one.ParentID, &one.Pattern, &one.TypeID, &one.Position, &one.Name, &one.Description, &one.CreatedAt, &one.Properties, &localJoinCol)
		if err = results.Err(); err != nil {
			return errors.Wrap(err, "failed to plebian-bind eager loaded slice sources")
		}
		resultSlice = append(resultSlice, one)
		localJoinCols = append(localJoinCols, localJoinCol)
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "failed to plebian-bind eager loaded slice sources")
	}
	if singular {
		object.R.Sources = resultSlice
		return nil
	}
	for i, foreign := range resultSlice {
		localJoinCol := localJoinCols[i]
		for _, local := range slice {
			if local.ID == localJoinCol {
				local.R.Sources = append(local.R.Sources, foreign)
				break
			}
		}
	}
	return nil
}
func (o *Author) AddAuthorI18nsG(insert bool, related ...*AuthorI18n) error {
	return o.AddAuthorI18ns(boil.GetDB(), insert, related...)
}
func (o *Author) AddAuthorI18nsP(exec boil.Executor, insert bool, related ...*AuthorI18n) {
	if err := o.AddAuthorI18ns(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) AddAuthorI18nsGP(insert bool, related ...*AuthorI18n) {
	if err := o.AddAuthorI18ns(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) AddAuthorI18ns(exec boil.Executor, insert bool, related ...*AuthorI18n) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.AuthorID = o.ID
			if err = rel.Insert(exec); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"author_i18n\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"author_id"}),
				strmangle.WhereClause("\"", "\"", 2, authorI18nPrimaryKeyColumns),
			)
			values := []interface{}{o.ID, rel.AuthorID, rel.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 foreign table")
			}
			rel.AuthorID = o.ID
		}
	}
	if o.R == nil {
		o.R = &authorR{
			AuthorI18ns: related,
		}
	} else {
		o.R.AuthorI18ns = append(o.R.AuthorI18ns, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &authorI18nR{
				Author: o,
			}
		} else {
			rel.R.Author = o
		}
	}
	return nil
}
func (o *Author) AddSourcesG(insert bool, related ...*Source) error {
	return o.AddSources(boil.GetDB(), insert, related...)
}
func (o *Author) AddSourcesP(exec boil.Executor, insert bool, related ...*Source) {
	if err := o.AddSources(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) AddSourcesGP(insert bool, related ...*Source) {
	if err := o.AddSources(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) AddSources(exec boil.Executor, insert bool, related ...*Source) error {
	var err error
	for _, rel := range related {
		if insert {
			if err = rel.Insert(exec); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		}
	}
	for _, rel := range related {
		query := "insert into \"authors_sources\" (\"author_id\", \"source_id\") values ($1, $2)"
		values := []interface{}{o.ID, rel.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 insert into join table")
		}
	}
	if o.R == nil {
		o.R = &authorR{
			Sources: related,
		}
	} else {
		o.R.Sources = append(o.R.Sources, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &sourceR{
				Authors: AuthorSlice{o},
			}
		} else {
			rel.R.Authors = append(rel.R.Authors, o)
		}
	}
	return nil
}
func (o *Author) SetSourcesG(insert bool, related ...*Source) error {
	return o.SetSources(boil.GetDB(), insert, related...)
}
func (o *Author) SetSourcesP(exec boil.Executor, insert bool, related ...*Source) {
	if err := o.SetSources(exec, insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) SetSourcesGP(insert bool, related ...*Source) {
	if err := o.SetSources(boil.GetDB(), insert, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) SetSources(exec boil.Executor, insert bool, related ...*Source) error {
	query := "delete from \"authors_sources\" where \"author_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")
	}
	removeSourcesFromAuthorsSlice(o, related)
	if o.R != nil {
		o.R.Sources = nil
	}
	return o.AddSources(exec, insert, related...)
}
func (o *Author) RemoveSourcesG(related ...*Source) error {
	return o.RemoveSources(boil.GetDB(), related...)
}
func (o *Author) RemoveSourcesP(exec boil.Executor, related ...*Source) {
	if err := o.RemoveSources(exec, related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) RemoveSourcesGP(related ...*Source) {
	if err := o.RemoveSources(boil.GetDB(), related...); err != nil {
		panic(boil.WrapErr(err))
	}
}
func (o *Author) RemoveSources(exec boil.Executor, related ...*Source) error {
	var err error
	query := fmt.Sprintf(
		"delete from \"authors_sources\" where \"author_id\" = $1 and \"source_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, len(related), 2, 1),
	)
	values := []interface{}{o.ID}
	for _, rel := range related {
		values = append(values, rel.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")
	}
	removeSourcesFromAuthorsSlice(o, related)
	if o.R == nil {
		return nil
	}
	for _, rel := range related {
		for i, ri := range o.R.Sources {
			if rel != ri {
				continue
			}
			ln := len(o.R.Sources)
			if ln > 1 && i < ln-1 {
				o.R.Sources[i] = o.R.Sources[ln-1]
			}
			o.R.Sources = o.R.Sources[:ln-1]
			break
		}
	}
	return nil
}
func removeSourcesFromAuthorsSlice(o *Author, related []*Source) {
	for _, rel := range related {
		if rel.R == nil {
			continue
		}
		for i, ri := range rel.R.Authors {
			if o.ID != ri.ID {
				continue
			}
			ln := len(rel.R.Authors)
			if ln > 1 && i < ln-1 {
				rel.R.Authors[i] = rel.R.Authors[ln-1]
			}
			rel.R.Authors = rel.R.Authors[:ln-1]
			break
		}
	}
}
func AuthorsG(mods ...qm.QueryMod) authorQuery {
	return Authors(boil.GetDB(), mods...)
}