500 lines
15 KiB
Go
500 lines
15 KiB
Go
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
package factory
|
|
|
|
import (
|
|
"context"
|
|
|
|
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
|
"github.com/aarondl/opt/null"
|
|
"github.com/jaswdr/faker/v2"
|
|
)
|
|
|
|
type GeographyColumnMod interface {
|
|
Apply(context.Context, *GeographyColumnTemplate)
|
|
}
|
|
|
|
type GeographyColumnModFunc func(context.Context, *GeographyColumnTemplate)
|
|
|
|
func (f GeographyColumnModFunc) Apply(ctx context.Context, n *GeographyColumnTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type GeographyColumnModSlice []GeographyColumnMod
|
|
|
|
func (mods GeographyColumnModSlice) Apply(ctx context.Context, n *GeographyColumnTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// GeographyColumnTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type GeographyColumnTemplate struct {
|
|
FTableCatalog func() null.Val[string]
|
|
FTableSchema func() null.Val[string]
|
|
FTableName func() null.Val[string]
|
|
FGeographyColumn func() null.Val[string]
|
|
CoordDimension func() null.Val[int32]
|
|
Srid func() null.Val[int32]
|
|
Type func() null.Val[string]
|
|
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
// Apply mods to the GeographyColumnTemplate
|
|
func (o *GeographyColumnTemplate) Apply(ctx context.Context, mods ...GeographyColumnMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.GeographyColumn
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t GeographyColumnTemplate) setModelRels(o *models.GeographyColumn) {}
|
|
|
|
// Build returns an *models.GeographyColumn
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use GeographyColumnTemplate.Create
|
|
func (o GeographyColumnTemplate) Build() *models.GeographyColumn {
|
|
m := &models.GeographyColumn{}
|
|
|
|
if o.FTableCatalog != nil {
|
|
m.FTableCatalog = o.FTableCatalog()
|
|
}
|
|
if o.FTableSchema != nil {
|
|
m.FTableSchema = o.FTableSchema()
|
|
}
|
|
if o.FTableName != nil {
|
|
m.FTableName = o.FTableName()
|
|
}
|
|
if o.FGeographyColumn != nil {
|
|
m.FGeographyColumn = o.FGeographyColumn()
|
|
}
|
|
if o.CoordDimension != nil {
|
|
m.CoordDimension = o.CoordDimension()
|
|
}
|
|
if o.Srid != nil {
|
|
m.Srid = o.Srid()
|
|
}
|
|
if o.Type != nil {
|
|
m.Type = o.Type()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.GeographyColumnSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use GeographyColumnTemplate.CreateMany
|
|
func (o GeographyColumnTemplate) BuildMany(number int) models.GeographyColumnSlice {
|
|
m := make(models.GeographyColumnSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// GeographyColumn has methods that act as mods for the GeographyColumnTemplate
|
|
var GeographyColumnMods geographyColumnMods
|
|
|
|
type geographyColumnMods struct{}
|
|
|
|
func (m geographyColumnMods) RandomizeAllColumns(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModSlice{
|
|
GeographyColumnMods.RandomFTableCatalog(f),
|
|
GeographyColumnMods.RandomFTableSchema(f),
|
|
GeographyColumnMods.RandomFTableName(f),
|
|
GeographyColumnMods.RandomFGeographyColumn(f),
|
|
GeographyColumnMods.RandomCoordDimension(f),
|
|
GeographyColumnMods.RandomSrid(f),
|
|
GeographyColumnMods.RandomType(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m geographyColumnMods) FTableCatalog(val null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableCatalog = func() null.Val[string] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m geographyColumnMods) FTableCatalogFunc(f func() null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableCatalog = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m geographyColumnMods) UnsetFTableCatalog() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableCatalog = 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 geographyColumnMods) RandomFTableCatalog(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableCatalog = 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 geographyColumnMods) RandomFTableCatalogNotNull(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableCatalog = 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 geographyColumnMods) FTableSchema(val null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableSchema = func() null.Val[string] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m geographyColumnMods) FTableSchemaFunc(f func() null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableSchema = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m geographyColumnMods) UnsetFTableSchema() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableSchema = 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 geographyColumnMods) RandomFTableSchema(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableSchema = 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 geographyColumnMods) RandomFTableSchemaNotNull(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableSchema = 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 geographyColumnMods) FTableName(val null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableName = func() null.Val[string] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m geographyColumnMods) FTableNameFunc(f func() null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableName = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m geographyColumnMods) UnsetFTableName() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableName = 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 geographyColumnMods) RandomFTableName(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableName = 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 geographyColumnMods) RandomFTableNameNotNull(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FTableName = 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 geographyColumnMods) FGeographyColumn(val null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FGeographyColumn = func() null.Val[string] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m geographyColumnMods) FGeographyColumnFunc(f func() null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FGeographyColumn = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m geographyColumnMods) UnsetFGeographyColumn() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FGeographyColumn = 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 geographyColumnMods) RandomFGeographyColumn(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FGeographyColumn = 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 geographyColumnMods) RandomFGeographyColumnNotNull(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.FGeographyColumn = 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 geographyColumnMods) CoordDimension(val null.Val[int32]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.CoordDimension = func() null.Val[int32] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m geographyColumnMods) CoordDimensionFunc(f func() null.Val[int32]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.CoordDimension = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m geographyColumnMods) UnsetCoordDimension() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.CoordDimension = 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 geographyColumnMods) RandomCoordDimension(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.CoordDimension = 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 geographyColumnMods) RandomCoordDimensionNotNull(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.CoordDimension = 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 geographyColumnMods) Srid(val null.Val[int32]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Srid = func() null.Val[int32] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m geographyColumnMods) SridFunc(f func() null.Val[int32]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Srid = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m geographyColumnMods) UnsetSrid() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Srid = 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 geographyColumnMods) RandomSrid(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Srid = 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 geographyColumnMods) RandomSridNotNull(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Srid = 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 geographyColumnMods) Type(val null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Type = func() null.Val[string] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m geographyColumnMods) TypeFunc(f func() null.Val[string]) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Type = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m geographyColumnMods) UnsetType() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Type = 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 geographyColumnMods) RandomType(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Type = 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 geographyColumnMods) RandomTypeNotNull(f *faker.Faker) GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(_ context.Context, o *GeographyColumnTemplate) {
|
|
o.Type = func() null.Val[string] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_string(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m geographyColumnMods) WithParentsCascading() GeographyColumnMod {
|
|
return GeographyColumnModFunc(func(ctx context.Context, o *GeographyColumnTemplate) {
|
|
if isDone, _ := geographyColumnWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = geographyColumnWithParentsCascadingCtx.WithValue(ctx, true)
|
|
})
|
|
}
|