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

package factory

import (
	"context"
	"encoding/json"
	"testing"
	"time"

	"github.com/Gleipnir-Technology/bob"
	"github.com/Gleipnir-Technology/bob/types"
	models "github.com/Gleipnir-Technology/nidus-sync/db/models"
	"github.com/aarondl/opt/null"
	"github.com/aarondl/opt/omit"
	"github.com/aarondl/opt/omitnull"
	"github.com/google/uuid"
	"github.com/jaswdr/faker/v2"
)

type FieldseekerZoneMod interface {
	Apply(context.Context, *FieldseekerZoneTemplate)
}

type FieldseekerZoneModFunc func(context.Context, *FieldseekerZoneTemplate)

func (f FieldseekerZoneModFunc) Apply(ctx context.Context, n *FieldseekerZoneTemplate) {
	f(ctx, n)
}

type FieldseekerZoneModSlice []FieldseekerZoneMod

func (mods FieldseekerZoneModSlice) Apply(ctx context.Context, n *FieldseekerZoneTemplate) {
	for _, f := range mods {
		f.Apply(ctx, n)
	}
}

// FieldseekerZoneTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FieldseekerZoneTemplate struct {
	Objectid       func() int64
	Name           func() null.Val[string]
	Globalid       func() uuid.UUID
	CreatedUser    func() null.Val[string]
	CreatedDate    func() null.Val[time.Time]
	LastEditedUser func() null.Val[string]
	LastEditedDate func() null.Val[time.Time]
	Active         func() null.Val[int32]
	Creationdate   func() null.Val[time.Time]
	Creator        func() null.Val[string]
	Editdate       func() null.Val[time.Time]
	Editor         func() null.Val[string]
	ShapeArea      func() null.Val[float64]
	ShapeLength    func() null.Val[float64]
	Geometry       func() types.JSON[json.RawMessage]
	Geospatial     func() null.Val[string]
	Version        func() int32
	OrganizationID func() int32

	r fieldseekerZoneR
	f *Factory

	alreadyPersisted bool
}

type fieldseekerZoneR struct {
	Organization *fieldseekerZoneROrganizationR
}

type fieldseekerZoneROrganizationR struct {
	o *OrganizationTemplate
}

// Apply mods to the FieldseekerZoneTemplate
func (o *FieldseekerZoneTemplate) Apply(ctx context.Context, mods ...FieldseekerZoneMod) {
	for _, mod := range mods {
		mod.Apply(ctx, o)
	}
}

// setModelRels creates and sets the relationships on *models.FieldseekerZone
// according to the relationships in the template. Nothing is inserted into the db
func (t FieldseekerZoneTemplate) setModelRels(o *models.FieldseekerZone) {
	if t.r.Organization != nil {
		rel := t.r.Organization.o.Build()
		rel.R.Zones = append(rel.R.Zones, o)
		o.OrganizationID = rel.ID // h2
		o.R.Organization = rel
	}
}

// BuildSetter returns an *models.FieldseekerZoneSetter
// this does nothing with the relationship templates
func (o FieldseekerZoneTemplate) BuildSetter() *models.FieldseekerZoneSetter {
	m := &models.FieldseekerZoneSetter{}

	if o.Objectid != nil {
		val := o.Objectid()
		m.Objectid = omit.From(val)
	}
	if o.Name != nil {
		val := o.Name()
		m.Name = omitnull.FromNull(val)
	}
	if o.Globalid != nil {
		val := o.Globalid()
		m.Globalid = omit.From(val)
	}
	if o.CreatedUser != nil {
		val := o.CreatedUser()
		m.CreatedUser = omitnull.FromNull(val)
	}
	if o.CreatedDate != nil {
		val := o.CreatedDate()
		m.CreatedDate = omitnull.FromNull(val)
	}
	if o.LastEditedUser != nil {
		val := o.LastEditedUser()
		m.LastEditedUser = omitnull.FromNull(val)
	}
	if o.LastEditedDate != nil {
		val := o.LastEditedDate()
		m.LastEditedDate = omitnull.FromNull(val)
	}
	if o.Active != nil {
		val := o.Active()
		m.Active = omitnull.FromNull(val)
	}
	if o.Creationdate != nil {
		val := o.Creationdate()
		m.Creationdate = omitnull.FromNull(val)
	}
	if o.Creator != nil {
		val := o.Creator()
		m.Creator = omitnull.FromNull(val)
	}
	if o.Editdate != nil {
		val := o.Editdate()
		m.Editdate = omitnull.FromNull(val)
	}
	if o.Editor != nil {
		val := o.Editor()
		m.Editor = omitnull.FromNull(val)
	}
	if o.ShapeArea != nil {
		val := o.ShapeArea()
		m.ShapeArea = omitnull.FromNull(val)
	}
	if o.ShapeLength != nil {
		val := o.ShapeLength()
		m.ShapeLength = omitnull.FromNull(val)
	}
	if o.Geometry != nil {
		val := o.Geometry()
		m.Geometry = omit.From(val)
	}
	if o.Geospatial != nil {
		val := o.Geospatial()
		m.Geospatial = omitnull.FromNull(val)
	}
	if o.Version != nil {
		val := o.Version()
		m.Version = omit.From(val)
	}
	if o.OrganizationID != nil {
		val := o.OrganizationID()
		m.OrganizationID = omit.From(val)
	}

	return m
}

// BuildManySetter returns an []*models.FieldseekerZoneSetter
// this does nothing with the relationship templates
func (o FieldseekerZoneTemplate) BuildManySetter(number int) []*models.FieldseekerZoneSetter {
	m := make([]*models.FieldseekerZoneSetter, number)

	for i := range m {
		m[i] = o.BuildSetter()
	}

	return m
}

// Build returns an *models.FieldseekerZone
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use FieldseekerZoneTemplate.Create
func (o FieldseekerZoneTemplate) Build() *models.FieldseekerZone {
	m := &models.FieldseekerZone{}

	if o.Objectid != nil {
		m.Objectid = o.Objectid()
	}
	if o.Name != nil {
		m.Name = o.Name()
	}
	if o.Globalid != nil {
		m.Globalid = o.Globalid()
	}
	if o.CreatedUser != nil {
		m.CreatedUser = o.CreatedUser()
	}
	if o.CreatedDate != nil {
		m.CreatedDate = o.CreatedDate()
	}
	if o.LastEditedUser != nil {
		m.LastEditedUser = o.LastEditedUser()
	}
	if o.LastEditedDate != nil {
		m.LastEditedDate = o.LastEditedDate()
	}
	if o.Active != nil {
		m.Active = o.Active()
	}
	if o.Creationdate != nil {
		m.Creationdate = o.Creationdate()
	}
	if o.Creator != nil {
		m.Creator = o.Creator()
	}
	if o.Editdate != nil {
		m.Editdate = o.Editdate()
	}
	if o.Editor != nil {
		m.Editor = o.Editor()
	}
	if o.ShapeArea != nil {
		m.ShapeArea = o.ShapeArea()
	}
	if o.ShapeLength != nil {
		m.ShapeLength = o.ShapeLength()
	}
	if o.Geometry != nil {
		m.Geometry = o.Geometry()
	}
	if o.Geospatial != nil {
		m.Geospatial = o.Geospatial()
	}
	if o.Version != nil {
		m.Version = o.Version()
	}
	if o.OrganizationID != nil {
		m.OrganizationID = o.OrganizationID()
	}

	o.setModelRels(m)

	return m
}

// BuildMany returns an models.FieldseekerZoneSlice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use FieldseekerZoneTemplate.CreateMany
func (o FieldseekerZoneTemplate) BuildMany(number int) models.FieldseekerZoneSlice {
	m := make(models.FieldseekerZoneSlice, number)

	for i := range m {
		m[i] = o.Build()
	}

	return m
}

func ensureCreatableFieldseekerZone(m *models.FieldseekerZoneSetter) {
	if !(m.Objectid.IsValue()) {
		val := random_int64(nil)
		m.Objectid = omit.From(val)
	}
	if !(m.Globalid.IsValue()) {
		val := random_uuid_UUID(nil)
		m.Globalid = omit.From(val)
	}
	if !(m.Geometry.IsValue()) {
		val := random_types_JSON_json_RawMessage_(nil)
		m.Geometry = omit.From(val)
	}
	if !(m.OrganizationID.IsValue()) {
		val := random_int32(nil)
		m.OrganizationID = omit.From(val)
	}
}

// insertOptRels creates and inserts any optional the relationships on *models.FieldseekerZone
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *FieldseekerZoneTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FieldseekerZone) error {
	var err error

	return err
}

// Create builds a fieldseekerZone and inserts it into the database
// Relations objects are also inserted and placed in the .R field
func (o *FieldseekerZoneTemplate) Create(ctx context.Context, exec bob.Executor) (*models.FieldseekerZone, error) {
	var err error
	opt := o.BuildSetter()
	ensureCreatableFieldseekerZone(opt)

	if o.r.Organization == nil {
		FieldseekerZoneMods.WithNewOrganization().Apply(ctx, o)
	}

	var rel0 *models.Organization

	if o.r.Organization.o.alreadyPersisted {
		rel0 = o.r.Organization.o.Build()
	} else {
		rel0, err = o.r.Organization.o.Create(ctx, exec)
		if err != nil {
			return nil, err
		}
	}

	opt.OrganizationID = omit.From(rel0.ID)

	m, err := models.FieldseekerZones.Insert(opt).One(ctx, exec)
	if err != nil {
		return nil, err
	}

	m.R.Organization = rel0

	if err := o.insertOptRels(ctx, exec, m); err != nil {
		return nil, err
	}
	return m, err
}

// MustCreate builds a fieldseekerZone and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *FieldseekerZoneTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.FieldseekerZone {
	m, err := o.Create(ctx, exec)
	if err != nil {
		panic(err)
	}
	return m
}

// CreateOrFail builds a fieldseekerZone and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
func (o *FieldseekerZoneTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.FieldseekerZone {
	tb.Helper()
	m, err := o.Create(ctx, exec)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

// CreateMany builds multiple fieldseekerZones and inserts them into the database
// Relations objects are also inserted and placed in the .R field
func (o FieldseekerZoneTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.FieldseekerZoneSlice, error) {
	var err error
	m := make(models.FieldseekerZoneSlice, number)

	for i := range m {
		m[i], err = o.Create(ctx, exec)
		if err != nil {
			return nil, err
		}
	}

	return m, nil
}

// MustCreateMany builds multiple fieldseekerZones and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o FieldseekerZoneTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.FieldseekerZoneSlice {
	m, err := o.CreateMany(ctx, exec, number)
	if err != nil {
		panic(err)
	}
	return m
}

// CreateManyOrFail builds multiple fieldseekerZones and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
func (o FieldseekerZoneTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.FieldseekerZoneSlice {
	tb.Helper()
	m, err := o.CreateMany(ctx, exec, number)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

// FieldseekerZone has methods that act as mods for the FieldseekerZoneTemplate
var FieldseekerZoneMods fieldseekerZoneMods

type fieldseekerZoneMods struct{}

func (m fieldseekerZoneMods) RandomizeAllColumns(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModSlice{
		FieldseekerZoneMods.RandomObjectid(f),
		FieldseekerZoneMods.RandomName(f),
		FieldseekerZoneMods.RandomGlobalid(f),
		FieldseekerZoneMods.RandomCreatedUser(f),
		FieldseekerZoneMods.RandomCreatedDate(f),
		FieldseekerZoneMods.RandomLastEditedUser(f),
		FieldseekerZoneMods.RandomLastEditedDate(f),
		FieldseekerZoneMods.RandomActive(f),
		FieldseekerZoneMods.RandomCreationdate(f),
		FieldseekerZoneMods.RandomCreator(f),
		FieldseekerZoneMods.RandomEditdate(f),
		FieldseekerZoneMods.RandomEditor(f),
		FieldseekerZoneMods.RandomShapeArea(f),
		FieldseekerZoneMods.RandomShapeLength(f),
		FieldseekerZoneMods.RandomGeometry(f),
		FieldseekerZoneMods.RandomGeospatial(f),
		FieldseekerZoneMods.RandomVersion(f),
		FieldseekerZoneMods.RandomOrganizationID(f),
	}
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Objectid(val int64) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Objectid = func() int64 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) ObjectidFunc(f func() int64) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Objectid = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetObjectid() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Objectid = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZoneMods) RandomObjectid(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Objectid = func() int64 {
			return random_int64(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Name(val null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Name = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) NameFunc(f func() null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Name = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetName() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Name = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomName(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Name = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "50")
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomNameNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Name = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "50")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Globalid(val uuid.UUID) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Globalid = func() uuid.UUID { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) GlobalidFunc(f func() uuid.UUID) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Globalid = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetGlobalid() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Globalid = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZoneMods) RandomGlobalid(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Globalid = func() uuid.UUID {
			return random_uuid_UUID(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) CreatedUser(val null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedUser = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) CreatedUserFunc(f func() null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedUser = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetCreatedUser() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedUser = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomCreatedUser(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomCreatedUserNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) CreatedDate(val null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedDate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) CreatedDateFunc(f func() null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedDate = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetCreatedDate() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedDate = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomCreatedDate(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedDate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomCreatedDateNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.CreatedDate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) LastEditedUser(val null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedUser = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) LastEditedUserFunc(f func() null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedUser = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetLastEditedUser() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedUser = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomLastEditedUser(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomLastEditedUserNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) LastEditedDate(val null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedDate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) LastEditedDateFunc(f func() null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedDate = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetLastEditedDate() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedDate = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomLastEditedDate(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedDate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomLastEditedDateNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.LastEditedDate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Active(val null.Val[int32]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Active = func() null.Val[int32] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) ActiveFunc(f func() null.Val[int32]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Active = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetActive() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Active = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomActive(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Active = func() null.Val[int32] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_int32(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomActiveNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Active = func() null.Val[int32] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_int32(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Creationdate(val null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creationdate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) CreationdateFunc(f func() null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creationdate = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetCreationdate() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creationdate = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomCreationdate(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creationdate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomCreationdateNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creationdate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Creator(val null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creator = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) CreatorFunc(f func() null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creator = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetCreator() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creator = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomCreator(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creator = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomCreatorNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Creator = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Editdate(val null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editdate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) EditdateFunc(f func() null.Val[time.Time]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editdate = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetEditdate() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editdate = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomEditdate(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editdate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomEditdateNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editdate = func() null.Val[time.Time] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_time_Time(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Editor(val null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editor = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) EditorFunc(f func() null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editor = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetEditor() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editor = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomEditor(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editor = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomEditorNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Editor = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) ShapeArea(val null.Val[float64]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeArea = func() null.Val[float64] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) ShapeAreaFunc(f func() null.Val[float64]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeArea = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetShapeArea() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeArea = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomShapeArea(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeArea = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomShapeAreaNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeArea = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) ShapeLength(val null.Val[float64]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeLength = func() null.Val[float64] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) ShapeLengthFunc(f func() null.Val[float64]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeLength = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetShapeLength() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeLength = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomShapeLength(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeLength = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomShapeLengthNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.ShapeLength = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Geometry(val types.JSON[json.RawMessage]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geometry = func() types.JSON[json.RawMessage] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) GeometryFunc(f func() types.JSON[json.RawMessage]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geometry = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetGeometry() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geometry = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZoneMods) RandomGeometry(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geometry = func() types.JSON[json.RawMessage] {
			return random_types_JSON_json_RawMessage_(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Geospatial(val null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geospatial = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) GeospatialFunc(f func() null.Val[string]) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geospatial = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetGeospatial() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geospatial = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m fieldseekerZoneMods) RandomGeospatial(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geospatial = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m fieldseekerZoneMods) RandomGeospatialNotNull(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Geospatial = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) Version(val int32) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Version = func() int32 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) VersionFunc(f func() int32) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Version = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetVersion() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Version = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZoneMods) RandomVersion(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.Version = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZoneMods) OrganizationID(val int32) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.OrganizationID = func() int32 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZoneMods) OrganizationIDFunc(f func() int32) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.OrganizationID = f
	})
}

// Clear any values for the column
func (m fieldseekerZoneMods) UnsetOrganizationID() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.OrganizationID = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZoneMods) RandomOrganizationID(f *faker.Faker) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(_ context.Context, o *FieldseekerZoneTemplate) {
		o.OrganizationID = func() int32 {
			return random_int32(f)
		}
	})
}

func (m fieldseekerZoneMods) WithParentsCascading() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(ctx context.Context, o *FieldseekerZoneTemplate) {
		if isDone, _ := fieldseekerZoneWithParentsCascadingCtx.Value(ctx); isDone {
			return
		}
		ctx = fieldseekerZoneWithParentsCascadingCtx.WithValue(ctx, true)
		{

			related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading())
			m.WithOrganization(related).Apply(ctx, o)
		}
	})
}

func (m fieldseekerZoneMods) WithOrganization(rel *OrganizationTemplate) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(ctx context.Context, o *FieldseekerZoneTemplate) {
		o.r.Organization = &fieldseekerZoneROrganizationR{
			o: rel,
		}
	})
}

func (m fieldseekerZoneMods) WithNewOrganization(mods ...OrganizationMod) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(ctx context.Context, o *FieldseekerZoneTemplate) {
		related := o.f.NewOrganizationWithContext(ctx, mods...)

		m.WithOrganization(related).Apply(ctx, o)
	})
}

func (m fieldseekerZoneMods) WithExistingOrganization(em *models.Organization) FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(ctx context.Context, o *FieldseekerZoneTemplate) {
		o.r.Organization = &fieldseekerZoneROrganizationR{
			o: o.f.FromExistingOrganization(em),
		}
	})
}

func (m fieldseekerZoneMods) WithoutOrganization() FieldseekerZoneMod {
	return FieldseekerZoneModFunc(func(ctx context.Context, o *FieldseekerZoneTemplate) {
		o.r.Organization = nil
	})
}
