nidus-sync/db/factory/spatial_ref_sys.bob.go
Eli Ribble a68b8781e7
Add ability to make LLM agent forget the conversation history
This is extremely useful for testing.

In order to do this I needed to actually deploy the migration to a bob
fork so I could start to add support for behaviors I really want.
Specifically the ability to search for ids in a slice.
2026-01-27 18:44:02 +00:00

505 lines
14 KiB
Go

// 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"
"testing"
"github.com/Gleipnir-Technology/bob"
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/jaswdr/faker/v2"
)
type SpatialRefSyMod interface {
Apply(context.Context, *SpatialRefSyTemplate)
}
type SpatialRefSyModFunc func(context.Context, *SpatialRefSyTemplate)
func (f SpatialRefSyModFunc) Apply(ctx context.Context, n *SpatialRefSyTemplate) {
f(ctx, n)
}
type SpatialRefSyModSlice []SpatialRefSyMod
func (mods SpatialRefSyModSlice) Apply(ctx context.Context, n *SpatialRefSyTemplate) {
for _, f := range mods {
f.Apply(ctx, n)
}
}
// SpatialRefSyTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type SpatialRefSyTemplate struct {
Srid func() int32
AuthName func() null.Val[string]
AuthSrid func() null.Val[int32]
Srtext func() null.Val[string]
Proj4text func() null.Val[string]
f *Factory
alreadyPersisted bool
}
// Apply mods to the SpatialRefSyTemplate
func (o *SpatialRefSyTemplate) Apply(ctx context.Context, mods ...SpatialRefSyMod) {
for _, mod := range mods {
mod.Apply(ctx, o)
}
}
// setModelRels creates and sets the relationships on *models.SpatialRefSy
// according to the relationships in the template. Nothing is inserted into the db
func (t SpatialRefSyTemplate) setModelRels(o *models.SpatialRefSy) {}
// BuildSetter returns an *models.SpatialRefSySetter
// this does nothing with the relationship templates
func (o SpatialRefSyTemplate) BuildSetter() *models.SpatialRefSySetter {
m := &models.SpatialRefSySetter{}
if o.Srid != nil {
val := o.Srid()
m.Srid = omit.From(val)
}
if o.AuthName != nil {
val := o.AuthName()
m.AuthName = omitnull.FromNull(val)
}
if o.AuthSrid != nil {
val := o.AuthSrid()
m.AuthSrid = omitnull.FromNull(val)
}
if o.Srtext != nil {
val := o.Srtext()
m.Srtext = omitnull.FromNull(val)
}
if o.Proj4text != nil {
val := o.Proj4text()
m.Proj4text = omitnull.FromNull(val)
}
return m
}
// BuildManySetter returns an []*models.SpatialRefSySetter
// this does nothing with the relationship templates
func (o SpatialRefSyTemplate) BuildManySetter(number int) []*models.SpatialRefSySetter {
m := make([]*models.SpatialRefSySetter, number)
for i := range m {
m[i] = o.BuildSetter()
}
return m
}
// Build returns an *models.SpatialRefSy
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use SpatialRefSyTemplate.Create
func (o SpatialRefSyTemplate) Build() *models.SpatialRefSy {
m := &models.SpatialRefSy{}
if o.Srid != nil {
m.Srid = o.Srid()
}
if o.AuthName != nil {
m.AuthName = o.AuthName()
}
if o.AuthSrid != nil {
m.AuthSrid = o.AuthSrid()
}
if o.Srtext != nil {
m.Srtext = o.Srtext()
}
if o.Proj4text != nil {
m.Proj4text = o.Proj4text()
}
o.setModelRels(m)
return m
}
// BuildMany returns an models.SpatialRefSySlice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use SpatialRefSyTemplate.CreateMany
func (o SpatialRefSyTemplate) BuildMany(number int) models.SpatialRefSySlice {
m := make(models.SpatialRefSySlice, number)
for i := range m {
m[i] = o.Build()
}
return m
}
func ensureCreatableSpatialRefSy(m *models.SpatialRefSySetter) {
if !(m.Srid.IsValue()) {
val := random_int32(nil)
m.Srid = omit.From(val)
}
}
// insertOptRels creates and inserts any optional the relationships on *models.SpatialRefSy
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *SpatialRefSyTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.SpatialRefSy) error {
var err error
return err
}
// Create builds a spatialRefSy and inserts it into the database
// Relations objects are also inserted and placed in the .R field
func (o *SpatialRefSyTemplate) Create(ctx context.Context, exec bob.Executor) (*models.SpatialRefSy, error) {
var err error
opt := o.BuildSetter()
ensureCreatableSpatialRefSy(opt)
m, err := models.SpatialRefSys.Insert(opt).One(ctx, exec)
if err != nil {
return nil, err
}
if err := o.insertOptRels(ctx, exec, m); err != nil {
return nil, err
}
return m, err
}
// MustCreate builds a spatialRefSy and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *SpatialRefSyTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.SpatialRefSy {
m, err := o.Create(ctx, exec)
if err != nil {
panic(err)
}
return m
}
// CreateOrFail builds a spatialRefSy 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 *SpatialRefSyTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.SpatialRefSy {
tb.Helper()
m, err := o.Create(ctx, exec)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// CreateMany builds multiple spatialRefSys and inserts them into the database
// Relations objects are also inserted and placed in the .R field
func (o SpatialRefSyTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.SpatialRefSySlice, error) {
var err error
m := make(models.SpatialRefSySlice, number)
for i := range m {
m[i], err = o.Create(ctx, exec)
if err != nil {
return nil, err
}
}
return m, nil
}
// MustCreateMany builds multiple spatialRefSys and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o SpatialRefSyTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.SpatialRefSySlice {
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
panic(err)
}
return m
}
// CreateManyOrFail builds multiple spatialRefSys 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 SpatialRefSyTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.SpatialRefSySlice {
tb.Helper()
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// SpatialRefSy has methods that act as mods for the SpatialRefSyTemplate
var SpatialRefSyMods spatialRefSyMods
type spatialRefSyMods struct{}
func (m spatialRefSyMods) RandomizeAllColumns(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModSlice{
SpatialRefSyMods.RandomSrid(f),
SpatialRefSyMods.RandomAuthName(f),
SpatialRefSyMods.RandomAuthSrid(f),
SpatialRefSyMods.RandomSrtext(f),
SpatialRefSyMods.RandomProj4text(f),
}
}
// Set the model columns to this value
func (m spatialRefSyMods) Srid(val int32) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srid = func() int32 { return val }
})
}
// Set the Column from the function
func (m spatialRefSyMods) SridFunc(f func() int32) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srid = f
})
}
// Clear any values for the column
func (m spatialRefSyMods) UnsetSrid() SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srid = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m spatialRefSyMods) RandomSrid(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srid = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m spatialRefSyMods) AuthName(val null.Val[string]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthName = func() null.Val[string] { return val }
})
}
// Set the Column from the function
func (m spatialRefSyMods) AuthNameFunc(f func() null.Val[string]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthName = f
})
}
// Clear any values for the column
func (m spatialRefSyMods) UnsetAuthName() SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthName = 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 spatialRefSyMods) RandomAuthName(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthName = func() null.Val[string] {
if f == nil {
f = &defaultFaker
}
val := random_string(f, "256")
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 spatialRefSyMods) RandomAuthNameNotNull(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthName = func() null.Val[string] {
if f == nil {
f = &defaultFaker
}
val := random_string(f, "256")
return null.From(val)
}
})
}
// Set the model columns to this value
func (m spatialRefSyMods) AuthSrid(val null.Val[int32]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthSrid = func() null.Val[int32] { return val }
})
}
// Set the Column from the function
func (m spatialRefSyMods) AuthSridFunc(f func() null.Val[int32]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthSrid = f
})
}
// Clear any values for the column
func (m spatialRefSyMods) UnsetAuthSrid() SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthSrid = 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 spatialRefSyMods) RandomAuthSrid(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthSrid = 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 spatialRefSyMods) RandomAuthSridNotNull(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.AuthSrid = 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 spatialRefSyMods) Srtext(val null.Val[string]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srtext = func() null.Val[string] { return val }
})
}
// Set the Column from the function
func (m spatialRefSyMods) SrtextFunc(f func() null.Val[string]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srtext = f
})
}
// Clear any values for the column
func (m spatialRefSyMods) UnsetSrtext() SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srtext = 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 spatialRefSyMods) RandomSrtext(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srtext = func() null.Val[string] {
if f == nil {
f = &defaultFaker
}
val := random_string(f, "2048")
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 spatialRefSyMods) RandomSrtextNotNull(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Srtext = func() null.Val[string] {
if f == nil {
f = &defaultFaker
}
val := random_string(f, "2048")
return null.From(val)
}
})
}
// Set the model columns to this value
func (m spatialRefSyMods) Proj4text(val null.Val[string]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Proj4text = func() null.Val[string] { return val }
})
}
// Set the Column from the function
func (m spatialRefSyMods) Proj4textFunc(f func() null.Val[string]) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Proj4text = f
})
}
// Clear any values for the column
func (m spatialRefSyMods) UnsetProj4text() SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Proj4text = 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 spatialRefSyMods) RandomProj4text(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Proj4text = func() null.Val[string] {
if f == nil {
f = &defaultFaker
}
val := random_string(f, "2048")
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 spatialRefSyMods) RandomProj4textNotNull(f *faker.Faker) SpatialRefSyMod {
return SpatialRefSyModFunc(func(_ context.Context, o *SpatialRefSyTemplate) {
o.Proj4text = func() null.Val[string] {
if f == nil {
f = &defaultFaker
}
val := random_string(f, "2048")
return null.From(val)
}
})
}
func (m spatialRefSyMods) WithParentsCascading() SpatialRefSyMod {
return SpatialRefSyModFunc(func(ctx context.Context, o *SpatialRefSyTemplate) {
if isDone, _ := spatialRefSyWithParentsCascadingCtx.Value(ctx); isDone {
return
}
ctx = spatialRefSyWithParentsCascadingCtx.WithValue(ctx, true)
})
}