497 lines
15 KiB
Go
497 lines
15 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/omit"
|
|
"github.com/jaswdr/faker/v2"
|
|
)
|
|
|
|
type FileuploadErrorCSVMod interface {
|
|
Apply(context.Context, *FileuploadErrorCSVTemplate)
|
|
}
|
|
|
|
type FileuploadErrorCSVModFunc func(context.Context, *FileuploadErrorCSVTemplate)
|
|
|
|
func (f FileuploadErrorCSVModFunc) Apply(ctx context.Context, n *FileuploadErrorCSVTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type FileuploadErrorCSVModSlice []FileuploadErrorCSVMod
|
|
|
|
func (mods FileuploadErrorCSVModSlice) Apply(ctx context.Context, n *FileuploadErrorCSVTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// FileuploadErrorCSVTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type FileuploadErrorCSVTemplate struct {
|
|
Col func() int32
|
|
CSVFileID func() int32
|
|
ID func() int32
|
|
Line func() int32
|
|
Message func() string
|
|
|
|
r fileuploadErrorCSVR
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
type fileuploadErrorCSVR struct {
|
|
CSVFileCSV *fileuploadErrorCSVRCSVFileCSVR
|
|
}
|
|
|
|
type fileuploadErrorCSVRCSVFileCSVR struct {
|
|
o *FileuploadCSVTemplate
|
|
}
|
|
|
|
// Apply mods to the FileuploadErrorCSVTemplate
|
|
func (o *FileuploadErrorCSVTemplate) Apply(ctx context.Context, mods ...FileuploadErrorCSVMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.FileuploadErrorCSV
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t FileuploadErrorCSVTemplate) setModelRels(o *models.FileuploadErrorCSV) {
|
|
if t.r.CSVFileCSV != nil {
|
|
rel := t.r.CSVFileCSV.o.Build()
|
|
rel.R.CSVFileErrorCSVS = append(rel.R.CSVFileErrorCSVS, o)
|
|
o.CSVFileID = rel.FileID // h2
|
|
o.R.CSVFileCSV = rel
|
|
}
|
|
}
|
|
|
|
// BuildSetter returns an *models.FileuploadErrorCSVSetter
|
|
// this does nothing with the relationship templates
|
|
func (o FileuploadErrorCSVTemplate) BuildSetter() *models.FileuploadErrorCSVSetter {
|
|
m := &models.FileuploadErrorCSVSetter{}
|
|
|
|
if o.Col != nil {
|
|
val := o.Col()
|
|
m.Col = omit.From(val)
|
|
}
|
|
if o.CSVFileID != nil {
|
|
val := o.CSVFileID()
|
|
m.CSVFileID = omit.From(val)
|
|
}
|
|
if o.ID != nil {
|
|
val := o.ID()
|
|
m.ID = omit.From(val)
|
|
}
|
|
if o.Line != nil {
|
|
val := o.Line()
|
|
m.Line = omit.From(val)
|
|
}
|
|
if o.Message != nil {
|
|
val := o.Message()
|
|
m.Message = omit.From(val)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildManySetter returns an []*models.FileuploadErrorCSVSetter
|
|
// this does nothing with the relationship templates
|
|
func (o FileuploadErrorCSVTemplate) BuildManySetter(number int) []*models.FileuploadErrorCSVSetter {
|
|
m := make([]*models.FileuploadErrorCSVSetter, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.BuildSetter()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// Build returns an *models.FileuploadErrorCSV
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use FileuploadErrorCSVTemplate.Create
|
|
func (o FileuploadErrorCSVTemplate) Build() *models.FileuploadErrorCSV {
|
|
m := &models.FileuploadErrorCSV{}
|
|
|
|
if o.Col != nil {
|
|
m.Col = o.Col()
|
|
}
|
|
if o.CSVFileID != nil {
|
|
m.CSVFileID = o.CSVFileID()
|
|
}
|
|
if o.ID != nil {
|
|
m.ID = o.ID()
|
|
}
|
|
if o.Line != nil {
|
|
m.Line = o.Line()
|
|
}
|
|
if o.Message != nil {
|
|
m.Message = o.Message()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.FileuploadErrorCSVSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use FileuploadErrorCSVTemplate.CreateMany
|
|
func (o FileuploadErrorCSVTemplate) BuildMany(number int) models.FileuploadErrorCSVSlice {
|
|
m := make(models.FileuploadErrorCSVSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func ensureCreatableFileuploadErrorCSV(m *models.FileuploadErrorCSVSetter) {
|
|
if !(m.Col.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.Col = omit.From(val)
|
|
}
|
|
if !(m.CSVFileID.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.CSVFileID = omit.From(val)
|
|
}
|
|
if !(m.Line.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.Line = omit.From(val)
|
|
}
|
|
if !(m.Message.IsValue()) {
|
|
val := random_string(nil)
|
|
m.Message = omit.From(val)
|
|
}
|
|
}
|
|
|
|
// insertOptRels creates and inserts any optional the relationships on *models.FileuploadErrorCSV
|
|
// according to the relationships in the template.
|
|
// any required relationship should have already exist on the model
|
|
func (o *FileuploadErrorCSVTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FileuploadErrorCSV) error {
|
|
var err error
|
|
|
|
return err
|
|
}
|
|
|
|
// Create builds a fileuploadErrorCSV and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o *FileuploadErrorCSVTemplate) Create(ctx context.Context, exec bob.Executor) (*models.FileuploadErrorCSV, error) {
|
|
var err error
|
|
opt := o.BuildSetter()
|
|
ensureCreatableFileuploadErrorCSV(opt)
|
|
|
|
if o.r.CSVFileCSV == nil {
|
|
FileuploadErrorCSVMods.WithNewCSVFileCSV().Apply(ctx, o)
|
|
}
|
|
|
|
var rel0 *models.FileuploadCSV
|
|
|
|
if o.r.CSVFileCSV.o.alreadyPersisted {
|
|
rel0 = o.r.CSVFileCSV.o.Build()
|
|
} else {
|
|
rel0, err = o.r.CSVFileCSV.o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
opt.CSVFileID = omit.From(rel0.FileID)
|
|
|
|
m, err := models.FileuploadErrorCSVS.Insert(opt).One(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
m.R.CSVFileCSV = rel0
|
|
|
|
if err := o.insertOptRels(ctx, exec, m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, err
|
|
}
|
|
|
|
// MustCreate builds a fileuploadErrorCSV and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o *FileuploadErrorCSVTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.FileuploadErrorCSV {
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateOrFail builds a fileuploadErrorCSV 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 *FileuploadErrorCSVTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.FileuploadErrorCSV {
|
|
tb.Helper()
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateMany builds multiple fileuploadErrorCSVS and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o FileuploadErrorCSVTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.FileuploadErrorCSVSlice, error) {
|
|
var err error
|
|
m := make(models.FileuploadErrorCSVSlice, number)
|
|
|
|
for i := range m {
|
|
m[i], err = o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return m, nil
|
|
}
|
|
|
|
// MustCreateMany builds multiple fileuploadErrorCSVS and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o FileuploadErrorCSVTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.FileuploadErrorCSVSlice {
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateManyOrFail builds multiple fileuploadErrorCSVS 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 FileuploadErrorCSVTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.FileuploadErrorCSVSlice {
|
|
tb.Helper()
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// FileuploadErrorCSV has methods that act as mods for the FileuploadErrorCSVTemplate
|
|
var FileuploadErrorCSVMods fileuploadErrorCSVMods
|
|
|
|
type fileuploadErrorCSVMods struct{}
|
|
|
|
func (m fileuploadErrorCSVMods) RandomizeAllColumns(f *faker.Faker) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModSlice{
|
|
FileuploadErrorCSVMods.RandomCol(f),
|
|
FileuploadErrorCSVMods.RandomCSVFileID(f),
|
|
FileuploadErrorCSVMods.RandomID(f),
|
|
FileuploadErrorCSVMods.RandomLine(f),
|
|
FileuploadErrorCSVMods.RandomMessage(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m fileuploadErrorCSVMods) Col(val int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Col = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m fileuploadErrorCSVMods) ColFunc(f func() int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Col = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m fileuploadErrorCSVMods) UnsetCol() FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Col = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m fileuploadErrorCSVMods) RandomCol(f *faker.Faker) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Col = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m fileuploadErrorCSVMods) CSVFileID(val int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.CSVFileID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m fileuploadErrorCSVMods) CSVFileIDFunc(f func() int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.CSVFileID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m fileuploadErrorCSVMods) UnsetCSVFileID() FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.CSVFileID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m fileuploadErrorCSVMods) RandomCSVFileID(f *faker.Faker) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.CSVFileID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m fileuploadErrorCSVMods) ID(val int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.ID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m fileuploadErrorCSVMods) IDFunc(f func() int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.ID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m fileuploadErrorCSVMods) UnsetID() FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.ID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m fileuploadErrorCSVMods) RandomID(f *faker.Faker) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.ID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m fileuploadErrorCSVMods) Line(val int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Line = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m fileuploadErrorCSVMods) LineFunc(f func() int32) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Line = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m fileuploadErrorCSVMods) UnsetLine() FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Line = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m fileuploadErrorCSVMods) RandomLine(f *faker.Faker) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Line = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m fileuploadErrorCSVMods) Message(val string) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Message = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m fileuploadErrorCSVMods) MessageFunc(f func() string) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Message = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m fileuploadErrorCSVMods) UnsetMessage() FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Message = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m fileuploadErrorCSVMods) RandomMessage(f *faker.Faker) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(_ context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.Message = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m fileuploadErrorCSVMods) WithParentsCascading() FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(ctx context.Context, o *FileuploadErrorCSVTemplate) {
|
|
if isDone, _ := fileuploadErrorCSVWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = fileuploadErrorCSVWithParentsCascadingCtx.WithValue(ctx, true)
|
|
{
|
|
|
|
related := o.f.NewFileuploadCSVWithContext(ctx, FileuploadCSVMods.WithParentsCascading())
|
|
m.WithCSVFileCSV(related).Apply(ctx, o)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m fileuploadErrorCSVMods) WithCSVFileCSV(rel *FileuploadCSVTemplate) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(ctx context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.r.CSVFileCSV = &fileuploadErrorCSVRCSVFileCSVR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m fileuploadErrorCSVMods) WithNewCSVFileCSV(mods ...FileuploadCSVMod) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(ctx context.Context, o *FileuploadErrorCSVTemplate) {
|
|
related := o.f.NewFileuploadCSVWithContext(ctx, mods...)
|
|
|
|
m.WithCSVFileCSV(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m fileuploadErrorCSVMods) WithExistingCSVFileCSV(em *models.FileuploadCSV) FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(ctx context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.r.CSVFileCSV = &fileuploadErrorCSVRCSVFileCSVR{
|
|
o: o.f.FromExistingFileuploadCSV(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m fileuploadErrorCSVMods) WithoutCSVFileCSV() FileuploadErrorCSVMod {
|
|
return FileuploadErrorCSVModFunc(func(ctx context.Context, o *FileuploadErrorCSVTemplate) {
|
|
o.r.CSVFileCSV = nil
|
|
})
|
|
}
|