// Code generated by BobGen mysql v0.42.0. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.

package models

import (
	"context"
	"fmt"
	"io"
	"time"

	"github.com/aarondl/opt/null"
	"github.com/aarondl/opt/omit"
	"github.com/aarondl/opt/omitnull"
	"github.com/stephenafamo/bob"
	"github.com/stephenafamo/bob/dialect/mysql"
	"github.com/stephenafamo/bob/dialect/mysql/dialect"
	"github.com/stephenafamo/bob/dialect/mysql/dm"
	"github.com/stephenafamo/bob/dialect/mysql/sm"
	"github.com/stephenafamo/bob/dialect/mysql/um"
	"github.com/stephenafamo/bob/expr"
	"github.com/stephenafamo/bob/mods"
	"github.com/stephenafamo/bob/orm"
)

// LocationsSpace is an object representing the database table.
type LocationsSpace struct {
	ID             int32               `db:"id,pk,autoincr" `
	UUID           string              `db:"uuid" `
	AccessProtocol string              `db:"access_protocol" `
	Size           null.Val[int64]     `db:"size" `
	Used           int64               `db:"used" `
	Path           string              `db:"path" `
	Verified       bool                `db:"verified" `
	LastVerified   null.Val[time.Time] `db:"last_verified" `
	StagingPath    string              `db:"staging_path" `

	R locationsSpaceR `db:"-" `
}

// LocationsSpaceSlice is an alias for a slice of pointers to LocationsSpace.
// This should almost always be used instead of []*LocationsSpace.
type LocationsSpaceSlice []*LocationsSpace

// LocationsSpaces contains methods to work with the locations_space table
var LocationsSpaces = mysql.NewTablex[*LocationsSpace, LocationsSpaceSlice, *LocationsSpaceSetter]("locations_space", buildLocationsSpaceColumns("locations_space"), []string{"id"}, []string{"uuid"})

// LocationsSpacesQuery is a query on the locations_space table
type LocationsSpacesQuery = *mysql.ViewQuery[*LocationsSpace, LocationsSpaceSlice]

// locationsSpaceR is where relationships are stored.
type locationsSpaceR struct {
	SpaceLocationsArchipelago           *LocationsArchipelago           // locations_archipelago_space_id_be47fd5c_fk_locations_space_uuid
	SpaceLocationsArkivum               *LocationsArkivum               // locations_arkivum_space_id_d159e309_fk_locations_space_uuid
	SpaceLocationsDataverse             *LocationsDataverse             // locations_dataverse_space_id_1b94d732_fk_locations_space_uuid
	SpaceLocationsDspace                *LocationsDspace                // locations_dspace_space_id_e1c12ce1_fk_locations_space_uuid
	SpaceLocationsDspacerest            *LocationsDspacerest            // locations_dspacerest_space_id_6ae6a82b_fk_locations_space_uuid
	SpaceLocationsDuracloud             *LocationsDuracloud             // locations_duracloud_space_id_753df0f2_fk_locations_space_uuid
	SpaceLocationsFedora                *LocationsFedora                // locations_fedora_space_id_088fe895_fk_locations_space_uuid
	SpaceLocationsGPG                   *LocationsGPG                   // locations_gpg_space_id_6223440d_fk_locations_space_uuid
	SpaceLocationsLocalfilesystem       *LocationsLocalfilesystem       // locations_localfiles_space_id_a97d3d9f_fk_locations
	SpaceLocationsLocations             LocationsLocationSlice          // locations_location_space_id_748845a7_fk_locations_space_uuid
	SpaceLocationsLockssomatic          *LocationsLockssomatic          // locations_lockssomatic_space_id_cc6a3cd6_fk_locations_space_uuid
	SpaceLocationsNF                    *LocationsNF                    // locations_nfs_space_id_34913c3b_fk_locations_space_uuid
	SpaceLocationsOfflinereplicastaging *LocationsOfflinereplicastaging // locations_offlinerep_space_id_2a8d7578_fk_locations
	SpaceLocationsPipelinelocalf        *LocationsPipelinelocalf        // locations_pipelinelo_space_id_6f6ba9f6_fk_locations
	SpaceLocationsRclone                *LocationsRclone                // locations_rclone_space_id_adb7fd1d_fk_locations_space_uuid
	SpaceLocationsS3                    *LocationsS3                    // locations_s3_space_id_d8fc3ba3_fk_locations_space_uuid
	SpaceLocationsSwift                 *LocationsSwift                 // locations_swift_space_id_9cfded49_fk_locations_space_uuid
}

func buildLocationsSpaceColumns(alias string) locationsSpaceColumns {
	return locationsSpaceColumns{
		ColumnsExpr: expr.NewColumnsExpr(
			"id", "uuid", "access_protocol", "size", "used", "path", "verified", "last_verified", "staging_path",
		).WithParent("locations_space"),
		tableAlias:     alias,
		ID:             mysql.Quote(alias, "id"),
		UUID:           mysql.Quote(alias, "uuid"),
		AccessProtocol: mysql.Quote(alias, "access_protocol"),
		Size:           mysql.Quote(alias, "size"),
		Used:           mysql.Quote(alias, "used"),
		Path:           mysql.Quote(alias, "path"),
		Verified:       mysql.Quote(alias, "verified"),
		LastVerified:   mysql.Quote(alias, "last_verified"),
		StagingPath:    mysql.Quote(alias, "staging_path"),
	}
}

type locationsSpaceColumns struct {
	expr.ColumnsExpr
	tableAlias     string
	ID             mysql.Expression
	UUID           mysql.Expression
	AccessProtocol mysql.Expression
	Size           mysql.Expression
	Used           mysql.Expression
	Path           mysql.Expression
	Verified       mysql.Expression
	LastVerified   mysql.Expression
	StagingPath    mysql.Expression
}

func (c locationsSpaceColumns) Alias() string {
	return c.tableAlias
}

func (locationsSpaceColumns) AliasedAs(alias string) locationsSpaceColumns {
	return buildLocationsSpaceColumns(alias)
}

// LocationsSpaceSetter is used for insert/upsert/update operations
// All values are optional, and do not have to be set
// Generated columns are not included
type LocationsSpaceSetter struct {
	ID             omit.Val[int32]         `db:"id,pk,autoincr" `
	UUID           omit.Val[string]        `db:"uuid" `
	AccessProtocol omit.Val[string]        `db:"access_protocol" `
	Size           omitnull.Val[int64]     `db:"size" `
	Used           omit.Val[int64]         `db:"used" `
	Path           omit.Val[string]        `db:"path" `
	Verified       omit.Val[bool]          `db:"verified" `
	LastVerified   omitnull.Val[time.Time] `db:"last_verified" `
	StagingPath    omit.Val[string]        `db:"staging_path" `
}

func (s LocationsSpaceSetter) SetColumns() []string {
	vals := make([]string, 0, 9)
	if s.ID.IsValue() {
		vals = append(vals, "id")
	}
	if s.UUID.IsValue() {
		vals = append(vals, "uuid")
	}
	if s.AccessProtocol.IsValue() {
		vals = append(vals, "access_protocol")
	}
	if !s.Size.IsUnset() {
		vals = append(vals, "size")
	}
	if s.Used.IsValue() {
		vals = append(vals, "used")
	}
	if s.Path.IsValue() {
		vals = append(vals, "path")
	}
	if s.Verified.IsValue() {
		vals = append(vals, "verified")
	}
	if !s.LastVerified.IsUnset() {
		vals = append(vals, "last_verified")
	}
	if s.StagingPath.IsValue() {
		vals = append(vals, "staging_path")
	}
	return vals
}

func (s LocationsSpaceSetter) Overwrite(t *LocationsSpace) {
	if s.ID.IsValue() {
		t.ID = s.ID.MustGet()
	}
	if s.UUID.IsValue() {
		t.UUID = s.UUID.MustGet()
	}
	if s.AccessProtocol.IsValue() {
		t.AccessProtocol = s.AccessProtocol.MustGet()
	}
	if !s.Size.IsUnset() {
		t.Size = s.Size.MustGetNull()
	}
	if s.Used.IsValue() {
		t.Used = s.Used.MustGet()
	}
	if s.Path.IsValue() {
		t.Path = s.Path.MustGet()
	}
	if s.Verified.IsValue() {
		t.Verified = s.Verified.MustGet()
	}
	if !s.LastVerified.IsUnset() {
		t.LastVerified = s.LastVerified.MustGetNull()
	}
	if s.StagingPath.IsValue() {
		t.StagingPath = s.StagingPath.MustGet()
	}
}

func (s *LocationsSpaceSetter) Apply(q *dialect.InsertQuery) {
	q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
		return LocationsSpaces.BeforeInsertHooks.RunHooks(ctx, exec, s)
	})

	q.AppendValues(
		bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(s.ID.IsValue()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.ID.MustGet()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(s.UUID.IsValue()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.UUID.MustGet()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(s.AccessProtocol.IsValue()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.AccessProtocol.MustGet()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(!s.Size.IsUnset()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.Size.MustGetNull()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(s.Used.IsValue()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.Used.MustGet()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(s.Path.IsValue()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.Path.MustGet()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(s.Verified.IsValue()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.Verified.MustGet()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(!s.LastVerified.IsUnset()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.LastVerified.MustGetNull()).WriteSQL(ctx, w, d, start)
		}), bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
			if !(s.StagingPath.IsValue()) {
				return mysql.Raw("DEFAULT").WriteSQL(ctx, w, d, start)
			}
			return mysql.Arg(s.StagingPath.MustGet()).WriteSQL(ctx, w, d, start)
		}))
}

func (s LocationsSpaceSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
	return um.Set(s.Expressions("locations_space")...)
}

func (s LocationsSpaceSetter) Expressions(prefix ...string) []bob.Expression {
	exprs := make([]bob.Expression, 0, 9)

	if s.ID.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "id")...),
			mysql.Arg(s.ID),
		}})
	}

	if s.UUID.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "uuid")...),
			mysql.Arg(s.UUID),
		}})
	}

	if s.AccessProtocol.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "access_protocol")...),
			mysql.Arg(s.AccessProtocol),
		}})
	}

	if !s.Size.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "size")...),
			mysql.Arg(s.Size),
		}})
	}

	if s.Used.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "used")...),
			mysql.Arg(s.Used),
		}})
	}

	if s.Path.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "path")...),
			mysql.Arg(s.Path),
		}})
	}

	if s.Verified.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "verified")...),
			mysql.Arg(s.Verified),
		}})
	}

	if !s.LastVerified.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "last_verified")...),
			mysql.Arg(s.LastVerified),
		}})
	}

	if s.StagingPath.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			mysql.Quote(append(prefix, "staging_path")...),
			mysql.Arg(s.StagingPath),
		}})
	}

	return exprs
}

// FindLocationsSpace retrieves a single record by primary key
// If cols is empty Find will return all columns.
func FindLocationsSpace(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*LocationsSpace, error) {
	if len(cols) == 0 {
		return LocationsSpaces.Query(
			sm.Where(LocationsSpaces.Columns.ID.EQ(mysql.Arg(IDPK))),
		).One(ctx, exec)
	}

	return LocationsSpaces.Query(
		sm.Where(LocationsSpaces.Columns.ID.EQ(mysql.Arg(IDPK))),
		sm.Columns(LocationsSpaces.Columns.Only(cols...)),
	).One(ctx, exec)
}

// LocationsSpaceExists checks the presence of a single record by primary key
func LocationsSpaceExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
	return LocationsSpaces.Query(
		sm.Where(LocationsSpaces.Columns.ID.EQ(mysql.Arg(IDPK))),
	).Exists(ctx, exec)
}

// AfterQueryHook is called after LocationsSpace is retrieved from the database
func (o *LocationsSpace) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
	var err error

	switch queryType {
	case bob.QueryTypeSelect:
		ctx, err = LocationsSpaces.AfterSelectHooks.RunHooks(ctx, exec, LocationsSpaceSlice{o})
	case bob.QueryTypeInsert:
		ctx, err = LocationsSpaces.AfterInsertHooks.RunHooks(ctx, exec, LocationsSpaceSlice{o})
	case bob.QueryTypeUpdate:
		ctx, err = LocationsSpaces.AfterUpdateHooks.RunHooks(ctx, exec, LocationsSpaceSlice{o})
	case bob.QueryTypeDelete:
		ctx, err = LocationsSpaces.AfterDeleteHooks.RunHooks(ctx, exec, LocationsSpaceSlice{o})
	}

	return err
}

// primaryKeyVals returns the primary key values of the LocationsSpace
func (o *LocationsSpace) primaryKeyVals() bob.Expression {
	return mysql.Arg(o.ID)
}

func (o *LocationsSpace) pkEQ() dialect.Expression {
	return mysql.Quote("locations_space", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
		return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
	}))
}

// Update uses an executor to update the LocationsSpace
func (o *LocationsSpace) Update(ctx context.Context, exec bob.Executor, s *LocationsSpaceSetter) error {
	_, err := LocationsSpaces.Update(s.UpdateMod(), um.Where(o.pkEQ())).Exec(ctx, exec)
	if err != nil {
		return err
	}

	s.Overwrite(o)

	return nil
}

// Delete deletes a single LocationsSpace record with an executor
func (o *LocationsSpace) Delete(ctx context.Context, exec bob.Executor) error {
	_, err := LocationsSpaces.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
	return err
}

// Reload refreshes the LocationsSpace using the executor
func (o *LocationsSpace) Reload(ctx context.Context, exec bob.Executor) error {
	o2, err := LocationsSpaces.Query(
		sm.Where(LocationsSpaces.Columns.ID.EQ(mysql.Arg(o.ID))),
	).One(ctx, exec)
	if err != nil {
		return err
	}
	o2.R = o.R
	*o = *o2

	return nil
}

// AfterQueryHook is called after LocationsSpaceSlice is retrieved from the database
func (o LocationsSpaceSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
	var err error

	switch queryType {
	case bob.QueryTypeSelect:
		ctx, err = LocationsSpaces.AfterSelectHooks.RunHooks(ctx, exec, o)
	case bob.QueryTypeInsert:
		ctx, err = LocationsSpaces.AfterInsertHooks.RunHooks(ctx, exec, o)
	case bob.QueryTypeUpdate:
		ctx, err = LocationsSpaces.AfterUpdateHooks.RunHooks(ctx, exec, o)
	case bob.QueryTypeDelete:
		ctx, err = LocationsSpaces.AfterDeleteHooks.RunHooks(ctx, exec, o)
	}

	return err
}

func (o LocationsSpaceSlice) pkIN() dialect.Expression {
	if len(o) == 0 {
		return mysql.Raw("NULL")
	}

	return mysql.Quote("locations_space", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
		pkPairs := make([]bob.Expression, len(o))
		for i, row := range o {
			pkPairs[i] = row.primaryKeyVals()
		}
		return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
	}))
}

// copyMatchingRows finds models in the given slice that have the same primary key
// then it first copies the existing relationships from the old model to the new model
// and then replaces the old model in the slice with the new model
func (o LocationsSpaceSlice) copyMatchingRows(from ...*LocationsSpace) {
	for i, old := range o {
		for _, new := range from {
			if new.ID != old.ID {
				continue
			}
			new.R = old.R
			o[i] = new
			break
		}
	}
}

// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
func (o LocationsSpaceSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
	return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
		q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
			return LocationsSpaces.BeforeUpdateHooks.RunHooks(ctx, exec, o)
		})

		q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
			var err error
			switch retrieved := retrieved.(type) {
			case *LocationsSpace:
				o.copyMatchingRows(retrieved)
			case []*LocationsSpace:
				o.copyMatchingRows(retrieved...)
			case LocationsSpaceSlice:
				o.copyMatchingRows(retrieved...)
			default:
				// If the retrieved value is not a LocationsSpace or a slice of LocationsSpace
				// then run the AfterUpdateHooks on the slice
				_, err = LocationsSpaces.AfterUpdateHooks.RunHooks(ctx, exec, o)
			}

			return err
		}))

		q.AppendWhere(o.pkIN())
	})
}

// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
func (o LocationsSpaceSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
	return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
		q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
			return LocationsSpaces.BeforeDeleteHooks.RunHooks(ctx, exec, o)
		})

		q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
			var err error
			switch retrieved := retrieved.(type) {
			case *LocationsSpace:
				o.copyMatchingRows(retrieved)
			case []*LocationsSpace:
				o.copyMatchingRows(retrieved...)
			case LocationsSpaceSlice:
				o.copyMatchingRows(retrieved...)
			default:
				// If the retrieved value is not a LocationsSpace or a slice of LocationsSpace
				// then run the AfterDeleteHooks on the slice
				_, err = LocationsSpaces.AfterDeleteHooks.RunHooks(ctx, exec, o)
			}

			return err
		}))

		q.AppendWhere(o.pkIN())
	})
}

func (o LocationsSpaceSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals LocationsSpaceSetter) error {
	_, err := LocationsSpaces.Update(vals.UpdateMod(), o.UpdateMod()).Exec(ctx, exec)

	for i := range o {
		vals.Overwrite(o[i])
	}

	return err
}

func (o LocationsSpaceSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
	if len(o) == 0 {
		return nil
	}

	_, err := LocationsSpaces.Delete(o.DeleteMod()).Exec(ctx, exec)
	return err
}

func (o LocationsSpaceSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
	if len(o) == 0 {
		return nil
	}

	o2, err := LocationsSpaces.Query(sm.Where(o.pkIN())).All(ctx, exec)
	if err != nil {
		return err
	}

	o.copyMatchingRows(o2...)

	return nil
}

// SpaceLocationsArchipelago starts a query for related objects on locations_archipelago
func (o *LocationsSpace) SpaceLocationsArchipelago(mods ...bob.Mod[*dialect.SelectQuery]) LocationsArchipelagosQuery {
	return LocationsArchipelagos.Query(append(mods,
		sm.Where(LocationsArchipelagos.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsArchipelago(mods ...bob.Mod[*dialect.SelectQuery]) LocationsArchipelagosQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsArchipelagos.Query(append(mods,
		sm.Where(mysql.Group(LocationsArchipelagos.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsArkivum starts a query for related objects on locations_arkivum
func (o *LocationsSpace) SpaceLocationsArkivum(mods ...bob.Mod[*dialect.SelectQuery]) LocationsArkivumsQuery {
	return LocationsArkivums.Query(append(mods,
		sm.Where(LocationsArkivums.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsArkivum(mods ...bob.Mod[*dialect.SelectQuery]) LocationsArkivumsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsArkivums.Query(append(mods,
		sm.Where(mysql.Group(LocationsArkivums.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsDataverse starts a query for related objects on locations_dataverse
func (o *LocationsSpace) SpaceLocationsDataverse(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDataversesQuery {
	return LocationsDataverses.Query(append(mods,
		sm.Where(LocationsDataverses.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsDataverse(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDataversesQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsDataverses.Query(append(mods,
		sm.Where(mysql.Group(LocationsDataverses.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsDspace starts a query for related objects on locations_dspace
func (o *LocationsSpace) SpaceLocationsDspace(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDspacesQuery {
	return LocationsDspaces.Query(append(mods,
		sm.Where(LocationsDspaces.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsDspace(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDspacesQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsDspaces.Query(append(mods,
		sm.Where(mysql.Group(LocationsDspaces.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsDspacerest starts a query for related objects on locations_dspacerest
func (o *LocationsSpace) SpaceLocationsDspacerest(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDspacerestsQuery {
	return LocationsDspacerests.Query(append(mods,
		sm.Where(LocationsDspacerests.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsDspacerest(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDspacerestsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsDspacerests.Query(append(mods,
		sm.Where(mysql.Group(LocationsDspacerests.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsDuracloud starts a query for related objects on locations_duracloud
func (o *LocationsSpace) SpaceLocationsDuracloud(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDuracloudsQuery {
	return LocationsDuraclouds.Query(append(mods,
		sm.Where(LocationsDuraclouds.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsDuracloud(mods ...bob.Mod[*dialect.SelectQuery]) LocationsDuracloudsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsDuraclouds.Query(append(mods,
		sm.Where(mysql.Group(LocationsDuraclouds.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsFedora starts a query for related objects on locations_fedora
func (o *LocationsSpace) SpaceLocationsFedora(mods ...bob.Mod[*dialect.SelectQuery]) LocationsFedorasQuery {
	return LocationsFedoras.Query(append(mods,
		sm.Where(LocationsFedoras.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsFedora(mods ...bob.Mod[*dialect.SelectQuery]) LocationsFedorasQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsFedoras.Query(append(mods,
		sm.Where(mysql.Group(LocationsFedoras.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsGPG starts a query for related objects on locations_gpg
func (o *LocationsSpace) SpaceLocationsGPG(mods ...bob.Mod[*dialect.SelectQuery]) LocationsGPGSQuery {
	return LocationsGPGS.Query(append(mods,
		sm.Where(LocationsGPGS.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsGPG(mods ...bob.Mod[*dialect.SelectQuery]) LocationsGPGSQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsGPGS.Query(append(mods,
		sm.Where(mysql.Group(LocationsGPGS.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsLocalfilesystem starts a query for related objects on locations_localfilesystem
func (o *LocationsSpace) SpaceLocationsLocalfilesystem(mods ...bob.Mod[*dialect.SelectQuery]) LocationsLocalfilesystemsQuery {
	return LocationsLocalfilesystems.Query(append(mods,
		sm.Where(LocationsLocalfilesystems.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsLocalfilesystem(mods ...bob.Mod[*dialect.SelectQuery]) LocationsLocalfilesystemsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsLocalfilesystems.Query(append(mods,
		sm.Where(mysql.Group(LocationsLocalfilesystems.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsLocations starts a query for related objects on locations_location
func (o *LocationsSpace) SpaceLocationsLocations(mods ...bob.Mod[*dialect.SelectQuery]) LocationsLocationsQuery {
	return LocationsLocations.Query(append(mods,
		sm.Where(LocationsLocations.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsLocations(mods ...bob.Mod[*dialect.SelectQuery]) LocationsLocationsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsLocations.Query(append(mods,
		sm.Where(mysql.Group(LocationsLocations.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsLockssomatic starts a query for related objects on locations_lockssomatic
func (o *LocationsSpace) SpaceLocationsLockssomatic(mods ...bob.Mod[*dialect.SelectQuery]) LocationsLockssomaticsQuery {
	return LocationsLockssomatics.Query(append(mods,
		sm.Where(LocationsLockssomatics.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsLockssomatic(mods ...bob.Mod[*dialect.SelectQuery]) LocationsLockssomaticsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsLockssomatics.Query(append(mods,
		sm.Where(mysql.Group(LocationsLockssomatics.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsNF starts a query for related objects on locations_nfs
func (o *LocationsSpace) SpaceLocationsNF(mods ...bob.Mod[*dialect.SelectQuery]) LocationsNFSQuery {
	return LocationsNFS.Query(append(mods,
		sm.Where(LocationsNFS.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsNF(mods ...bob.Mod[*dialect.SelectQuery]) LocationsNFSQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsNFS.Query(append(mods,
		sm.Where(mysql.Group(LocationsNFS.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsOfflinereplicastaging starts a query for related objects on locations_offlinereplicastaging
func (o *LocationsSpace) SpaceLocationsOfflinereplicastaging(mods ...bob.Mod[*dialect.SelectQuery]) LocationsOfflinereplicastagingsQuery {
	return LocationsOfflinereplicastagings.Query(append(mods,
		sm.Where(LocationsOfflinereplicastagings.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsOfflinereplicastaging(mods ...bob.Mod[*dialect.SelectQuery]) LocationsOfflinereplicastagingsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsOfflinereplicastagings.Query(append(mods,
		sm.Where(mysql.Group(LocationsOfflinereplicastagings.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsPipelinelocalf starts a query for related objects on locations_pipelinelocalfs
func (o *LocationsSpace) SpaceLocationsPipelinelocalf(mods ...bob.Mod[*dialect.SelectQuery]) LocationsPipelinelocalfsQuery {
	return LocationsPipelinelocalfs.Query(append(mods,
		sm.Where(LocationsPipelinelocalfs.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsPipelinelocalf(mods ...bob.Mod[*dialect.SelectQuery]) LocationsPipelinelocalfsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsPipelinelocalfs.Query(append(mods,
		sm.Where(mysql.Group(LocationsPipelinelocalfs.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsRclone starts a query for related objects on locations_rclone
func (o *LocationsSpace) SpaceLocationsRclone(mods ...bob.Mod[*dialect.SelectQuery]) LocationsRclonesQuery {
	return LocationsRclones.Query(append(mods,
		sm.Where(LocationsRclones.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsRclone(mods ...bob.Mod[*dialect.SelectQuery]) LocationsRclonesQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsRclones.Query(append(mods,
		sm.Where(mysql.Group(LocationsRclones.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsS3 starts a query for related objects on locations_s3
func (o *LocationsSpace) SpaceLocationsS3(mods ...bob.Mod[*dialect.SelectQuery]) LocationsS3SQuery {
	return LocationsS3S.Query(append(mods,
		sm.Where(LocationsS3S.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsS3(mods ...bob.Mod[*dialect.SelectQuery]) LocationsS3SQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsS3S.Query(append(mods,
		sm.Where(mysql.Group(LocationsS3S.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

// SpaceLocationsSwift starts a query for related objects on locations_swift
func (o *LocationsSpace) SpaceLocationsSwift(mods ...bob.Mod[*dialect.SelectQuery]) LocationsSwiftsQuery {
	return LocationsSwifts.Query(append(mods,
		sm.Where(LocationsSwifts.Columns.SpaceID.EQ(mysql.Arg(o.UUID))),
	)...)
}

func (os LocationsSpaceSlice) SpaceLocationsSwift(mods ...bob.Mod[*dialect.SelectQuery]) LocationsSwiftsQuery {
	PKArgSlice := make([]bob.Expression, len(os))
	for i, o := range os {
		PKArgSlice[i] = mysql.ArgGroup(o.UUID)
	}
	PKArgExpr := mysql.Group(PKArgSlice...)

	return LocationsSwifts.Query(append(mods,
		sm.Where(mysql.Group(LocationsSwifts.Columns.SpaceID).OP("IN", PKArgExpr)),
	)...)
}

func insertLocationsSpaceSpaceLocationsArchipelago0(ctx context.Context, exec bob.Executor, locationsArchipelago1 *LocationsArchipelagoSetter, locationsSpace0 *LocationsSpace) (*LocationsArchipelago, error) {
	locationsArchipelago1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsArchipelagos.Insert(locationsArchipelago1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsArchipelago0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsArchipelago0(ctx context.Context, exec bob.Executor, count int, locationsArchipelago1 *LocationsArchipelago, locationsSpace0 *LocationsSpace) (*LocationsArchipelago, error) {
	setter := &LocationsArchipelagoSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsArchipelago1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsArchipelago0: %w", err)
	}

	return locationsArchipelago1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsArchipelago(ctx context.Context, exec bob.Executor, related *LocationsArchipelagoSetter) error {
	var err error

	locationsArchipelago1, err := insertLocationsSpaceSpaceLocationsArchipelago0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsArchipelago = locationsArchipelago1

	locationsArchipelago1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsArchipelago(ctx context.Context, exec bob.Executor, locationsArchipelago1 *LocationsArchipelago) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsArchipelago0(ctx, exec, 1, locationsArchipelago1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsArchipelago = locationsArchipelago1

	locationsArchipelago1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsArkivum0(ctx context.Context, exec bob.Executor, locationsArkivum1 *LocationsArkivumSetter, locationsSpace0 *LocationsSpace) (*LocationsArkivum, error) {
	locationsArkivum1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsArkivums.Insert(locationsArkivum1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsArkivum0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsArkivum0(ctx context.Context, exec bob.Executor, count int, locationsArkivum1 *LocationsArkivum, locationsSpace0 *LocationsSpace) (*LocationsArkivum, error) {
	setter := &LocationsArkivumSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsArkivum1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsArkivum0: %w", err)
	}

	return locationsArkivum1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsArkivum(ctx context.Context, exec bob.Executor, related *LocationsArkivumSetter) error {
	var err error

	locationsArkivum1, err := insertLocationsSpaceSpaceLocationsArkivum0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsArkivum = locationsArkivum1

	locationsArkivum1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsArkivum(ctx context.Context, exec bob.Executor, locationsArkivum1 *LocationsArkivum) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsArkivum0(ctx, exec, 1, locationsArkivum1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsArkivum = locationsArkivum1

	locationsArkivum1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsDataverse0(ctx context.Context, exec bob.Executor, locationsDataverse1 *LocationsDataverseSetter, locationsSpace0 *LocationsSpace) (*LocationsDataverse, error) {
	locationsDataverse1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsDataverses.Insert(locationsDataverse1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsDataverse0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsDataverse0(ctx context.Context, exec bob.Executor, count int, locationsDataverse1 *LocationsDataverse, locationsSpace0 *LocationsSpace) (*LocationsDataverse, error) {
	setter := &LocationsDataverseSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsDataverse1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsDataverse0: %w", err)
	}

	return locationsDataverse1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsDataverse(ctx context.Context, exec bob.Executor, related *LocationsDataverseSetter) error {
	var err error

	locationsDataverse1, err := insertLocationsSpaceSpaceLocationsDataverse0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDataverse = locationsDataverse1

	locationsDataverse1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsDataverse(ctx context.Context, exec bob.Executor, locationsDataverse1 *LocationsDataverse) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsDataverse0(ctx, exec, 1, locationsDataverse1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDataverse = locationsDataverse1

	locationsDataverse1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsDspace0(ctx context.Context, exec bob.Executor, locationsDspace1 *LocationsDspaceSetter, locationsSpace0 *LocationsSpace) (*LocationsDspace, error) {
	locationsDspace1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsDspaces.Insert(locationsDspace1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsDspace0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsDspace0(ctx context.Context, exec bob.Executor, count int, locationsDspace1 *LocationsDspace, locationsSpace0 *LocationsSpace) (*LocationsDspace, error) {
	setter := &LocationsDspaceSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsDspace1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsDspace0: %w", err)
	}

	return locationsDspace1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsDspace(ctx context.Context, exec bob.Executor, related *LocationsDspaceSetter) error {
	var err error

	locationsDspace1, err := insertLocationsSpaceSpaceLocationsDspace0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDspace = locationsDspace1

	locationsDspace1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsDspace(ctx context.Context, exec bob.Executor, locationsDspace1 *LocationsDspace) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsDspace0(ctx, exec, 1, locationsDspace1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDspace = locationsDspace1

	locationsDspace1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsDspacerest0(ctx context.Context, exec bob.Executor, locationsDspacerest1 *LocationsDspacerestSetter, locationsSpace0 *LocationsSpace) (*LocationsDspacerest, error) {
	locationsDspacerest1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsDspacerests.Insert(locationsDspacerest1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsDspacerest0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsDspacerest0(ctx context.Context, exec bob.Executor, count int, locationsDspacerest1 *LocationsDspacerest, locationsSpace0 *LocationsSpace) (*LocationsDspacerest, error) {
	setter := &LocationsDspacerestSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsDspacerest1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsDspacerest0: %w", err)
	}

	return locationsDspacerest1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsDspacerest(ctx context.Context, exec bob.Executor, related *LocationsDspacerestSetter) error {
	var err error

	locationsDspacerest1, err := insertLocationsSpaceSpaceLocationsDspacerest0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDspacerest = locationsDspacerest1

	locationsDspacerest1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsDspacerest(ctx context.Context, exec bob.Executor, locationsDspacerest1 *LocationsDspacerest) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsDspacerest0(ctx, exec, 1, locationsDspacerest1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDspacerest = locationsDspacerest1

	locationsDspacerest1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsDuracloud0(ctx context.Context, exec bob.Executor, locationsDuracloud1 *LocationsDuracloudSetter, locationsSpace0 *LocationsSpace) (*LocationsDuracloud, error) {
	locationsDuracloud1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsDuraclouds.Insert(locationsDuracloud1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsDuracloud0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsDuracloud0(ctx context.Context, exec bob.Executor, count int, locationsDuracloud1 *LocationsDuracloud, locationsSpace0 *LocationsSpace) (*LocationsDuracloud, error) {
	setter := &LocationsDuracloudSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsDuracloud1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsDuracloud0: %w", err)
	}

	return locationsDuracloud1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsDuracloud(ctx context.Context, exec bob.Executor, related *LocationsDuracloudSetter) error {
	var err error

	locationsDuracloud1, err := insertLocationsSpaceSpaceLocationsDuracloud0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDuracloud = locationsDuracloud1

	locationsDuracloud1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsDuracloud(ctx context.Context, exec bob.Executor, locationsDuracloud1 *LocationsDuracloud) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsDuracloud0(ctx, exec, 1, locationsDuracloud1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsDuracloud = locationsDuracloud1

	locationsDuracloud1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsFedora0(ctx context.Context, exec bob.Executor, locationsFedora1 *LocationsFedoraSetter, locationsSpace0 *LocationsSpace) (*LocationsFedora, error) {
	locationsFedora1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsFedoras.Insert(locationsFedora1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsFedora0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsFedora0(ctx context.Context, exec bob.Executor, count int, locationsFedora1 *LocationsFedora, locationsSpace0 *LocationsSpace) (*LocationsFedora, error) {
	setter := &LocationsFedoraSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsFedora1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsFedora0: %w", err)
	}

	return locationsFedora1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsFedora(ctx context.Context, exec bob.Executor, related *LocationsFedoraSetter) error {
	var err error

	locationsFedora1, err := insertLocationsSpaceSpaceLocationsFedora0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsFedora = locationsFedora1

	locationsFedora1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsFedora(ctx context.Context, exec bob.Executor, locationsFedora1 *LocationsFedora) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsFedora0(ctx, exec, 1, locationsFedora1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsFedora = locationsFedora1

	locationsFedora1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsGPG0(ctx context.Context, exec bob.Executor, locationsGPG1 *LocationsGPGSetter, locationsSpace0 *LocationsSpace) (*LocationsGPG, error) {
	locationsGPG1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsGPGS.Insert(locationsGPG1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsGPG0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsGPG0(ctx context.Context, exec bob.Executor, count int, locationsGPG1 *LocationsGPG, locationsSpace0 *LocationsSpace) (*LocationsGPG, error) {
	setter := &LocationsGPGSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsGPG1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsGPG0: %w", err)
	}

	return locationsGPG1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsGPG(ctx context.Context, exec bob.Executor, related *LocationsGPGSetter) error {
	var err error

	locationsGPG1, err := insertLocationsSpaceSpaceLocationsGPG0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsGPG = locationsGPG1

	locationsGPG1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsGPG(ctx context.Context, exec bob.Executor, locationsGPG1 *LocationsGPG) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsGPG0(ctx, exec, 1, locationsGPG1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsGPG = locationsGPG1

	locationsGPG1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsLocalfilesystem0(ctx context.Context, exec bob.Executor, locationsLocalfilesystem1 *LocationsLocalfilesystemSetter, locationsSpace0 *LocationsSpace) (*LocationsLocalfilesystem, error) {
	locationsLocalfilesystem1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsLocalfilesystems.Insert(locationsLocalfilesystem1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsLocalfilesystem0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsLocalfilesystem0(ctx context.Context, exec bob.Executor, count int, locationsLocalfilesystem1 *LocationsLocalfilesystem, locationsSpace0 *LocationsSpace) (*LocationsLocalfilesystem, error) {
	setter := &LocationsLocalfilesystemSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsLocalfilesystem1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsLocalfilesystem0: %w", err)
	}

	return locationsLocalfilesystem1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsLocalfilesystem(ctx context.Context, exec bob.Executor, related *LocationsLocalfilesystemSetter) error {
	var err error

	locationsLocalfilesystem1, err := insertLocationsSpaceSpaceLocationsLocalfilesystem0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsLocalfilesystem = locationsLocalfilesystem1

	locationsLocalfilesystem1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsLocalfilesystem(ctx context.Context, exec bob.Executor, locationsLocalfilesystem1 *LocationsLocalfilesystem) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsLocalfilesystem0(ctx, exec, 1, locationsLocalfilesystem1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsLocalfilesystem = locationsLocalfilesystem1

	locationsLocalfilesystem1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsLocations0(ctx context.Context, exec bob.Executor, locationsLocations1 []*LocationsLocationSetter, locationsSpace0 *LocationsSpace) (LocationsLocationSlice, error) {
	for i := range locationsLocations1 {
		locationsLocations1[i].SpaceID = omit.From(locationsSpace0.UUID)
	}

	ret, err := LocationsLocations.Insert(bob.ToMods(locationsLocations1...)).All(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsLocations0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsLocations0(ctx context.Context, exec bob.Executor, count int, locationsLocations1 LocationsLocationSlice, locationsSpace0 *LocationsSpace) (LocationsLocationSlice, error) {
	setter := &LocationsLocationSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsLocations1.UpdateAll(ctx, exec, *setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsLocations0: %w", err)
	}

	return locationsLocations1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsLocations(ctx context.Context, exec bob.Executor, related ...*LocationsLocationSetter) error {
	if len(related) == 0 {
		return nil
	}

	var err error

	locationsLocations1, err := insertLocationsSpaceSpaceLocationsLocations0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsLocations = append(locationsSpace0.R.SpaceLocationsLocations, locationsLocations1...)

	for _, rel := range locationsLocations1 {
		rel.R.SpaceLocationsSpace = locationsSpace0
	}
	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsLocations(ctx context.Context, exec bob.Executor, related ...*LocationsLocation) error {
	if len(related) == 0 {
		return nil
	}

	var err error
	locationsLocations1 := LocationsLocationSlice(related)

	_, err = attachLocationsSpaceSpaceLocationsLocations0(ctx, exec, len(related), locationsLocations1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsLocations = append(locationsSpace0.R.SpaceLocationsLocations, locationsLocations1...)

	for _, rel := range related {
		rel.R.SpaceLocationsSpace = locationsSpace0
	}

	return nil
}

func insertLocationsSpaceSpaceLocationsLockssomatic0(ctx context.Context, exec bob.Executor, locationsLockssomatic1 *LocationsLockssomaticSetter, locationsSpace0 *LocationsSpace) (*LocationsLockssomatic, error) {
	locationsLockssomatic1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsLockssomatics.Insert(locationsLockssomatic1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsLockssomatic0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsLockssomatic0(ctx context.Context, exec bob.Executor, count int, locationsLockssomatic1 *LocationsLockssomatic, locationsSpace0 *LocationsSpace) (*LocationsLockssomatic, error) {
	setter := &LocationsLockssomaticSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsLockssomatic1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsLockssomatic0: %w", err)
	}

	return locationsLockssomatic1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsLockssomatic(ctx context.Context, exec bob.Executor, related *LocationsLockssomaticSetter) error {
	var err error

	locationsLockssomatic1, err := insertLocationsSpaceSpaceLocationsLockssomatic0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsLockssomatic = locationsLockssomatic1

	locationsLockssomatic1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsLockssomatic(ctx context.Context, exec bob.Executor, locationsLockssomatic1 *LocationsLockssomatic) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsLockssomatic0(ctx, exec, 1, locationsLockssomatic1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsLockssomatic = locationsLockssomatic1

	locationsLockssomatic1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsNF0(ctx context.Context, exec bob.Executor, locationsNF1 *LocationsNFSetter, locationsSpace0 *LocationsSpace) (*LocationsNF, error) {
	locationsNF1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsNFS.Insert(locationsNF1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsNF0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsNF0(ctx context.Context, exec bob.Executor, count int, locationsNF1 *LocationsNF, locationsSpace0 *LocationsSpace) (*LocationsNF, error) {
	setter := &LocationsNFSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsNF1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsNF0: %w", err)
	}

	return locationsNF1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsNF(ctx context.Context, exec bob.Executor, related *LocationsNFSetter) error {
	var err error

	locationsNF1, err := insertLocationsSpaceSpaceLocationsNF0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsNF = locationsNF1

	locationsNF1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsNF(ctx context.Context, exec bob.Executor, locationsNF1 *LocationsNF) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsNF0(ctx, exec, 1, locationsNF1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsNF = locationsNF1

	locationsNF1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsOfflinereplicastaging0(ctx context.Context, exec bob.Executor, locationsOfflinereplicastaging1 *LocationsOfflinereplicastagingSetter, locationsSpace0 *LocationsSpace) (*LocationsOfflinereplicastaging, error) {
	locationsOfflinereplicastaging1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsOfflinereplicastagings.Insert(locationsOfflinereplicastaging1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsOfflinereplicastaging0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsOfflinereplicastaging0(ctx context.Context, exec bob.Executor, count int, locationsOfflinereplicastaging1 *LocationsOfflinereplicastaging, locationsSpace0 *LocationsSpace) (*LocationsOfflinereplicastaging, error) {
	setter := &LocationsOfflinereplicastagingSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsOfflinereplicastaging1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsOfflinereplicastaging0: %w", err)
	}

	return locationsOfflinereplicastaging1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsOfflinereplicastaging(ctx context.Context, exec bob.Executor, related *LocationsOfflinereplicastagingSetter) error {
	var err error

	locationsOfflinereplicastaging1, err := insertLocationsSpaceSpaceLocationsOfflinereplicastaging0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsOfflinereplicastaging = locationsOfflinereplicastaging1

	locationsOfflinereplicastaging1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsOfflinereplicastaging(ctx context.Context, exec bob.Executor, locationsOfflinereplicastaging1 *LocationsOfflinereplicastaging) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsOfflinereplicastaging0(ctx, exec, 1, locationsOfflinereplicastaging1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsOfflinereplicastaging = locationsOfflinereplicastaging1

	locationsOfflinereplicastaging1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsPipelinelocalf0(ctx context.Context, exec bob.Executor, locationsPipelinelocalf1 *LocationsPipelinelocalfSetter, locationsSpace0 *LocationsSpace) (*LocationsPipelinelocalf, error) {
	locationsPipelinelocalf1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsPipelinelocalfs.Insert(locationsPipelinelocalf1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsPipelinelocalf0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsPipelinelocalf0(ctx context.Context, exec bob.Executor, count int, locationsPipelinelocalf1 *LocationsPipelinelocalf, locationsSpace0 *LocationsSpace) (*LocationsPipelinelocalf, error) {
	setter := &LocationsPipelinelocalfSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsPipelinelocalf1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsPipelinelocalf0: %w", err)
	}

	return locationsPipelinelocalf1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsPipelinelocalf(ctx context.Context, exec bob.Executor, related *LocationsPipelinelocalfSetter) error {
	var err error

	locationsPipelinelocalf1, err := insertLocationsSpaceSpaceLocationsPipelinelocalf0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsPipelinelocalf = locationsPipelinelocalf1

	locationsPipelinelocalf1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsPipelinelocalf(ctx context.Context, exec bob.Executor, locationsPipelinelocalf1 *LocationsPipelinelocalf) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsPipelinelocalf0(ctx, exec, 1, locationsPipelinelocalf1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsPipelinelocalf = locationsPipelinelocalf1

	locationsPipelinelocalf1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsRclone0(ctx context.Context, exec bob.Executor, locationsRclone1 *LocationsRcloneSetter, locationsSpace0 *LocationsSpace) (*LocationsRclone, error) {
	locationsRclone1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsRclones.Insert(locationsRclone1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsRclone0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsRclone0(ctx context.Context, exec bob.Executor, count int, locationsRclone1 *LocationsRclone, locationsSpace0 *LocationsSpace) (*LocationsRclone, error) {
	setter := &LocationsRcloneSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsRclone1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsRclone0: %w", err)
	}

	return locationsRclone1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsRclone(ctx context.Context, exec bob.Executor, related *LocationsRcloneSetter) error {
	var err error

	locationsRclone1, err := insertLocationsSpaceSpaceLocationsRclone0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsRclone = locationsRclone1

	locationsRclone1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsRclone(ctx context.Context, exec bob.Executor, locationsRclone1 *LocationsRclone) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsRclone0(ctx, exec, 1, locationsRclone1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsRclone = locationsRclone1

	locationsRclone1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsS30(ctx context.Context, exec bob.Executor, locationsS31 *LocationsS3Setter, locationsSpace0 *LocationsSpace) (*LocationsS3, error) {
	locationsS31.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsS3S.Insert(locationsS31).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsS30: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsS30(ctx context.Context, exec bob.Executor, count int, locationsS31 *LocationsS3, locationsSpace0 *LocationsSpace) (*LocationsS3, error) {
	setter := &LocationsS3Setter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsS31.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsS30: %w", err)
	}

	return locationsS31, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsS3(ctx context.Context, exec bob.Executor, related *LocationsS3Setter) error {
	var err error

	locationsS31, err := insertLocationsSpaceSpaceLocationsS30(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsS3 = locationsS31

	locationsS31.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsS3(ctx context.Context, exec bob.Executor, locationsS31 *LocationsS3) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsS30(ctx, exec, 1, locationsS31, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsS3 = locationsS31

	locationsS31.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func insertLocationsSpaceSpaceLocationsSwift0(ctx context.Context, exec bob.Executor, locationsSwift1 *LocationsSwiftSetter, locationsSpace0 *LocationsSpace) (*LocationsSwift, error) {
	locationsSwift1.SpaceID = omit.From(locationsSpace0.UUID)

	ret, err := LocationsSwifts.Insert(locationsSwift1).One(ctx, exec)
	if err != nil {
		return ret, fmt.Errorf("insertLocationsSpaceSpaceLocationsSwift0: %w", err)
	}

	return ret, nil
}

func attachLocationsSpaceSpaceLocationsSwift0(ctx context.Context, exec bob.Executor, count int, locationsSwift1 *LocationsSwift, locationsSpace0 *LocationsSpace) (*LocationsSwift, error) {
	setter := &LocationsSwiftSetter{
		SpaceID: omit.From(locationsSpace0.UUID),
	}

	err := locationsSwift1.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachLocationsSpaceSpaceLocationsSwift0: %w", err)
	}

	return locationsSwift1, nil
}

func (locationsSpace0 *LocationsSpace) InsertSpaceLocationsSwift(ctx context.Context, exec bob.Executor, related *LocationsSwiftSetter) error {
	var err error

	locationsSwift1, err := insertLocationsSpaceSpaceLocationsSwift0(ctx, exec, related, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsSwift = locationsSwift1

	locationsSwift1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

func (locationsSpace0 *LocationsSpace) AttachSpaceLocationsSwift(ctx context.Context, exec bob.Executor, locationsSwift1 *LocationsSwift) error {
	var err error

	_, err = attachLocationsSpaceSpaceLocationsSwift0(ctx, exec, 1, locationsSwift1, locationsSpace0)
	if err != nil {
		return err
	}

	locationsSpace0.R.SpaceLocationsSwift = locationsSwift1

	locationsSwift1.R.SpaceLocationsSpace = locationsSpace0

	return nil
}

type locationsSpaceWhere[Q mysql.Filterable] struct {
	ID             mysql.WhereMod[Q, int32]
	UUID           mysql.WhereMod[Q, string]
	AccessProtocol mysql.WhereMod[Q, string]
	Size           mysql.WhereNullMod[Q, int64]
	Used           mysql.WhereMod[Q, int64]
	Path           mysql.WhereMod[Q, string]
	Verified       mysql.WhereMod[Q, bool]
	LastVerified   mysql.WhereNullMod[Q, time.Time]
	StagingPath    mysql.WhereMod[Q, string]
}

func (locationsSpaceWhere[Q]) AliasedAs(alias string) locationsSpaceWhere[Q] {
	return buildLocationsSpaceWhere[Q](buildLocationsSpaceColumns(alias))
}

func buildLocationsSpaceWhere[Q mysql.Filterable](cols locationsSpaceColumns) locationsSpaceWhere[Q] {
	return locationsSpaceWhere[Q]{
		ID:             mysql.Where[Q, int32](cols.ID),
		UUID:           mysql.Where[Q, string](cols.UUID),
		AccessProtocol: mysql.Where[Q, string](cols.AccessProtocol),
		Size:           mysql.WhereNull[Q, int64](cols.Size),
		Used:           mysql.Where[Q, int64](cols.Used),
		Path:           mysql.Where[Q, string](cols.Path),
		Verified:       mysql.Where[Q, bool](cols.Verified),
		LastVerified:   mysql.WhereNull[Q, time.Time](cols.LastVerified),
		StagingPath:    mysql.Where[Q, string](cols.StagingPath),
	}
}

func (o *LocationsSpace) Preload(name string, retrieved any) error {
	if o == nil {
		return nil
	}

	switch name {
	case "SpaceLocationsArchipelago":
		rel, ok := retrieved.(*LocationsArchipelago)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsArchipelago = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsArkivum":
		rel, ok := retrieved.(*LocationsArkivum)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsArkivum = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsDataverse":
		rel, ok := retrieved.(*LocationsDataverse)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsDataverse = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsDspace":
		rel, ok := retrieved.(*LocationsDspace)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsDspace = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsDspacerest":
		rel, ok := retrieved.(*LocationsDspacerest)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsDspacerest = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsDuracloud":
		rel, ok := retrieved.(*LocationsDuracloud)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsDuracloud = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsFedora":
		rel, ok := retrieved.(*LocationsFedora)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsFedora = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsGPG":
		rel, ok := retrieved.(*LocationsGPG)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsGPG = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsLocalfilesystem":
		rel, ok := retrieved.(*LocationsLocalfilesystem)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsLocalfilesystem = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsLocations":
		rels, ok := retrieved.(LocationsLocationSlice)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsLocations = rels

		for _, rel := range rels {
			if rel != nil {
				rel.R.SpaceLocationsSpace = o
			}
		}
		return nil
	case "SpaceLocationsLockssomatic":
		rel, ok := retrieved.(*LocationsLockssomatic)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsLockssomatic = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsNF":
		rel, ok := retrieved.(*LocationsNF)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsNF = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsOfflinereplicastaging":
		rel, ok := retrieved.(*LocationsOfflinereplicastaging)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsOfflinereplicastaging = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsPipelinelocalf":
		rel, ok := retrieved.(*LocationsPipelinelocalf)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsPipelinelocalf = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsRclone":
		rel, ok := retrieved.(*LocationsRclone)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsRclone = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsS3":
		rel, ok := retrieved.(*LocationsS3)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsS3 = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	case "SpaceLocationsSwift":
		rel, ok := retrieved.(*LocationsSwift)
		if !ok {
			return fmt.Errorf("locationsSpace cannot load %T as %q", retrieved, name)
		}

		o.R.SpaceLocationsSwift = rel

		if rel != nil {
			rel.R.SpaceLocationsSpace = o
		}
		return nil
	default:
		return fmt.Errorf("locationsSpace has no relationship %q", name)
	}
}

type locationsSpacePreloader struct {
	SpaceLocationsArchipelago           func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsArkivum               func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsDataverse             func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsDspace                func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsDspacerest            func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsDuracloud             func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsFedora                func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsGPG                   func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsLocalfilesystem       func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsLockssomatic          func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsNF                    func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsOfflinereplicastaging func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsPipelinelocalf        func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsRclone                func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsS3                    func(...mysql.PreloadOption) mysql.Preloader
	SpaceLocationsSwift                 func(...mysql.PreloadOption) mysql.Preloader
}

func buildLocationsSpacePreloader() locationsSpacePreloader {
	return locationsSpacePreloader{
		SpaceLocationsArchipelago: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsArchipelago, LocationsArchipelagoSlice](mysql.PreloadRel{
				Name: "SpaceLocationsArchipelago",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsArchipelagos,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsArchipelagos.Columns.Names(), opts...)
		},
		SpaceLocationsArkivum: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsArkivum, LocationsArkivumSlice](mysql.PreloadRel{
				Name: "SpaceLocationsArkivum",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsArkivums,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsArkivums.Columns.Names(), opts...)
		},
		SpaceLocationsDataverse: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsDataverse, LocationsDataverseSlice](mysql.PreloadRel{
				Name: "SpaceLocationsDataverse",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsDataverses,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsDataverses.Columns.Names(), opts...)
		},
		SpaceLocationsDspace: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsDspace, LocationsDspaceSlice](mysql.PreloadRel{
				Name: "SpaceLocationsDspace",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsDspaces,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsDspaces.Columns.Names(), opts...)
		},
		SpaceLocationsDspacerest: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsDspacerest, LocationsDspacerestSlice](mysql.PreloadRel{
				Name: "SpaceLocationsDspacerest",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsDspacerests,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsDspacerests.Columns.Names(), opts...)
		},
		SpaceLocationsDuracloud: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsDuracloud, LocationsDuracloudSlice](mysql.PreloadRel{
				Name: "SpaceLocationsDuracloud",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsDuraclouds,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsDuraclouds.Columns.Names(), opts...)
		},
		SpaceLocationsFedora: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsFedora, LocationsFedoraSlice](mysql.PreloadRel{
				Name: "SpaceLocationsFedora",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsFedoras,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsFedoras.Columns.Names(), opts...)
		},
		SpaceLocationsGPG: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsGPG, LocationsGPGSlice](mysql.PreloadRel{
				Name: "SpaceLocationsGPG",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsGPGS,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsGPGS.Columns.Names(), opts...)
		},
		SpaceLocationsLocalfilesystem: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsLocalfilesystem, LocationsLocalfilesystemSlice](mysql.PreloadRel{
				Name: "SpaceLocationsLocalfilesystem",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsLocalfilesystems,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsLocalfilesystems.Columns.Names(), opts...)
		},
		SpaceLocationsLockssomatic: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsLockssomatic, LocationsLockssomaticSlice](mysql.PreloadRel{
				Name: "SpaceLocationsLockssomatic",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsLockssomatics,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsLockssomatics.Columns.Names(), opts...)
		},
		SpaceLocationsNF: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsNF, LocationsNFSlice](mysql.PreloadRel{
				Name: "SpaceLocationsNF",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsNFS,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsNFS.Columns.Names(), opts...)
		},
		SpaceLocationsOfflinereplicastaging: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsOfflinereplicastaging, LocationsOfflinereplicastagingSlice](mysql.PreloadRel{
				Name: "SpaceLocationsOfflinereplicastaging",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsOfflinereplicastagings,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsOfflinereplicastagings.Columns.Names(), opts...)
		},
		SpaceLocationsPipelinelocalf: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsPipelinelocalf, LocationsPipelinelocalfSlice](mysql.PreloadRel{
				Name: "SpaceLocationsPipelinelocalf",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsPipelinelocalfs,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsPipelinelocalfs.Columns.Names(), opts...)
		},
		SpaceLocationsRclone: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsRclone, LocationsRcloneSlice](mysql.PreloadRel{
				Name: "SpaceLocationsRclone",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsRclones,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsRclones.Columns.Names(), opts...)
		},
		SpaceLocationsS3: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsS3, LocationsS3Slice](mysql.PreloadRel{
				Name: "SpaceLocationsS3",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsS3S,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsS3S.Columns.Names(), opts...)
		},
		SpaceLocationsSwift: func(opts ...mysql.PreloadOption) mysql.Preloader {
			return mysql.Preload[*LocationsSwift, LocationsSwiftSlice](mysql.PreloadRel{
				Name: "SpaceLocationsSwift",
				Sides: []mysql.PreloadSide{
					{
						From:        LocationsSpaces,
						To:          LocationsSwifts,
						FromColumns: []string{"uuid"},
						ToColumns:   []string{"space_id"},
					},
				},
			}, LocationsSwifts.Columns.Names(), opts...)
		},
	}
}

type locationsSpaceThenLoader[Q orm.Loadable] struct {
	SpaceLocationsArchipelago           func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsArkivum               func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsDataverse             func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsDspace                func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsDspacerest            func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsDuracloud             func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsFedora                func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsGPG                   func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsLocalfilesystem       func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsLocations             func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsLockssomatic          func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsNF                    func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsOfflinereplicastaging func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsPipelinelocalf        func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsRclone                func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsS3                    func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
	SpaceLocationsSwift                 func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}

func buildLocationsSpaceThenLoader[Q orm.Loadable]() locationsSpaceThenLoader[Q] {
	type SpaceLocationsArchipelagoLoadInterface interface {
		LoadSpaceLocationsArchipelago(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsArkivumLoadInterface interface {
		LoadSpaceLocationsArkivum(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsDataverseLoadInterface interface {
		LoadSpaceLocationsDataverse(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsDspaceLoadInterface interface {
		LoadSpaceLocationsDspace(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsDspacerestLoadInterface interface {
		LoadSpaceLocationsDspacerest(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsDuracloudLoadInterface interface {
		LoadSpaceLocationsDuracloud(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsFedoraLoadInterface interface {
		LoadSpaceLocationsFedora(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsGPGLoadInterface interface {
		LoadSpaceLocationsGPG(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsLocalfilesystemLoadInterface interface {
		LoadSpaceLocationsLocalfilesystem(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsLocationsLoadInterface interface {
		LoadSpaceLocationsLocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsLockssomaticLoadInterface interface {
		LoadSpaceLocationsLockssomatic(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsNFLoadInterface interface {
		LoadSpaceLocationsNF(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsOfflinereplicastagingLoadInterface interface {
		LoadSpaceLocationsOfflinereplicastaging(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsPipelinelocalfLoadInterface interface {
		LoadSpaceLocationsPipelinelocalf(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsRcloneLoadInterface interface {
		LoadSpaceLocationsRclone(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsS3LoadInterface interface {
		LoadSpaceLocationsS3(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}
	type SpaceLocationsSwiftLoadInterface interface {
		LoadSpaceLocationsSwift(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}

	return locationsSpaceThenLoader[Q]{
		SpaceLocationsArchipelago: thenLoadBuilder[Q](
			"SpaceLocationsArchipelago",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsArchipelagoLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsArchipelago(ctx, exec, mods...)
			},
		),
		SpaceLocationsArkivum: thenLoadBuilder[Q](
			"SpaceLocationsArkivum",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsArkivumLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsArkivum(ctx, exec, mods...)
			},
		),
		SpaceLocationsDataverse: thenLoadBuilder[Q](
			"SpaceLocationsDataverse",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsDataverseLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsDataverse(ctx, exec, mods...)
			},
		),
		SpaceLocationsDspace: thenLoadBuilder[Q](
			"SpaceLocationsDspace",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsDspaceLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsDspace(ctx, exec, mods...)
			},
		),
		SpaceLocationsDspacerest: thenLoadBuilder[Q](
			"SpaceLocationsDspacerest",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsDspacerestLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsDspacerest(ctx, exec, mods...)
			},
		),
		SpaceLocationsDuracloud: thenLoadBuilder[Q](
			"SpaceLocationsDuracloud",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsDuracloudLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsDuracloud(ctx, exec, mods...)
			},
		),
		SpaceLocationsFedora: thenLoadBuilder[Q](
			"SpaceLocationsFedora",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsFedoraLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsFedora(ctx, exec, mods...)
			},
		),
		SpaceLocationsGPG: thenLoadBuilder[Q](
			"SpaceLocationsGPG",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsGPGLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsGPG(ctx, exec, mods...)
			},
		),
		SpaceLocationsLocalfilesystem: thenLoadBuilder[Q](
			"SpaceLocationsLocalfilesystem",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsLocalfilesystemLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsLocalfilesystem(ctx, exec, mods...)
			},
		),
		SpaceLocationsLocations: thenLoadBuilder[Q](
			"SpaceLocationsLocations",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsLocationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsLocations(ctx, exec, mods...)
			},
		),
		SpaceLocationsLockssomatic: thenLoadBuilder[Q](
			"SpaceLocationsLockssomatic",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsLockssomaticLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsLockssomatic(ctx, exec, mods...)
			},
		),
		SpaceLocationsNF: thenLoadBuilder[Q](
			"SpaceLocationsNF",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsNFLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsNF(ctx, exec, mods...)
			},
		),
		SpaceLocationsOfflinereplicastaging: thenLoadBuilder[Q](
			"SpaceLocationsOfflinereplicastaging",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsOfflinereplicastagingLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsOfflinereplicastaging(ctx, exec, mods...)
			},
		),
		SpaceLocationsPipelinelocalf: thenLoadBuilder[Q](
			"SpaceLocationsPipelinelocalf",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsPipelinelocalfLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsPipelinelocalf(ctx, exec, mods...)
			},
		),
		SpaceLocationsRclone: thenLoadBuilder[Q](
			"SpaceLocationsRclone",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsRcloneLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsRclone(ctx, exec, mods...)
			},
		),
		SpaceLocationsS3: thenLoadBuilder[Q](
			"SpaceLocationsS3",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsS3LoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsS3(ctx, exec, mods...)
			},
		),
		SpaceLocationsSwift: thenLoadBuilder[Q](
			"SpaceLocationsSwift",
			func(ctx context.Context, exec bob.Executor, retrieved SpaceLocationsSwiftLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
				return retrieved.LoadSpaceLocationsSwift(ctx, exec, mods...)
			},
		),
	}
}

// LoadSpaceLocationsArchipelago loads the locationsSpace's SpaceLocationsArchipelago into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsArchipelago(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsArchipelago = nil

	related, err := o.SpaceLocationsArchipelago(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsArchipelago = related
	return nil
}

// LoadSpaceLocationsArchipelago loads the locationsSpace's SpaceLocationsArchipelago into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsArchipelago(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsArchipelagos, err := os.SpaceLocationsArchipelago(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsArchipelagos {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsArchipelago = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsArkivum loads the locationsSpace's SpaceLocationsArkivum into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsArkivum(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsArkivum = nil

	related, err := o.SpaceLocationsArkivum(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsArkivum = related
	return nil
}

// LoadSpaceLocationsArkivum loads the locationsSpace's SpaceLocationsArkivum into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsArkivum(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsArkivums, err := os.SpaceLocationsArkivum(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsArkivums {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsArkivum = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsDataverse loads the locationsSpace's SpaceLocationsDataverse into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsDataverse(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsDataverse = nil

	related, err := o.SpaceLocationsDataverse(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsDataverse = related
	return nil
}

// LoadSpaceLocationsDataverse loads the locationsSpace's SpaceLocationsDataverse into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsDataverse(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsDataverses, err := os.SpaceLocationsDataverse(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsDataverses {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsDataverse = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsDspace loads the locationsSpace's SpaceLocationsDspace into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsDspace(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsDspace = nil

	related, err := o.SpaceLocationsDspace(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsDspace = related
	return nil
}

// LoadSpaceLocationsDspace loads the locationsSpace's SpaceLocationsDspace into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsDspace(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsDspaces, err := os.SpaceLocationsDspace(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsDspaces {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsDspace = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsDspacerest loads the locationsSpace's SpaceLocationsDspacerest into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsDspacerest(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsDspacerest = nil

	related, err := o.SpaceLocationsDspacerest(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsDspacerest = related
	return nil
}

// LoadSpaceLocationsDspacerest loads the locationsSpace's SpaceLocationsDspacerest into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsDspacerest(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsDspacerests, err := os.SpaceLocationsDspacerest(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsDspacerests {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsDspacerest = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsDuracloud loads the locationsSpace's SpaceLocationsDuracloud into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsDuracloud(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsDuracloud = nil

	related, err := o.SpaceLocationsDuracloud(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsDuracloud = related
	return nil
}

// LoadSpaceLocationsDuracloud loads the locationsSpace's SpaceLocationsDuracloud into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsDuracloud(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsDuraclouds, err := os.SpaceLocationsDuracloud(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsDuraclouds {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsDuracloud = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsFedora loads the locationsSpace's SpaceLocationsFedora into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsFedora(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsFedora = nil

	related, err := o.SpaceLocationsFedora(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsFedora = related
	return nil
}

// LoadSpaceLocationsFedora loads the locationsSpace's SpaceLocationsFedora into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsFedora(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsFedoras, err := os.SpaceLocationsFedora(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsFedoras {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsFedora = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsGPG loads the locationsSpace's SpaceLocationsGPG into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsGPG(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsGPG = nil

	related, err := o.SpaceLocationsGPG(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsGPG = related
	return nil
}

// LoadSpaceLocationsGPG loads the locationsSpace's SpaceLocationsGPG into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsGPG(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsGPGS, err := os.SpaceLocationsGPG(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsGPGS {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsGPG = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsLocalfilesystem loads the locationsSpace's SpaceLocationsLocalfilesystem into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsLocalfilesystem(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsLocalfilesystem = nil

	related, err := o.SpaceLocationsLocalfilesystem(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsLocalfilesystem = related
	return nil
}

// LoadSpaceLocationsLocalfilesystem loads the locationsSpace's SpaceLocationsLocalfilesystem into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsLocalfilesystem(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsLocalfilesystems, err := os.SpaceLocationsLocalfilesystem(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsLocalfilesystems {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsLocalfilesystem = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsLocations loads the locationsSpace's SpaceLocationsLocations into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsLocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsLocations = nil

	related, err := o.SpaceLocationsLocations(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, rel := range related {
		rel.R.SpaceLocationsSpace = o
	}

	o.R.SpaceLocationsLocations = related
	return nil
}

// LoadSpaceLocationsLocations loads the locationsSpace's SpaceLocationsLocations into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsLocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsLocations, err := os.SpaceLocationsLocations(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		o.R.SpaceLocationsLocations = nil
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsLocations {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsLocations = append(o.R.SpaceLocationsLocations, rel)
		}
	}

	return nil
}

// LoadSpaceLocationsLockssomatic loads the locationsSpace's SpaceLocationsLockssomatic into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsLockssomatic(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsLockssomatic = nil

	related, err := o.SpaceLocationsLockssomatic(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsLockssomatic = related
	return nil
}

// LoadSpaceLocationsLockssomatic loads the locationsSpace's SpaceLocationsLockssomatic into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsLockssomatic(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsLockssomatics, err := os.SpaceLocationsLockssomatic(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsLockssomatics {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsLockssomatic = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsNF loads the locationsSpace's SpaceLocationsNF into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsNF(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsNF = nil

	related, err := o.SpaceLocationsNF(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsNF = related
	return nil
}

// LoadSpaceLocationsNF loads the locationsSpace's SpaceLocationsNF into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsNF(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsNFS, err := os.SpaceLocationsNF(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsNFS {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsNF = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsOfflinereplicastaging loads the locationsSpace's SpaceLocationsOfflinereplicastaging into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsOfflinereplicastaging(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsOfflinereplicastaging = nil

	related, err := o.SpaceLocationsOfflinereplicastaging(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsOfflinereplicastaging = related
	return nil
}

// LoadSpaceLocationsOfflinereplicastaging loads the locationsSpace's SpaceLocationsOfflinereplicastaging into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsOfflinereplicastaging(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsOfflinereplicastagings, err := os.SpaceLocationsOfflinereplicastaging(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsOfflinereplicastagings {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsOfflinereplicastaging = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsPipelinelocalf loads the locationsSpace's SpaceLocationsPipelinelocalf into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsPipelinelocalf(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsPipelinelocalf = nil

	related, err := o.SpaceLocationsPipelinelocalf(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsPipelinelocalf = related
	return nil
}

// LoadSpaceLocationsPipelinelocalf loads the locationsSpace's SpaceLocationsPipelinelocalf into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsPipelinelocalf(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsPipelinelocalfs, err := os.SpaceLocationsPipelinelocalf(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsPipelinelocalfs {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsPipelinelocalf = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsRclone loads the locationsSpace's SpaceLocationsRclone into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsRclone(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsRclone = nil

	related, err := o.SpaceLocationsRclone(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsRclone = related
	return nil
}

// LoadSpaceLocationsRclone loads the locationsSpace's SpaceLocationsRclone into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsRclone(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsRclones, err := os.SpaceLocationsRclone(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsRclones {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsRclone = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsS3 loads the locationsSpace's SpaceLocationsS3 into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsS3(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsS3 = nil

	related, err := o.SpaceLocationsS3(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsS3 = related
	return nil
}

// LoadSpaceLocationsS3 loads the locationsSpace's SpaceLocationsS3 into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsS3(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsS3S, err := os.SpaceLocationsS3(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsS3S {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsS3 = rel
			break
		}
	}

	return nil
}

// LoadSpaceLocationsSwift loads the locationsSpace's SpaceLocationsSwift into the .R struct
func (o *LocationsSpace) LoadSpaceLocationsSwift(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if o == nil {
		return nil
	}

	// Reset the relationship
	o.R.SpaceLocationsSwift = nil

	related, err := o.SpaceLocationsSwift(mods...).One(ctx, exec)
	if err != nil {
		return err
	}

	related.R.SpaceLocationsSpace = o

	o.R.SpaceLocationsSwift = related
	return nil
}

// LoadSpaceLocationsSwift loads the locationsSpace's SpaceLocationsSwift into the .R struct
func (os LocationsSpaceSlice) LoadSpaceLocationsSwift(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
	if len(os) == 0 {
		return nil
	}

	locationsSwifts, err := os.SpaceLocationsSwift(mods...).All(ctx, exec)
	if err != nil {
		return err
	}

	for _, o := range os {
		if o == nil {
			continue
		}

		for _, rel := range locationsSwifts {

			if !(o.UUID == rel.SpaceID) {
				continue
			}

			rel.R.SpaceLocationsSpace = o

			o.R.SpaceLocationsSwift = rel
			break
		}
	}

	return nil
}

type locationsSpaceJoins[Q dialect.Joinable] struct {
	typ                                 string
	SpaceLocationsArchipelago           modAs[Q, locationsArchipelagoColumns]
	SpaceLocationsArkivum               modAs[Q, locationsArkivumColumns]
	SpaceLocationsDataverse             modAs[Q, locationsDataverseColumns]
	SpaceLocationsDspace                modAs[Q, locationsDspaceColumns]
	SpaceLocationsDspacerest            modAs[Q, locationsDspacerestColumns]
	SpaceLocationsDuracloud             modAs[Q, locationsDuracloudColumns]
	SpaceLocationsFedora                modAs[Q, locationsFedoraColumns]
	SpaceLocationsGPG                   modAs[Q, locationsGPGColumns]
	SpaceLocationsLocalfilesystem       modAs[Q, locationsLocalfilesystemColumns]
	SpaceLocationsLocations             modAs[Q, locationsLocationColumns]
	SpaceLocationsLockssomatic          modAs[Q, locationsLockssomaticColumns]
	SpaceLocationsNF                    modAs[Q, locationsNFColumns]
	SpaceLocationsOfflinereplicastaging modAs[Q, locationsOfflinereplicastagingColumns]
	SpaceLocationsPipelinelocalf        modAs[Q, locationsPipelinelocalfColumns]
	SpaceLocationsRclone                modAs[Q, locationsRcloneColumns]
	SpaceLocationsS3                    modAs[Q, locationsS3Columns]
	SpaceLocationsSwift                 modAs[Q, locationsSwiftColumns]
}

func (j locationsSpaceJoins[Q]) aliasedAs(alias string) locationsSpaceJoins[Q] {
	return buildLocationsSpaceJoins[Q](buildLocationsSpaceColumns(alias), j.typ)
}

func buildLocationsSpaceJoins[Q dialect.Joinable](cols locationsSpaceColumns, typ string) locationsSpaceJoins[Q] {
	return locationsSpaceJoins[Q]{
		typ: typ,
		SpaceLocationsArchipelago: modAs[Q, locationsArchipelagoColumns]{
			c: LocationsArchipelagos.Columns,
			f: func(to locationsArchipelagoColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsArchipelagos.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsArkivum: modAs[Q, locationsArkivumColumns]{
			c: LocationsArkivums.Columns,
			f: func(to locationsArkivumColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsArkivums.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsDataverse: modAs[Q, locationsDataverseColumns]{
			c: LocationsDataverses.Columns,
			f: func(to locationsDataverseColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsDataverses.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsDspace: modAs[Q, locationsDspaceColumns]{
			c: LocationsDspaces.Columns,
			f: func(to locationsDspaceColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsDspaces.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsDspacerest: modAs[Q, locationsDspacerestColumns]{
			c: LocationsDspacerests.Columns,
			f: func(to locationsDspacerestColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsDspacerests.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsDuracloud: modAs[Q, locationsDuracloudColumns]{
			c: LocationsDuraclouds.Columns,
			f: func(to locationsDuracloudColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsDuraclouds.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsFedora: modAs[Q, locationsFedoraColumns]{
			c: LocationsFedoras.Columns,
			f: func(to locationsFedoraColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsFedoras.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsGPG: modAs[Q, locationsGPGColumns]{
			c: LocationsGPGS.Columns,
			f: func(to locationsGPGColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsGPGS.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsLocalfilesystem: modAs[Q, locationsLocalfilesystemColumns]{
			c: LocationsLocalfilesystems.Columns,
			f: func(to locationsLocalfilesystemColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsLocalfilesystems.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsLocations: modAs[Q, locationsLocationColumns]{
			c: LocationsLocations.Columns,
			f: func(to locationsLocationColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsLocations.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsLockssomatic: modAs[Q, locationsLockssomaticColumns]{
			c: LocationsLockssomatics.Columns,
			f: func(to locationsLockssomaticColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsLockssomatics.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsNF: modAs[Q, locationsNFColumns]{
			c: LocationsNFS.Columns,
			f: func(to locationsNFColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsNFS.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsOfflinereplicastaging: modAs[Q, locationsOfflinereplicastagingColumns]{
			c: LocationsOfflinereplicastagings.Columns,
			f: func(to locationsOfflinereplicastagingColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsOfflinereplicastagings.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsPipelinelocalf: modAs[Q, locationsPipelinelocalfColumns]{
			c: LocationsPipelinelocalfs.Columns,
			f: func(to locationsPipelinelocalfColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsPipelinelocalfs.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsRclone: modAs[Q, locationsRcloneColumns]{
			c: LocationsRclones.Columns,
			f: func(to locationsRcloneColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsRclones.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsS3: modAs[Q, locationsS3Columns]{
			c: LocationsS3S.Columns,
			f: func(to locationsS3Columns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsS3S.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
		SpaceLocationsSwift: modAs[Q, locationsSwiftColumns]{
			c: LocationsSwifts.Columns,
			f: func(to locationsSwiftColumns) bob.Mod[Q] {
				mods := make(mods.QueryMods[Q], 0, 1)

				{
					mods = append(mods, dialect.Join[Q](typ, LocationsSwifts.Name().As(to.Alias())).On(
						to.SpaceID.EQ(cols.UUID),
					))
				}

				return mods
			},
		},
	}
}
