// Code generated by BobGen psql v0.41.1. 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/models" "github.com/aarondl/opt/null" "github.com/jaswdr/faker/v2" ) type GeometryColumnMod interface { Apply(context.Context, *GeometryColumnTemplate) } type GeometryColumnModFunc func(context.Context, *GeometryColumnTemplate) func (f GeometryColumnModFunc) Apply(ctx context.Context, n *GeometryColumnTemplate) { f(ctx, n) } type GeometryColumnModSlice []GeometryColumnMod func (mods GeometryColumnModSlice) Apply(ctx context.Context, n *GeometryColumnTemplate) { for _, f := range mods { f.Apply(ctx, n) } } // GeometryColumnTemplate is an object representing the database table. // all columns are optional and should be set by mods type GeometryColumnTemplate struct { FTableCatalog func() null.Val[string] FTableSchema func() null.Val[string] FTableName func() null.Val[string] FGeometryColumn 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 GeometryColumnTemplate func (o *GeometryColumnTemplate) Apply(ctx context.Context, mods ...GeometryColumnMod) { for _, mod := range mods { mod.Apply(ctx, o) } } // setModelRels creates and sets the relationships on *models.GeometryColumn // according to the relationships in the template. Nothing is inserted into the db func (t GeometryColumnTemplate) setModelRels(o *models.GeometryColumn) {} // Build returns an *models.GeometryColumn // Related objects are also created and placed in the .R field // NOTE: Objects are not inserted into the database. Use GeometryColumnTemplate.Create func (o GeometryColumnTemplate) Build() *models.GeometryColumn { m := &models.GeometryColumn{} 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.FGeometryColumn != nil { m.FGeometryColumn = o.FGeometryColumn() } 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.GeometryColumnSlice // Related objects are also created and placed in the .R field // NOTE: Objects are not inserted into the database. Use GeometryColumnTemplate.CreateMany func (o GeometryColumnTemplate) BuildMany(number int) models.GeometryColumnSlice { m := make(models.GeometryColumnSlice, number) for i := range m { m[i] = o.Build() } return m } // GeometryColumn has methods that act as mods for the GeometryColumnTemplate var GeometryColumnMods geometryColumnMods type geometryColumnMods struct{} func (m geometryColumnMods) RandomizeAllColumns(f *faker.Faker) GeometryColumnMod { return GeometryColumnModSlice{ GeometryColumnMods.RandomFTableCatalog(f), GeometryColumnMods.RandomFTableSchema(f), GeometryColumnMods.RandomFTableName(f), GeometryColumnMods.RandomFGeometryColumn(f), GeometryColumnMods.RandomCoordDimension(f), GeometryColumnMods.RandomSrid(f), GeometryColumnMods.RandomType(f), } } // Set the model columns to this value func (m geometryColumnMods) FTableCatalog(val null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableCatalog = func() null.Val[string] { return val } }) } // Set the Column from the function func (m geometryColumnMods) FTableCatalogFunc(f func() null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableCatalog = f }) } // Clear any values for the column func (m geometryColumnMods) UnsetFTableCatalog() GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomFTableCatalog(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableCatalog = 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 geometryColumnMods) RandomFTableCatalogNotNull(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableCatalog = 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 geometryColumnMods) FTableSchema(val null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableSchema = func() null.Val[string] { return val } }) } // Set the Column from the function func (m geometryColumnMods) FTableSchemaFunc(f func() null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableSchema = f }) } // Clear any values for the column func (m geometryColumnMods) UnsetFTableSchema() GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomFTableSchema(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomFTableSchemaNotNull(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) FTableName(val null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableName = func() null.Val[string] { return val } }) } // Set the Column from the function func (m geometryColumnMods) FTableNameFunc(f func() null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FTableName = f }) } // Clear any values for the column func (m geometryColumnMods) UnsetFTableName() GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomFTableName(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomFTableNameNotNull(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) FGeometryColumn(val null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FGeometryColumn = func() null.Val[string] { return val } }) } // Set the Column from the function func (m geometryColumnMods) FGeometryColumnFunc(f func() null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FGeometryColumn = f }) } // Clear any values for the column func (m geometryColumnMods) UnsetFGeometryColumn() GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FGeometryColumn = 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 geometryColumnMods) RandomFGeometryColumn(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FGeometryColumn = 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 geometryColumnMods) RandomFGeometryColumnNotNull(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.FGeometryColumn = 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 geometryColumnMods) CoordDimension(val null.Val[int32]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.CoordDimension = func() null.Val[int32] { return val } }) } // Set the Column from the function func (m geometryColumnMods) CoordDimensionFunc(f func() null.Val[int32]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.CoordDimension = f }) } // Clear any values for the column func (m geometryColumnMods) UnsetCoordDimension() GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomCoordDimension(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomCoordDimensionNotNull(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) Srid(val null.Val[int32]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.Srid = func() null.Val[int32] { return val } }) } // Set the Column from the function func (m geometryColumnMods) SridFunc(f func() null.Val[int32]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.Srid = f }) } // Clear any values for the column func (m geometryColumnMods) UnsetSrid() GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomSrid(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomSridNotNull(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) Type(val null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.Type = func() null.Val[string] { return val } }) } // Set the Column from the function func (m geometryColumnMods) TypeFunc(f func() null.Val[string]) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.Type = f }) } // Clear any values for the column func (m geometryColumnMods) UnsetType() GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { 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 geometryColumnMods) RandomType(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.Type = func() null.Val[string] { if f == nil { f = &defaultFaker } val := random_string(f, "30") 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 geometryColumnMods) RandomTypeNotNull(f *faker.Faker) GeometryColumnMod { return GeometryColumnModFunc(func(_ context.Context, o *GeometryColumnTemplate) { o.Type = func() null.Val[string] { if f == nil { f = &defaultFaker } val := random_string(f, "30") return null.From(val) } }) } func (m geometryColumnMods) WithParentsCascading() GeometryColumnMod { return GeometryColumnModFunc(func(ctx context.Context, o *GeometryColumnTemplate) { if isDone, _ := geometryColumnWithParentsCascadingCtx.Value(ctx); isDone { return } ctx = geometryColumnWithParentsCascadingCtx.WithValue(ctx, true) }) }