Add statistics on the sync and save org ID with fieldseeker tables

We need the org ID so that we can avoid bleedover between different
organizations.
This commit is contained in:
Eli Ribble 2025-11-07 09:30:31 +00:00
parent bf6e40d877
commit b0432f3243
No known key found for this signature in database
178 changed files with 9075 additions and 6223 deletions

View file

@ -8,6 +8,10 @@ import "context"
type contextKey string
var (
// Relationship Contexts for fieldseeker_sync
fieldseekerSyncWithParentsCascadingCtx = newContextual[bool]("fieldseekerSyncWithParentsCascading")
fieldseekerSyncRelOrganizationCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey")
// Relationship Contexts for fs_containerrelate
fsContainerrelateWithParentsCascadingCtx = newContextual[bool]("fsContainerrelateWithParentsCascading")
fsContainerrelateRelOrganizationCtx = newContextual[bool]("fs_containerrelate.organization.fs_containerrelate.fs_containerrelate_organization_id_fkey")
@ -233,6 +237,7 @@ var (
// Relationship Contexts for organization
organizationWithParentsCascadingCtx = newContextual[bool]("organizationWithParentsCascading")
organizationRelFieldseekerSyncsCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey")
organizationRelFSContainerrelatesCtx = newContextual[bool]("fs_containerrelate.organization.fs_containerrelate.fs_containerrelate_organization_id_fkey")
organizationRelFSFieldscoutinglogsCtx = newContextual[bool]("fs_fieldscoutinglog.organization.fs_fieldscoutinglog.fs_fieldscoutinglog_organization_id_fkey")
organizationRelFSHabitatrelatesCtx = newContextual[bool]("fs_habitatrelate.organization.fs_habitatrelate.fs_habitatrelate_organization_id_fkey")

View file

@ -13,6 +13,7 @@ import (
)
type Factory struct {
baseFieldseekerSyncMods FieldseekerSyncModSlice
baseFSContainerrelateMods FSContainerrelateModSlice
baseFSFieldscoutinglogMods FSFieldscoutinglogModSlice
baseFSHabitatrelateMods FSHabitatrelateModSlice
@ -78,6 +79,40 @@ func New() *Factory {
return &Factory{}
}
func (f *Factory) NewFieldseekerSync(mods ...FieldseekerSyncMod) *FieldseekerSyncTemplate {
return f.NewFieldseekerSyncWithContext(context.Background(), mods...)
}
func (f *Factory) NewFieldseekerSyncWithContext(ctx context.Context, mods ...FieldseekerSyncMod) *FieldseekerSyncTemplate {
o := &FieldseekerSyncTemplate{f: f}
if f != nil {
f.baseFieldseekerSyncMods.Apply(ctx, o)
}
FieldseekerSyncModSlice(mods).Apply(ctx, o)
return o
}
func (f *Factory) FromExistingFieldseekerSync(m *models.FieldseekerSync) *FieldseekerSyncTemplate {
o := &FieldseekerSyncTemplate{f: f, alreadyPersisted: true}
o.ID = func() int32 { return m.ID }
o.Created = func() time.Time { return m.Created }
o.RecordsCreated = func() int32 { return m.RecordsCreated }
o.RecordsUpdated = func() int32 { return m.RecordsUpdated }
o.RecordsUnchanged = func() int32 { return m.RecordsUnchanged }
o.OrganizationID = func() int32 { return m.OrganizationID }
ctx := context.Background()
if m.R.Organization != nil {
FieldseekerSyncMods.WithExistingOrganization(m.R.Organization).Apply(ctx, o)
}
return o
}
func (f *Factory) NewFSContainerrelate(mods ...FSContainerrelateMod) *FSContainerrelateTemplate {
return f.NewFSContainerrelateWithContext(context.Background(), mods...)
}
@ -97,7 +132,7 @@ func (f *Factory) NewFSContainerrelateWithContext(ctx context.Context, mods ...F
func (f *Factory) FromExistingFSContainerrelate(m *models.FSContainerrelate) *FSContainerrelateTemplate {
o := &FSContainerrelateTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Containertype = func() null.Val[string] { return m.Containertype }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -143,7 +178,7 @@ func (f *Factory) NewFSFieldscoutinglogWithContext(ctx context.Context, mods ...
func (f *Factory) FromExistingFSFieldscoutinglog(m *models.FSFieldscoutinglog) *FSFieldscoutinglogTemplate {
o := &FSFieldscoutinglogTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -186,7 +221,7 @@ func (f *Factory) NewFSHabitatrelateWithContext(ctx context.Context, mods ...FSH
func (f *Factory) FromExistingFSHabitatrelate(m *models.FSHabitatrelate) *FSHabitatrelateTemplate {
o := &FSHabitatrelateTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -230,7 +265,7 @@ func (f *Factory) NewFSInspectionsampleWithContext(ctx context.Context, mods ...
func (f *Factory) FromExistingFSInspectionsample(m *models.FSInspectionsample) *FSInspectionsampleTemplate {
o := &FSInspectionsampleTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -276,7 +311,7 @@ func (f *Factory) NewFSInspectionsampledetailWithContext(ctx context.Context, mo
func (f *Factory) FromExistingFSInspectionsampledetail(m *models.FSInspectionsampledetail) *FSInspectionsampledetailTemplate {
o := &FSInspectionsampledetailTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -333,7 +368,7 @@ func (f *Factory) NewFSLinelocationWithContext(ctx context.Context, mods ...FSLi
func (f *Factory) FromExistingFSLinelocation(m *models.FSLinelocation) *FSLinelocationTemplate {
o := &FSLinelocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Acres = func() null.Val[float64] { return m.Acres }
o.Active = func() null.Val[int16] { return m.Active }
@ -413,7 +448,7 @@ func (f *Factory) NewFSLocationtrackingWithContext(ctx context.Context, mods ...
func (f *Factory) FromExistingFSLocationtracking(m *models.FSLocationtracking) *FSLocationtrackingTemplate {
o := &FSLocationtrackingTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accuracy = func() null.Val[float64] { return m.Accuracy }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -457,7 +492,7 @@ func (f *Factory) NewFSMosquitoinspectionWithContext(ctx context.Context, mods .
func (f *Factory) FromExistingFSMosquitoinspection(m *models.FSMosquitoinspection) *FSMosquitoinspectionTemplate {
o := &FSMosquitoinspectionTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Actiontaken = func() null.Val[string] { return m.Actiontaken }
o.Activity = func() null.Val[string] { return m.Activity }
o.Adultact = func() null.Val[string] { return m.Adultact }
@ -546,7 +581,7 @@ func (f *Factory) NewFSPointlocationWithContext(ctx context.Context, mods ...FSP
func (f *Factory) FromExistingFSPointlocation(m *models.FSPointlocation) *FSPointlocationTemplate {
o := &FSPointlocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -622,7 +657,7 @@ func (f *Factory) NewFSPolygonlocationWithContext(ctx context.Context, mods ...F
func (f *Factory) FromExistingFSPolygonlocation(m *models.FSPolygonlocation) *FSPolygonlocationTemplate {
o := &FSPolygonlocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Acres = func() null.Val[float64] { return m.Acres }
o.Active = func() null.Val[int16] { return m.Active }
@ -696,7 +731,7 @@ func (f *Factory) NewFSPoolWithContext(ctx context.Context, mods ...FSPoolMod) *
func (f *Factory) FromExistingFSPool(m *models.FSPool) *FSPoolTemplate {
o := &FSPoolTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -756,7 +791,7 @@ func (f *Factory) NewFSPooldetailWithContext(ctx context.Context, mods ...FSPool
func (f *Factory) FromExistingFSPooldetail(m *models.FSPooldetail) *FSPooldetailTemplate {
o := &FSPooldetailTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -802,7 +837,7 @@ func (f *Factory) NewFSProposedtreatmentareaWithContext(ctx context.Context, mod
func (f *Factory) FromExistingFSProposedtreatmentarea(m *models.FSProposedtreatmentarea) *FSProposedtreatmentareaTemplate {
o := &FSProposedtreatmentareaTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Acres = func() null.Val[float64] { return m.Acres }
o.Comments = func() null.Val[string] { return m.Comments }
o.Completed = func() null.Val[int16] { return m.Completed }
@ -867,7 +902,7 @@ func (f *Factory) NewFSQamosquitoinspectionWithContext(ctx context.Context, mods
func (f *Factory) FromExistingFSQamosquitoinspection(m *models.FSQamosquitoinspection) *FSQamosquitoinspectionTemplate {
o := &FSQamosquitoinspectionTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Acresbreeding = func() null.Val[float64] { return m.Acresbreeding }
o.Actiontaken = func() null.Val[string] { return m.Actiontaken }
o.Adultactivity = func() null.Val[int16] { return m.Adultactivity }
@ -961,7 +996,7 @@ func (f *Factory) NewFSRodentlocationWithContext(ctx context.Context, mods ...FS
func (f *Factory) FromExistingFSRodentlocation(m *models.FSRodentlocation) *FSRodentlocationTemplate {
o := &FSRodentlocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -1023,7 +1058,7 @@ func (f *Factory) NewFSSamplecollectionWithContext(ctx context.Context, mods ...
func (f *Factory) FromExistingFSSamplecollection(m *models.FSSamplecollection) *FSSamplecollectionTemplate {
o := &FSSamplecollectionTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Activity = func() null.Val[string] { return m.Activity }
o.Avetemp = func() null.Val[float64] { return m.Avetemp }
o.Chickenid = func() null.Val[string] { return m.Chickenid }
@ -1101,7 +1136,7 @@ func (f *Factory) NewFSSamplelocationWithContext(ctx context.Context, mods ...FS
func (f *Factory) FromExistingFSSamplelocation(m *models.FSSamplelocation) *FSSamplelocationTemplate {
o := &FSSamplelocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -1157,7 +1192,7 @@ func (f *Factory) NewFSServicerequestWithContext(ctx context.Context, mods ...FS
func (f *Factory) FromExistingFSServicerequest(m *models.FSServicerequest) *FSServicerequestTemplate {
o := &FSServicerequestTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accepted = func() null.Val[int16] { return m.Accepted }
o.Acceptedby = func() null.Val[string] { return m.Acceptedby }
o.Accepteddate = func() null.Val[int64] { return m.Accepteddate }
@ -1275,7 +1310,7 @@ func (f *Factory) NewFSSpeciesabundanceWithContext(ctx context.Context, mods ...
func (f *Factory) FromExistingFSSpeciesabundance(m *models.FSSpeciesabundance) *FSSpeciesabundanceTemplate {
o := &FSSpeciesabundanceTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Bloodedfem = func() null.Val[int16] { return m.Bloodedfem }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -1336,7 +1371,7 @@ func (f *Factory) NewFSStormdrainWithContext(ctx context.Context, mods ...FSStor
func (f *Factory) FromExistingFSStormdrain(m *models.FSStormdrain) *FSStormdrainTemplate {
o := &FSStormdrainTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -1387,7 +1422,7 @@ func (f *Factory) NewFSTimecardWithContext(ctx context.Context, mods ...FSTimeca
func (f *Factory) FromExistingFSTimecard(m *models.FSTimecard) *FSTimecardTemplate {
o := &FSTimecardTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Activity = func() null.Val[string] { return m.Activity }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
@ -1447,7 +1482,7 @@ func (f *Factory) NewFSTrapdatumWithContext(ctx context.Context, mods ...FSTrapd
func (f *Factory) FromExistingFSTrapdatum(m *models.FSTrapdatum) *FSTrapdatumTemplate {
o := &FSTrapdatumTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Avetemp = func() null.Val[float64] { return m.Avetemp }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
@ -1521,7 +1556,7 @@ func (f *Factory) NewFSTraplocationWithContext(ctx context.Context, mods ...FSTr
func (f *Factory) FromExistingFSTraplocation(m *models.FSTraplocation) *FSTraplocationTemplate {
o := &FSTraplocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -1583,7 +1618,7 @@ func (f *Factory) NewFSTreatmentWithContext(ctx context.Context, mods ...FSTreat
func (f *Factory) FromExistingFSTreatment(m *models.FSTreatment) *FSTreatmentTemplate {
o := &FSTreatmentTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Activity = func() null.Val[string] { return m.Activity }
o.Areaunit = func() null.Val[string] { return m.Areaunit }
o.Avetemp = func() null.Val[float64] { return m.Avetemp }
@ -1669,7 +1704,7 @@ func (f *Factory) NewFSTreatmentareaWithContext(ctx context.Context, mods ...FST
func (f *Factory) FromExistingFSTreatmentarea(m *models.FSTreatmentarea) *FSTreatmentareaTemplate {
o := &FSTreatmentareaTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -1719,7 +1754,7 @@ func (f *Factory) NewFSZoneWithContext(ctx context.Context, mods ...FSZoneMod) *
func (f *Factory) FromExistingFSZone(m *models.FSZone) *FSZoneTemplate {
o := &FSZoneTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Active = func() null.Val[int64] { return m.Active }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -1765,7 +1800,7 @@ func (f *Factory) NewFSZones2WithContext(ctx context.Context, mods ...FSZones2Mo
func (f *Factory) FromExistingFSZones2(m *models.FSZones2) *FSZones2Template {
o := &FSZones2Template{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -1837,7 +1872,7 @@ func (f *Factory) NewHistoryContainerrelateWithContext(ctx context.Context, mods
func (f *Factory) FromExistingHistoryContainerrelate(m *models.HistoryContainerrelate) *HistoryContainerrelateTemplate {
o := &HistoryContainerrelateTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Containertype = func() null.Val[string] { return m.Containertype }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -1848,6 +1883,7 @@ func (f *Factory) FromExistingHistoryContainerrelate(m *models.HistoryContainerr
o.Mosquitoinspid = func() null.Val[string] { return m.Mosquitoinspid }
o.Objectid = func() int32 { return m.Objectid }
o.Treatmentid = func() null.Val[string] { return m.Treatmentid }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -1883,7 +1919,7 @@ func (f *Factory) NewHistoryFieldscoutinglogWithContext(ctx context.Context, mod
func (f *Factory) FromExistingHistoryFieldscoutinglog(m *models.HistoryFieldscoutinglog) *HistoryFieldscoutinglogTemplate {
o := &HistoryFieldscoutinglogTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -1891,6 +1927,7 @@ func (f *Factory) FromExistingHistoryFieldscoutinglog(m *models.HistoryFieldscou
o.Globalid = func() null.Val[string] { return m.Globalid }
o.Objectid = func() int32 { return m.Objectid }
o.Status = func() null.Val[int16] { return m.Status }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -1926,7 +1963,7 @@ func (f *Factory) NewHistoryHabitatrelateWithContext(ctx context.Context, mods .
func (f *Factory) FromExistingHistoryHabitatrelate(m *models.HistoryHabitatrelate) *HistoryHabitatrelateTemplate {
o := &HistoryHabitatrelateTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -1935,6 +1972,7 @@ func (f *Factory) FromExistingHistoryHabitatrelate(m *models.HistoryHabitatrelat
o.Globalid = func() null.Val[string] { return m.Globalid }
o.Habitattype = func() null.Val[string] { return m.Habitattype }
o.Objectid = func() int32 { return m.Objectid }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -1970,7 +2008,7 @@ func (f *Factory) NewHistoryInspectionsampleWithContext(ctx context.Context, mod
func (f *Factory) FromExistingHistoryInspectionsample(m *models.HistoryInspectionsample) *HistoryInspectionsampleTemplate {
o := &HistoryInspectionsampleTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -1981,6 +2019,7 @@ func (f *Factory) FromExistingHistoryInspectionsample(m *models.HistoryInspectio
o.Objectid = func() int32 { return m.Objectid }
o.Processed = func() null.Val[int16] { return m.Processed }
o.Sampleid = func() null.Val[string] { return m.Sampleid }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2016,7 +2055,7 @@ func (f *Factory) NewHistoryInspectionsampledetailWithContext(ctx context.Contex
func (f *Factory) FromExistingHistoryInspectionsampledetail(m *models.HistoryInspectionsampledetail) *HistoryInspectionsampledetailTemplate {
o := &HistoryInspectionsampledetailTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -2038,6 +2077,7 @@ func (f *Factory) FromExistingHistoryInspectionsampledetail(m *models.HistoryIns
o.Lpupcount = func() null.Val[int16] { return m.Lpupcount }
o.Objectid = func() int32 { return m.Objectid }
o.Processed = func() null.Val[int16] { return m.Processed }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2073,7 +2113,7 @@ func (f *Factory) NewHistoryLinelocationWithContext(ctx context.Context, mods ..
func (f *Factory) FromExistingHistoryLinelocation(m *models.HistoryLinelocation) *HistoryLinelocationTemplate {
o := &HistoryLinelocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Acres = func() null.Val[float64] { return m.Acres }
o.Active = func() null.Val[int16] { return m.Active }
@ -2118,6 +2158,7 @@ func (f *Factory) FromExistingHistoryLinelocation(m *models.HistoryLinelocation)
o.WidthMeters = func() null.Val[float64] { return m.WidthMeters }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2153,7 +2194,7 @@ func (f *Factory) NewHistoryLocationtrackingWithContext(ctx context.Context, mod
func (f *Factory) FromExistingHistoryLocationtracking(m *models.HistoryLocationtracking) *HistoryLocationtrackingTemplate {
o := &HistoryLocationtrackingTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accuracy = func() null.Val[float64] { return m.Accuracy }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -2162,6 +2203,7 @@ func (f *Factory) FromExistingHistoryLocationtracking(m *models.HistoryLocationt
o.Fieldtech = func() null.Val[string] { return m.Fieldtech }
o.Globalid = func() null.Val[string] { return m.Globalid }
o.Objectid = func() int32 { return m.Objectid }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2197,7 +2239,7 @@ func (f *Factory) NewHistoryMosquitoinspectionWithContext(ctx context.Context, m
func (f *Factory) FromExistingHistoryMosquitoinspection(m *models.HistoryMosquitoinspection) *HistoryMosquitoinspectionTemplate {
o := &HistoryMosquitoinspectionTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Actiontaken = func() null.Val[string] { return m.Actiontaken }
o.Activity = func() null.Val[string] { return m.Activity }
o.Adultact = func() null.Val[string] { return m.Adultact }
@ -2249,6 +2291,7 @@ func (f *Factory) FromExistingHistoryMosquitoinspection(m *models.HistoryMosquit
o.Windspeed = func() null.Val[float64] { return m.Windspeed }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2286,7 +2329,7 @@ func (f *Factory) NewHistoryPointlocationWithContext(ctx context.Context, mods .
func (f *Factory) FromExistingHistoryPointlocation(m *models.HistoryPointlocation) *HistoryPointlocationTemplate {
o := &HistoryPointlocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -2362,7 +2405,7 @@ func (f *Factory) NewHistoryPolygonlocationWithContext(ctx context.Context, mods
func (f *Factory) FromExistingHistoryPolygonlocation(m *models.HistoryPolygonlocation) *HistoryPolygonlocationTemplate {
o := &HistoryPolygonlocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Acres = func() null.Val[float64] { return m.Acres }
o.Active = func() null.Val[int16] { return m.Active }
@ -2436,7 +2479,7 @@ func (f *Factory) NewHistoryPoolWithContext(ctx context.Context, mods ...History
func (f *Factory) FromExistingHistoryPool(m *models.HistoryPool) *HistoryPoolTemplate {
o := &HistoryPoolTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -2458,6 +2501,7 @@ func (f *Factory) FromExistingHistoryPool(m *models.HistoryPool) *HistoryPoolTem
o.Testmethod = func() null.Val[string] { return m.Testmethod }
o.Testtech = func() null.Val[string] { return m.Testtech }
o.TrapdataID = func() null.Val[string] { return m.TrapdataID }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2496,7 +2540,7 @@ func (f *Factory) NewHistoryPooldetailWithContext(ctx context.Context, mods ...H
func (f *Factory) FromExistingHistoryPooldetail(m *models.HistoryPooldetail) *HistoryPooldetailTemplate {
o := &HistoryPooldetailTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -2507,6 +2551,7 @@ func (f *Factory) FromExistingHistoryPooldetail(m *models.HistoryPooldetail) *Hi
o.PoolID = func() null.Val[string] { return m.PoolID }
o.Species = func() null.Val[string] { return m.Species }
o.TrapdataID = func() null.Val[string] { return m.TrapdataID }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2542,7 +2587,7 @@ func (f *Factory) NewHistoryProposedtreatmentareaWithContext(ctx context.Context
func (f *Factory) FromExistingHistoryProposedtreatmentarea(m *models.HistoryProposedtreatmentarea) *HistoryProposedtreatmentareaTemplate {
o := &HistoryProposedtreatmentareaTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Acres = func() null.Val[float64] { return m.Acres }
o.Comments = func() null.Val[string] { return m.Comments }
o.Completed = func() null.Val[int16] { return m.Completed }
@ -2607,7 +2652,7 @@ func (f *Factory) NewHistoryQamosquitoinspectionWithContext(ctx context.Context,
func (f *Factory) FromExistingHistoryQamosquitoinspection(m *models.HistoryQamosquitoinspection) *HistoryQamosquitoinspectionTemplate {
o := &HistoryQamosquitoinspectionTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Acresbreeding = func() null.Val[float64] { return m.Acresbreeding }
o.Actiontaken = func() null.Val[string] { return m.Actiontaken }
o.Adultactivity = func() null.Val[int16] { return m.Adultactivity }
@ -2666,6 +2711,7 @@ func (f *Factory) FromExistingHistoryQamosquitoinspection(m *models.HistoryQamos
o.Windspeed = func() null.Val[float64] { return m.Windspeed }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2701,7 +2747,7 @@ func (f *Factory) NewHistoryRodentlocationWithContext(ctx context.Context, mods
func (f *Factory) FromExistingHistoryRodentlocation(m *models.HistoryRodentlocation) *HistoryRodentlocationTemplate {
o := &HistoryRodentlocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -2727,6 +2773,7 @@ func (f *Factory) FromExistingHistoryRodentlocation(m *models.HistoryRodentlocat
o.Usetype = func() null.Val[string] { return m.Usetype }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2763,7 +2810,7 @@ func (f *Factory) NewHistorySamplecollectionWithContext(ctx context.Context, mod
func (f *Factory) FromExistingHistorySamplecollection(m *models.HistorySamplecollection) *HistorySamplecollectionTemplate {
o := &HistorySamplecollectionTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Activity = func() null.Val[string] { return m.Activity }
o.Avetemp = func() null.Val[float64] { return m.Avetemp }
o.Chickenid = func() null.Val[string] { return m.Chickenid }
@ -2806,6 +2853,7 @@ func (f *Factory) FromExistingHistorySamplecollection(m *models.HistorySamplecol
o.Windspeed = func() null.Val[float64] { return m.Windspeed }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2841,7 +2889,7 @@ func (f *Factory) NewHistorySamplelocationWithContext(ctx context.Context, mods
func (f *Factory) FromExistingHistorySamplelocation(m *models.HistorySamplelocation) *HistorySamplelocationTemplate {
o := &HistorySamplelocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -2862,6 +2910,7 @@ func (f *Factory) FromExistingHistorySamplelocation(m *models.HistorySamplelocat
o.Usetype = func() null.Val[string] { return m.Usetype }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -2897,7 +2946,7 @@ func (f *Factory) NewHistoryServicerequestWithContext(ctx context.Context, mods
func (f *Factory) FromExistingHistoryServicerequest(m *models.HistoryServicerequest) *HistoryServicerequestTemplate {
o := &HistoryServicerequestTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accepted = func() null.Val[int16] { return m.Accepted }
o.Acceptedby = func() null.Val[string] { return m.Acceptedby }
o.Accepteddate = func() null.Val[int64] { return m.Accepteddate }
@ -2976,6 +3025,7 @@ func (f *Factory) FromExistingHistoryServicerequest(m *models.HistoryServicerequ
o.Yvalue = func() null.Val[string] { return m.Yvalue }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3015,7 +3065,7 @@ func (f *Factory) NewHistorySpeciesabundanceWithContext(ctx context.Context, mod
func (f *Factory) FromExistingHistorySpeciesabundance(m *models.HistorySpeciesabundance) *HistorySpeciesabundanceTemplate {
o := &HistorySpeciesabundanceTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Bloodedfem = func() null.Val[int16] { return m.Bloodedfem }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -3035,6 +3085,7 @@ func (f *Factory) FromExistingHistorySpeciesabundance(m *models.HistorySpeciesab
o.Total = func() null.Val[int64] { return m.Total }
o.TrapdataID = func() null.Val[string] { return m.TrapdataID }
o.Unknown = func() null.Val[int16] { return m.Unknown }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3076,7 +3127,7 @@ func (f *Factory) NewHistoryStormdrainWithContext(ctx context.Context, mods ...H
func (f *Factory) FromExistingHistoryStormdrain(m *models.HistoryStormdrain) *HistoryStormdrainTemplate {
o := &HistoryStormdrainTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -3092,6 +3143,7 @@ func (f *Factory) FromExistingHistoryStormdrain(m *models.HistoryStormdrain) *Hi
o.Type = func() null.Val[string] { return m.Type }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3127,7 +3179,7 @@ func (f *Factory) NewHistoryTimecardWithContext(ctx context.Context, mods ...His
func (f *Factory) FromExistingHistoryTimecard(m *models.HistoryTimecard) *HistoryTimecardTemplate {
o := &HistoryTimecardTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Activity = func() null.Val[string] { return m.Activity }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
@ -3151,6 +3203,7 @@ func (f *Factory) FromExistingHistoryTimecard(m *models.HistoryTimecard) *Histor
o.Traplocid = func() null.Val[string] { return m.Traplocid }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3187,7 +3240,7 @@ func (f *Factory) NewHistoryTrapdatumWithContext(ctx context.Context, mods ...Hi
func (f *Factory) FromExistingHistoryTrapdatum(m *models.HistoryTrapdatum) *HistoryTrapdatumTemplate {
o := &HistoryTrapdatumTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Avetemp = func() null.Val[float64] { return m.Avetemp }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
@ -3223,6 +3276,7 @@ func (f *Factory) FromExistingHistoryTrapdatum(m *models.HistoryTrapdatum) *Hist
o.Windspeed = func() null.Val[float64] { return m.Windspeed }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3261,7 +3315,7 @@ func (f *Factory) NewHistoryTraplocationWithContext(ctx context.Context, mods ..
func (f *Factory) FromExistingHistoryTraplocation(m *models.HistoryTraplocation) *HistoryTraplocationTemplate {
o := &HistoryTraplocationTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Accessdesc = func() null.Val[string] { return m.Accessdesc }
o.Active = func() null.Val[int16] { return m.Active }
o.Comments = func() null.Val[string] { return m.Comments }
@ -3282,6 +3336,7 @@ func (f *Factory) FromExistingHistoryTraplocation(m *models.HistoryTraplocation)
o.Usetype = func() null.Val[string] { return m.Usetype }
o.Zone = func() null.Val[string] { return m.Zone }
o.Zone2 = func() null.Val[string] { return m.Zone2 }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3323,7 +3378,7 @@ func (f *Factory) NewHistoryTreatmentWithContext(ctx context.Context, mods ...Hi
func (f *Factory) FromExistingHistoryTreatment(m *models.HistoryTreatment) *HistoryTreatmentTemplate {
o := &HistoryTreatmentTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Activity = func() null.Val[string] { return m.Activity }
o.Areaunit = func() null.Val[string] { return m.Areaunit }
o.Avetemp = func() null.Val[float64] { return m.Avetemp }
@ -3409,7 +3464,7 @@ func (f *Factory) NewHistoryTreatmentareaWithContext(ctx context.Context, mods .
func (f *Factory) FromExistingHistoryTreatmentarea(m *models.HistoryTreatmentarea) *HistoryTreatmentareaTemplate {
o := &HistoryTreatmentareaTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Comments = func() null.Val[string] { return m.Comments }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -3424,6 +3479,7 @@ func (f *Factory) FromExistingHistoryTreatmentarea(m *models.HistoryTreatmentare
o.Treatdate = func() null.Val[int64] { return m.Treatdate }
o.TreatID = func() null.Val[string] { return m.TreatID }
o.Type = func() null.Val[string] { return m.Type }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3459,7 +3515,7 @@ func (f *Factory) NewHistoryZoneWithContext(ctx context.Context, mods ...History
func (f *Factory) FromExistingHistoryZone(m *models.HistoryZone) *HistoryZoneTemplate {
o := &HistoryZoneTemplate{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Active = func() null.Val[int64] { return m.Active }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
@ -3470,6 +3526,7 @@ func (f *Factory) FromExistingHistoryZone(m *models.HistoryZone) *HistoryZoneTem
o.Objectid = func() int32 { return m.Objectid }
o.ShapeArea = func() null.Val[float64] { return m.ShapeArea }
o.ShapeLength = func() null.Val[float64] { return m.ShapeLength }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3505,7 +3562,7 @@ func (f *Factory) NewHistoryZones2WithContext(ctx context.Context, mods ...Histo
func (f *Factory) FromExistingHistoryZones2(m *models.HistoryZones2) *HistoryZones2Template {
o := &HistoryZones2Template{f: f, alreadyPersisted: true}
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
o.OrganizationID = func() int32 { return m.OrganizationID }
o.Creationdate = func() null.Val[int64] { return m.Creationdate }
o.Creator = func() null.Val[string] { return m.Creator }
o.Editdate = func() null.Val[int64] { return m.Editdate }
@ -3515,6 +3572,7 @@ func (f *Factory) FromExistingHistoryZones2(m *models.HistoryZones2) *HistoryZon
o.Objectid = func() int32 { return m.Objectid }
o.ShapeArea = func() null.Val[float64] { return m.ShapeArea }
o.ShapeLength = func() null.Val[float64] { return m.ShapeLength }
o.Created = func() null.Val[time.Time] { return m.Created }
o.CreatedDate = func() null.Val[int64] { return m.CreatedDate }
o.CreatedUser = func() null.Val[string] { return m.CreatedUser }
o.GeometryX = func() null.Val[float64] { return m.GeometryX }
@ -3594,6 +3652,9 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization
o.FieldseekerURL = func() null.Val[string] { return m.FieldseekerURL }
ctx := context.Background()
if len(m.R.FieldseekerSyncs) > 0 {
OrganizationMods.AddExistingFieldseekerSyncs(m.R.FieldseekerSyncs...).Apply(ctx, o)
}
if len(m.R.FSContainerrelates) > 0 {
OrganizationMods.AddExistingFSContainerrelates(m.R.FSContainerrelates...).Apply(ctx, o)
}
@ -3832,6 +3893,14 @@ func (f *Factory) FromExistingUser(m *models.User) *UserTemplate {
return o
}
func (f *Factory) ClearBaseFieldseekerSyncMods() {
f.baseFieldseekerSyncMods = nil
}
func (f *Factory) AddBaseFieldseekerSyncMod(mods ...FieldseekerSyncMod) {
f.baseFieldseekerSyncMods = append(f.baseFieldseekerSyncMods, mods...)
}
func (f *Factory) ClearBaseFSContainerrelateMods() {
f.baseFSContainerrelateMods = nil
}

View file

@ -8,6 +8,30 @@ import (
"testing"
)
func TestCreateFieldseekerSync(t *testing.T) {
if testDB == nil {
t.Skip("skipping test, no DSN provided")
}
ctx, cancel := context.WithCancel(t.Context())
t.Cleanup(cancel)
tx, err := testDB.Begin(ctx)
if err != nil {
t.Fatalf("Error starting transaction: %v", err)
}
defer func() {
if err := tx.Rollback(ctx); err != nil {
t.Fatalf("Error rolling back transaction: %v", err)
}
}()
if _, err := New().NewFieldseekerSyncWithContext(ctx).Create(ctx, tx); err != nil {
t.Fatalf("Error creating FieldseekerSync: %v", err)
}
}
func TestCreateFSContainerrelate(t *testing.T) {
if testDB == nil {
t.Skip("skipping test, no DSN provided")

View file

@ -0,0 +1,538 @@
// 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"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/omit"
"github.com/jaswdr/faker/v2"
"github.com/stephenafamo/bob"
)
type FieldseekerSyncMod interface {
Apply(context.Context, *FieldseekerSyncTemplate)
}
type FieldseekerSyncModFunc func(context.Context, *FieldseekerSyncTemplate)
func (f FieldseekerSyncModFunc) Apply(ctx context.Context, n *FieldseekerSyncTemplate) {
f(ctx, n)
}
type FieldseekerSyncModSlice []FieldseekerSyncMod
func (mods FieldseekerSyncModSlice) Apply(ctx context.Context, n *FieldseekerSyncTemplate) {
for _, f := range mods {
f.Apply(ctx, n)
}
}
// FieldseekerSyncTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FieldseekerSyncTemplate struct {
ID func() int32
Created func() time.Time
RecordsCreated func() int32
RecordsUpdated func() int32
RecordsUnchanged func() int32
OrganizationID func() int32
r fieldseekerSyncR
f *Factory
alreadyPersisted bool
}
type fieldseekerSyncR struct {
Organization *fieldseekerSyncROrganizationR
}
type fieldseekerSyncROrganizationR struct {
o *OrganizationTemplate
}
// Apply mods to the FieldseekerSyncTemplate
func (o *FieldseekerSyncTemplate) Apply(ctx context.Context, mods ...FieldseekerSyncMod) {
for _, mod := range mods {
mod.Apply(ctx, o)
}
}
// setModelRels creates and sets the relationships on *models.FieldseekerSync
// according to the relationships in the template. Nothing is inserted into the db
func (t FieldseekerSyncTemplate) setModelRels(o *models.FieldseekerSync) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FieldseekerSyncs = append(rel.R.FieldseekerSyncs, o)
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
// BuildSetter returns an *models.FieldseekerSyncSetter
// this does nothing with the relationship templates
func (o FieldseekerSyncTemplate) BuildSetter() *models.FieldseekerSyncSetter {
m := &models.FieldseekerSyncSetter{}
if o.ID != nil {
val := o.ID()
m.ID = omit.From(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omit.From(val)
}
if o.RecordsCreated != nil {
val := o.RecordsCreated()
m.RecordsCreated = omit.From(val)
}
if o.RecordsUpdated != nil {
val := o.RecordsUpdated()
m.RecordsUpdated = omit.From(val)
}
if o.RecordsUnchanged != nil {
val := o.RecordsUnchanged()
m.RecordsUnchanged = omit.From(val)
}
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omit.From(val)
}
return m
}
// BuildManySetter returns an []*models.FieldseekerSyncSetter
// this does nothing with the relationship templates
func (o FieldseekerSyncTemplate) BuildManySetter(number int) []*models.FieldseekerSyncSetter {
m := make([]*models.FieldseekerSyncSetter, number)
for i := range m {
m[i] = o.BuildSetter()
}
return m
}
// Build returns an *models.FieldseekerSync
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use FieldseekerSyncTemplate.Create
func (o FieldseekerSyncTemplate) Build() *models.FieldseekerSync {
m := &models.FieldseekerSync{}
if o.ID != nil {
m.ID = o.ID()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.RecordsCreated != nil {
m.RecordsCreated = o.RecordsCreated()
}
if o.RecordsUpdated != nil {
m.RecordsUpdated = o.RecordsUpdated()
}
if o.RecordsUnchanged != nil {
m.RecordsUnchanged = o.RecordsUnchanged()
}
if o.OrganizationID != nil {
m.OrganizationID = o.OrganizationID()
}
o.setModelRels(m)
return m
}
// BuildMany returns an models.FieldseekerSyncSlice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use FieldseekerSyncTemplate.CreateMany
func (o FieldseekerSyncTemplate) BuildMany(number int) models.FieldseekerSyncSlice {
m := make(models.FieldseekerSyncSlice, number)
for i := range m {
m[i] = o.Build()
}
return m
}
func ensureCreatableFieldseekerSync(m *models.FieldseekerSyncSetter) {
if !(m.RecordsCreated.IsValue()) {
val := random_int32(nil)
m.RecordsCreated = omit.From(val)
}
if !(m.RecordsUpdated.IsValue()) {
val := random_int32(nil)
m.RecordsUpdated = omit.From(val)
}
if !(m.RecordsUnchanged.IsValue()) {
val := random_int32(nil)
m.RecordsUnchanged = 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.FieldseekerSync
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *FieldseekerSyncTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FieldseekerSync) error {
var err error
return err
}
// Create builds a fieldseekerSync and inserts it into the database
// Relations objects are also inserted and placed in the .R field
func (o *FieldseekerSyncTemplate) Create(ctx context.Context, exec bob.Executor) (*models.FieldseekerSync, error) {
var err error
opt := o.BuildSetter()
ensureCreatableFieldseekerSync(opt)
if o.r.Organization == nil {
FieldseekerSyncMods.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.FieldseekerSyncs.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 fieldseekerSync and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *FieldseekerSyncTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.FieldseekerSync {
m, err := o.Create(ctx, exec)
if err != nil {
panic(err)
}
return m
}
// CreateOrFail builds a fieldseekerSync 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 *FieldseekerSyncTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.FieldseekerSync {
tb.Helper()
m, err := o.Create(ctx, exec)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// CreateMany builds multiple fieldseekerSyncs and inserts them into the database
// Relations objects are also inserted and placed in the .R field
func (o FieldseekerSyncTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.FieldseekerSyncSlice, error) {
var err error
m := make(models.FieldseekerSyncSlice, number)
for i := range m {
m[i], err = o.Create(ctx, exec)
if err != nil {
return nil, err
}
}
return m, nil
}
// MustCreateMany builds multiple fieldseekerSyncs and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o FieldseekerSyncTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.FieldseekerSyncSlice {
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
panic(err)
}
return m
}
// CreateManyOrFail builds multiple fieldseekerSyncs 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 FieldseekerSyncTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.FieldseekerSyncSlice {
tb.Helper()
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// FieldseekerSync has methods that act as mods for the FieldseekerSyncTemplate
var FieldseekerSyncMods fieldseekerSyncMods
type fieldseekerSyncMods struct{}
func (m fieldseekerSyncMods) RandomizeAllColumns(f *faker.Faker) FieldseekerSyncMod {
return FieldseekerSyncModSlice{
FieldseekerSyncMods.RandomID(f),
FieldseekerSyncMods.RandomCreated(f),
FieldseekerSyncMods.RandomRecordsCreated(f),
FieldseekerSyncMods.RandomRecordsUpdated(f),
FieldseekerSyncMods.RandomRecordsUnchanged(f),
FieldseekerSyncMods.RandomOrganizationID(f),
}
}
// Set the model columns to this value
func (m fieldseekerSyncMods) ID(val int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.ID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fieldseekerSyncMods) IDFunc(f func() int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.ID = f
})
}
// Clear any values for the column
func (m fieldseekerSyncMods) UnsetID() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
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 fieldseekerSyncMods) RandomID(f *faker.Faker) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.ID = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m fieldseekerSyncMods) Created(val time.Time) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.Created = func() time.Time { return val }
})
}
// Set the Column from the function
func (m fieldseekerSyncMods) CreatedFunc(f func() time.Time) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m fieldseekerSyncMods) UnsetCreated() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.Created = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerSyncMods) RandomCreated(f *faker.Faker) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.Created = func() time.Time {
return random_time_Time(f)
}
})
}
// Set the model columns to this value
func (m fieldseekerSyncMods) RecordsCreated(val int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsCreated = func() int32 { return val }
})
}
// Set the Column from the function
func (m fieldseekerSyncMods) RecordsCreatedFunc(f func() int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsCreated = f
})
}
// Clear any values for the column
func (m fieldseekerSyncMods) UnsetRecordsCreated() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsCreated = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerSyncMods) RandomRecordsCreated(f *faker.Faker) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsCreated = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m fieldseekerSyncMods) RecordsUpdated(val int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUpdated = func() int32 { return val }
})
}
// Set the Column from the function
func (m fieldseekerSyncMods) RecordsUpdatedFunc(f func() int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUpdated = f
})
}
// Clear any values for the column
func (m fieldseekerSyncMods) UnsetRecordsUpdated() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUpdated = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerSyncMods) RandomRecordsUpdated(f *faker.Faker) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUpdated = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m fieldseekerSyncMods) RecordsUnchanged(val int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUnchanged = func() int32 { return val }
})
}
// Set the Column from the function
func (m fieldseekerSyncMods) RecordsUnchangedFunc(f func() int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUnchanged = f
})
}
// Clear any values for the column
func (m fieldseekerSyncMods) UnsetRecordsUnchanged() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUnchanged = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerSyncMods) RandomRecordsUnchanged(f *faker.Faker) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.RecordsUnchanged = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m fieldseekerSyncMods) OrganizationID(val int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fieldseekerSyncMods) OrganizationIDFunc(f func() int32) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.OrganizationID = f
})
}
// Clear any values for the column
func (m fieldseekerSyncMods) UnsetOrganizationID() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
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 fieldseekerSyncMods) RandomOrganizationID(f *faker.Faker) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(_ context.Context, o *FieldseekerSyncTemplate) {
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
func (m fieldseekerSyncMods) WithParentsCascading() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(ctx context.Context, o *FieldseekerSyncTemplate) {
if isDone, _ := fieldseekerSyncWithParentsCascadingCtx.Value(ctx); isDone {
return
}
ctx = fieldseekerSyncWithParentsCascadingCtx.WithValue(ctx, true)
{
related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading())
m.WithOrganization(related).Apply(ctx, o)
}
})
}
func (m fieldseekerSyncMods) WithOrganization(rel *OrganizationTemplate) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(ctx context.Context, o *FieldseekerSyncTemplate) {
o.r.Organization = &fieldseekerSyncROrganizationR{
o: rel,
}
})
}
func (m fieldseekerSyncMods) WithNewOrganization(mods ...OrganizationMod) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(ctx context.Context, o *FieldseekerSyncTemplate) {
related := o.f.NewOrganizationWithContext(ctx, mods...)
m.WithOrganization(related).Apply(ctx, o)
})
}
func (m fieldseekerSyncMods) WithExistingOrganization(em *models.Organization) FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(ctx context.Context, o *FieldseekerSyncTemplate) {
o.r.Organization = &fieldseekerSyncROrganizationR{
o: o.f.FromExistingOrganization(em),
}
})
}
func (m fieldseekerSyncMods) WithoutOrganization() FieldseekerSyncMod {
return FieldseekerSyncModFunc(func(ctx context.Context, o *FieldseekerSyncTemplate) {
o.r.Organization = nil
})
}

View file

@ -37,7 +37,7 @@ func (mods FSContainerrelateModSlice) Apply(ctx context.Context, n *FSContainerr
// FSContainerrelateTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSContainerrelateTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Containertype func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -83,7 +83,7 @@ func (t FSContainerrelateTemplate) setModelRels(o *models.FSContainerrelate) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSContainerrelates = append(rel.R.FSContainerrelates, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -95,7 +95,7 @@ func (o FSContainerrelateTemplate) BuildSetter() *models.FSContainerrelateSetter
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Containertype != nil {
val := o.Containertype()
@ -261,6 +261,10 @@ func (o FSContainerrelateTemplate) BuildMany(number int) models.FSContainerrelat
}
func ensureCreatableFSContainerrelate(m *models.FSContainerrelateSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -273,25 +277,6 @@ func ensureCreatableFSContainerrelate(m *models.FSContainerrelateSetter) {
func (o *FSContainerrelateTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSContainerrelate) error {
var err error
isOrganizationDone, _ := fsContainerrelateRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsContainerrelateRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -302,11 +287,30 @@ func (o *FSContainerrelateTemplate) Create(ctx context.Context, exec bob.Executo
opt := o.BuildSetter()
ensureCreatableFSContainerrelate(opt)
if o.r.Organization == nil {
FSContainerrelateMods.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.FSContainerrelates.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
}
@ -406,14 +410,14 @@ func (m fsContainerrelateMods) RandomizeAllColumns(f *faker.Faker) FSContainerre
}
// Set the model columns to this value
func (m fsContainerrelateMods) OrganizationID(val null.Val[int32]) FSContainerrelateMod {
func (m fsContainerrelateMods) OrganizationID(val int32) FSContainerrelateMod {
return FSContainerrelateModFunc(func(_ context.Context, o *FSContainerrelateTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsContainerrelateMods) OrganizationIDFunc(f func() null.Val[int32]) FSContainerrelateMod {
func (m fsContainerrelateMods) OrganizationIDFunc(f func() int32) FSContainerrelateMod {
return FSContainerrelateModFunc(func(_ context.Context, o *FSContainerrelateTemplate) {
o.OrganizationID = f
})
@ -428,32 +432,10 @@ func (m fsContainerrelateMods) UnsetOrganizationID() FSContainerrelateMod {
// 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 fsContainerrelateMods) RandomOrganizationID(f *faker.Faker) FSContainerrelateMod {
return FSContainerrelateModFunc(func(_ context.Context, o *FSContainerrelateTemplate) {
o.OrganizationID = 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 fsContainerrelateMods) RandomOrganizationIDNotNull(f *faker.Faker) FSContainerrelateMod {
return FSContainerrelateModFunc(func(_ context.Context, o *FSContainerrelateTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSFieldscoutinglogModSlice) Apply(ctx context.Context, n *FSFieldscou
// FSFieldscoutinglogTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSFieldscoutinglogTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -80,7 +80,7 @@ func (t FSFieldscoutinglogTemplate) setModelRels(o *models.FSFieldscoutinglog) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSFieldscoutinglogs = append(rel.R.FSFieldscoutinglogs, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -92,7 +92,7 @@ func (o FSFieldscoutinglogTemplate) BuildSetter() *models.FSFieldscoutinglogSett
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -237,6 +237,10 @@ func (o FSFieldscoutinglogTemplate) BuildMany(number int) models.FSFieldscouting
}
func ensureCreatableFSFieldscoutinglog(m *models.FSFieldscoutinglogSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -249,25 +253,6 @@ func ensureCreatableFSFieldscoutinglog(m *models.FSFieldscoutinglogSetter) {
func (o *FSFieldscoutinglogTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSFieldscoutinglog) error {
var err error
isOrganizationDone, _ := fsFieldscoutinglogRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsFieldscoutinglogRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -278,11 +263,30 @@ func (o *FSFieldscoutinglogTemplate) Create(ctx context.Context, exec bob.Execut
opt := o.BuildSetter()
ensureCreatableFSFieldscoutinglog(opt)
if o.r.Organization == nil {
FSFieldscoutinglogMods.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.FSFieldscoutinglogs.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
}
@ -379,14 +383,14 @@ func (m fsFieldscoutinglogMods) RandomizeAllColumns(f *faker.Faker) FSFieldscout
}
// Set the model columns to this value
func (m fsFieldscoutinglogMods) OrganizationID(val null.Val[int32]) FSFieldscoutinglogMod {
func (m fsFieldscoutinglogMods) OrganizationID(val int32) FSFieldscoutinglogMod {
return FSFieldscoutinglogModFunc(func(_ context.Context, o *FSFieldscoutinglogTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsFieldscoutinglogMods) OrganizationIDFunc(f func() null.Val[int32]) FSFieldscoutinglogMod {
func (m fsFieldscoutinglogMods) OrganizationIDFunc(f func() int32) FSFieldscoutinglogMod {
return FSFieldscoutinglogModFunc(func(_ context.Context, o *FSFieldscoutinglogTemplate) {
o.OrganizationID = f
})
@ -401,32 +405,10 @@ func (m fsFieldscoutinglogMods) UnsetOrganizationID() FSFieldscoutinglogMod {
// 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 fsFieldscoutinglogMods) RandomOrganizationID(f *faker.Faker) FSFieldscoutinglogMod {
return FSFieldscoutinglogModFunc(func(_ context.Context, o *FSFieldscoutinglogTemplate) {
o.OrganizationID = 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 fsFieldscoutinglogMods) RandomOrganizationIDNotNull(f *faker.Faker) FSFieldscoutinglogMod {
return FSFieldscoutinglogModFunc(func(_ context.Context, o *FSFieldscoutinglogTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSHabitatrelateModSlice) Apply(ctx context.Context, n *FSHabitatrelat
// FSHabitatrelateTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSHabitatrelateTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -81,7 +81,7 @@ func (t FSHabitatrelateTemplate) setModelRels(o *models.FSHabitatrelate) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSHabitatrelates = append(rel.R.FSHabitatrelates, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -93,7 +93,7 @@ func (o FSHabitatrelateTemplate) BuildSetter() *models.FSHabitatrelateSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -245,6 +245,10 @@ func (o FSHabitatrelateTemplate) BuildMany(number int) models.FSHabitatrelateSli
}
func ensureCreatableFSHabitatrelate(m *models.FSHabitatrelateSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -257,25 +261,6 @@ func ensureCreatableFSHabitatrelate(m *models.FSHabitatrelateSetter) {
func (o *FSHabitatrelateTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSHabitatrelate) error {
var err error
isOrganizationDone, _ := fsHabitatrelateRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsHabitatrelateRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -286,11 +271,30 @@ func (o *FSHabitatrelateTemplate) Create(ctx context.Context, exec bob.Executor)
opt := o.BuildSetter()
ensureCreatableFSHabitatrelate(opt)
if o.r.Organization == nil {
FSHabitatrelateMods.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.FSHabitatrelates.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
}
@ -388,14 +392,14 @@ func (m fsHabitatrelateMods) RandomizeAllColumns(f *faker.Faker) FSHabitatrelate
}
// Set the model columns to this value
func (m fsHabitatrelateMods) OrganizationID(val null.Val[int32]) FSHabitatrelateMod {
func (m fsHabitatrelateMods) OrganizationID(val int32) FSHabitatrelateMod {
return FSHabitatrelateModFunc(func(_ context.Context, o *FSHabitatrelateTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsHabitatrelateMods) OrganizationIDFunc(f func() null.Val[int32]) FSHabitatrelateMod {
func (m fsHabitatrelateMods) OrganizationIDFunc(f func() int32) FSHabitatrelateMod {
return FSHabitatrelateModFunc(func(_ context.Context, o *FSHabitatrelateTemplate) {
o.OrganizationID = f
})
@ -410,32 +414,10 @@ func (m fsHabitatrelateMods) UnsetOrganizationID() FSHabitatrelateMod {
// 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 fsHabitatrelateMods) RandomOrganizationID(f *faker.Faker) FSHabitatrelateMod {
return FSHabitatrelateModFunc(func(_ context.Context, o *FSHabitatrelateTemplate) {
o.OrganizationID = 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 fsHabitatrelateMods) RandomOrganizationIDNotNull(f *faker.Faker) FSHabitatrelateMod {
return FSHabitatrelateModFunc(func(_ context.Context, o *FSHabitatrelateTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSInspectionsampleModSlice) Apply(ctx context.Context, n *FSInspectio
// FSInspectionsampleTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSInspectionsampleTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -83,7 +83,7 @@ func (t FSInspectionsampleTemplate) setModelRels(o *models.FSInspectionsample) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSInspectionsamples = append(rel.R.FSInspectionsamples, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -95,7 +95,7 @@ func (o FSInspectionsampleTemplate) BuildSetter() *models.FSInspectionsampleSett
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -261,6 +261,10 @@ func (o FSInspectionsampleTemplate) BuildMany(number int) models.FSInspectionsam
}
func ensureCreatableFSInspectionsample(m *models.FSInspectionsampleSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -273,25 +277,6 @@ func ensureCreatableFSInspectionsample(m *models.FSInspectionsampleSetter) {
func (o *FSInspectionsampleTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSInspectionsample) error {
var err error
isOrganizationDone, _ := fsInspectionsampleRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsInspectionsampleRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -302,11 +287,30 @@ func (o *FSInspectionsampleTemplate) Create(ctx context.Context, exec bob.Execut
opt := o.BuildSetter()
ensureCreatableFSInspectionsample(opt)
if o.r.Organization == nil {
FSInspectionsampleMods.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.FSInspectionsamples.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
}
@ -406,14 +410,14 @@ func (m fsInspectionsampleMods) RandomizeAllColumns(f *faker.Faker) FSInspection
}
// Set the model columns to this value
func (m fsInspectionsampleMods) OrganizationID(val null.Val[int32]) FSInspectionsampleMod {
func (m fsInspectionsampleMods) OrganizationID(val int32) FSInspectionsampleMod {
return FSInspectionsampleModFunc(func(_ context.Context, o *FSInspectionsampleTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsInspectionsampleMods) OrganizationIDFunc(f func() null.Val[int32]) FSInspectionsampleMod {
func (m fsInspectionsampleMods) OrganizationIDFunc(f func() int32) FSInspectionsampleMod {
return FSInspectionsampleModFunc(func(_ context.Context, o *FSInspectionsampleTemplate) {
o.OrganizationID = f
})
@ -428,32 +432,10 @@ func (m fsInspectionsampleMods) UnsetOrganizationID() FSInspectionsampleMod {
// 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 fsInspectionsampleMods) RandomOrganizationID(f *faker.Faker) FSInspectionsampleMod {
return FSInspectionsampleModFunc(func(_ context.Context, o *FSInspectionsampleTemplate) {
o.OrganizationID = 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 fsInspectionsampleMods) RandomOrganizationIDNotNull(f *faker.Faker) FSInspectionsampleMod {
return FSInspectionsampleModFunc(func(_ context.Context, o *FSInspectionsampleTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSInspectionsampledetailModSlice) Apply(ctx context.Context, n *FSIns
// FSInspectionsampledetailTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSInspectionsampledetailTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -94,7 +94,7 @@ func (t FSInspectionsampledetailTemplate) setModelRels(o *models.FSInspectionsam
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSInspectionsampledetails = append(rel.R.FSInspectionsampledetails, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -106,7 +106,7 @@ func (o FSInspectionsampledetailTemplate) BuildSetter() *models.FSInspectionsamp
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Comments != nil {
val := o.Comments()
@ -349,6 +349,10 @@ func (o FSInspectionsampledetailTemplate) BuildMany(number int) models.FSInspect
}
func ensureCreatableFSInspectionsampledetail(m *models.FSInspectionsampledetailSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -361,25 +365,6 @@ func ensureCreatableFSInspectionsampledetail(m *models.FSInspectionsampledetailS
func (o *FSInspectionsampledetailTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSInspectionsampledetail) error {
var err error
isOrganizationDone, _ := fsInspectionsampledetailRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsInspectionsampledetailRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -390,11 +375,30 @@ func (o *FSInspectionsampledetailTemplate) Create(ctx context.Context, exec bob.
opt := o.BuildSetter()
ensureCreatableFSInspectionsampledetail(opt)
if o.r.Organization == nil {
FSInspectionsampledetailMods.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.FSInspectionsampledetails.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
}
@ -505,14 +509,14 @@ func (m fsInspectionsampledetailMods) RandomizeAllColumns(f *faker.Faker) FSInsp
}
// Set the model columns to this value
func (m fsInspectionsampledetailMods) OrganizationID(val null.Val[int32]) FSInspectionsampledetailMod {
func (m fsInspectionsampledetailMods) OrganizationID(val int32) FSInspectionsampledetailMod {
return FSInspectionsampledetailModFunc(func(_ context.Context, o *FSInspectionsampledetailTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsInspectionsampledetailMods) OrganizationIDFunc(f func() null.Val[int32]) FSInspectionsampledetailMod {
func (m fsInspectionsampledetailMods) OrganizationIDFunc(f func() int32) FSInspectionsampledetailMod {
return FSInspectionsampledetailModFunc(func(_ context.Context, o *FSInspectionsampledetailTemplate) {
o.OrganizationID = f
})
@ -527,32 +531,10 @@ func (m fsInspectionsampledetailMods) UnsetOrganizationID() FSInspectionsamplede
// 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 fsInspectionsampledetailMods) RandomOrganizationID(f *faker.Faker) FSInspectionsampledetailMod {
return FSInspectionsampledetailModFunc(func(_ context.Context, o *FSInspectionsampledetailTemplate) {
o.OrganizationID = 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 fsInspectionsampledetailMods) RandomOrganizationIDNotNull(f *faker.Faker) FSInspectionsampledetailMod {
return FSInspectionsampledetailModFunc(func(_ context.Context, o *FSInspectionsampledetailTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSLinelocationModSlice) Apply(ctx context.Context, n *FSLinelocationT
// FSLinelocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSLinelocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Acres func() null.Val[float64]
Active func() null.Val[int16]
@ -117,7 +117,7 @@ func (t FSLinelocationTemplate) setModelRels(o *models.FSLinelocation) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSLinelocations = append(rel.R.FSLinelocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -129,7 +129,7 @@ func (o FSLinelocationTemplate) BuildSetter() *models.FSLinelocationSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -533,6 +533,10 @@ func (o FSLinelocationTemplate) BuildMany(number int) models.FSLinelocationSlice
}
func ensureCreatableFSLinelocation(m *models.FSLinelocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -545,25 +549,6 @@ func ensureCreatableFSLinelocation(m *models.FSLinelocationSetter) {
func (o *FSLinelocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSLinelocation) error {
var err error
isOrganizationDone, _ := fsLinelocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsLinelocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -574,11 +559,30 @@ func (o *FSLinelocationTemplate) Create(ctx context.Context, exec bob.Executor)
opt := o.BuildSetter()
ensureCreatableFSLinelocation(opt)
if o.r.Organization == nil {
FSLinelocationMods.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.FSLinelocations.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
}
@ -712,14 +716,14 @@ func (m fsLinelocationMods) RandomizeAllColumns(f *faker.Faker) FSLinelocationMo
}
// Set the model columns to this value
func (m fsLinelocationMods) OrganizationID(val null.Val[int32]) FSLinelocationMod {
func (m fsLinelocationMods) OrganizationID(val int32) FSLinelocationMod {
return FSLinelocationModFunc(func(_ context.Context, o *FSLinelocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsLinelocationMods) OrganizationIDFunc(f func() null.Val[int32]) FSLinelocationMod {
func (m fsLinelocationMods) OrganizationIDFunc(f func() int32) FSLinelocationMod {
return FSLinelocationModFunc(func(_ context.Context, o *FSLinelocationTemplate) {
o.OrganizationID = f
})
@ -734,32 +738,10 @@ func (m fsLinelocationMods) UnsetOrganizationID() FSLinelocationMod {
// 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 fsLinelocationMods) RandomOrganizationID(f *faker.Faker) FSLinelocationMod {
return FSLinelocationModFunc(func(_ context.Context, o *FSLinelocationTemplate) {
o.OrganizationID = 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 fsLinelocationMods) RandomOrganizationIDNotNull(f *faker.Faker) FSLinelocationMod {
return FSLinelocationModFunc(func(_ context.Context, o *FSLinelocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSLocationtrackingModSlice) Apply(ctx context.Context, n *FSLocationt
// FSLocationtrackingTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSLocationtrackingTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accuracy func() null.Val[float64]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -81,7 +81,7 @@ func (t FSLocationtrackingTemplate) setModelRels(o *models.FSLocationtracking) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSLocationtrackings = append(rel.R.FSLocationtrackings, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -93,7 +93,7 @@ func (o FSLocationtrackingTemplate) BuildSetter() *models.FSLocationtrackingSett
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accuracy != nil {
val := o.Accuracy()
@ -245,6 +245,10 @@ func (o FSLocationtrackingTemplate) BuildMany(number int) models.FSLocationtrack
}
func ensureCreatableFSLocationtracking(m *models.FSLocationtrackingSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -257,25 +261,6 @@ func ensureCreatableFSLocationtracking(m *models.FSLocationtrackingSetter) {
func (o *FSLocationtrackingTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSLocationtracking) error {
var err error
isOrganizationDone, _ := fsLocationtrackingRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsLocationtrackingRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -286,11 +271,30 @@ func (o *FSLocationtrackingTemplate) Create(ctx context.Context, exec bob.Execut
opt := o.BuildSetter()
ensureCreatableFSLocationtracking(opt)
if o.r.Organization == nil {
FSLocationtrackingMods.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.FSLocationtrackings.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
}
@ -388,14 +392,14 @@ func (m fsLocationtrackingMods) RandomizeAllColumns(f *faker.Faker) FSLocationtr
}
// Set the model columns to this value
func (m fsLocationtrackingMods) OrganizationID(val null.Val[int32]) FSLocationtrackingMod {
func (m fsLocationtrackingMods) OrganizationID(val int32) FSLocationtrackingMod {
return FSLocationtrackingModFunc(func(_ context.Context, o *FSLocationtrackingTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsLocationtrackingMods) OrganizationIDFunc(f func() null.Val[int32]) FSLocationtrackingMod {
func (m fsLocationtrackingMods) OrganizationIDFunc(f func() int32) FSLocationtrackingMod {
return FSLocationtrackingModFunc(func(_ context.Context, o *FSLocationtrackingTemplate) {
o.OrganizationID = f
})
@ -410,32 +414,10 @@ func (m fsLocationtrackingMods) UnsetOrganizationID() FSLocationtrackingMod {
// 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 fsLocationtrackingMods) RandomOrganizationID(f *faker.Faker) FSLocationtrackingMod {
return FSLocationtrackingModFunc(func(_ context.Context, o *FSLocationtrackingTemplate) {
o.OrganizationID = 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 fsLocationtrackingMods) RandomOrganizationIDNotNull(f *faker.Faker) FSLocationtrackingMod {
return FSLocationtrackingModFunc(func(_ context.Context, o *FSLocationtrackingTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSMosquitoinspectionModSlice) Apply(ctx context.Context, n *FSMosquit
// FSMosquitoinspectionTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSMosquitoinspectionTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Actiontaken func() null.Val[string]
Activity func() null.Val[string]
Adultact func() null.Val[string]
@ -126,7 +126,7 @@ func (t FSMosquitoinspectionTemplate) setModelRels(o *models.FSMosquitoinspectio
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSMosquitoinspections = append(rel.R.FSMosquitoinspections, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -138,7 +138,7 @@ func (o FSMosquitoinspectionTemplate) BuildSetter() *models.FSMosquitoinspection
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Actiontaken != nil {
val := o.Actiontaken()
@ -605,6 +605,10 @@ func (o FSMosquitoinspectionTemplate) BuildMany(number int) models.FSMosquitoins
}
func ensureCreatableFSMosquitoinspection(m *models.FSMosquitoinspectionSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -617,25 +621,6 @@ func ensureCreatableFSMosquitoinspection(m *models.FSMosquitoinspectionSetter) {
func (o *FSMosquitoinspectionTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSMosquitoinspection) error {
var err error
isOrganizationDone, _ := fsMosquitoinspectionRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsMosquitoinspectionRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -646,11 +631,30 @@ func (o *FSMosquitoinspectionTemplate) Create(ctx context.Context, exec bob.Exec
opt := o.BuildSetter()
ensureCreatableFSMosquitoinspection(opt)
if o.r.Organization == nil {
FSMosquitoinspectionMods.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.FSMosquitoinspections.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
}
@ -793,14 +797,14 @@ func (m fsMosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) FSMosquito
}
// Set the model columns to this value
func (m fsMosquitoinspectionMods) OrganizationID(val null.Val[int32]) FSMosquitoinspectionMod {
func (m fsMosquitoinspectionMods) OrganizationID(val int32) FSMosquitoinspectionMod {
return FSMosquitoinspectionModFunc(func(_ context.Context, o *FSMosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsMosquitoinspectionMods) OrganizationIDFunc(f func() null.Val[int32]) FSMosquitoinspectionMod {
func (m fsMosquitoinspectionMods) OrganizationIDFunc(f func() int32) FSMosquitoinspectionMod {
return FSMosquitoinspectionModFunc(func(_ context.Context, o *FSMosquitoinspectionTemplate) {
o.OrganizationID = f
})
@ -815,32 +819,10 @@ func (m fsMosquitoinspectionMods) UnsetOrganizationID() FSMosquitoinspectionMod
// 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 fsMosquitoinspectionMods) RandomOrganizationID(f *faker.Faker) FSMosquitoinspectionMod {
return FSMosquitoinspectionModFunc(func(_ context.Context, o *FSMosquitoinspectionTemplate) {
o.OrganizationID = 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 fsMosquitoinspectionMods) RandomOrganizationIDNotNull(f *faker.Faker) FSMosquitoinspectionMod {
return FSMosquitoinspectionModFunc(func(_ context.Context, o *FSMosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSPointlocationModSlice) Apply(ctx context.Context, n *FSPointlocatio
// FSPointlocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSPointlocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -113,7 +113,7 @@ func (t FSPointlocationTemplate) setModelRels(o *models.FSPointlocation) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSPointlocations = append(rel.R.FSPointlocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -125,7 +125,7 @@ func (o FSPointlocationTemplate) BuildSetter() *models.FSPointlocationSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -501,6 +501,10 @@ func (o FSPointlocationTemplate) BuildMany(number int) models.FSPointlocationSli
}
func ensureCreatableFSPointlocation(m *models.FSPointlocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -513,25 +517,6 @@ func ensureCreatableFSPointlocation(m *models.FSPointlocationSetter) {
func (o *FSPointlocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSPointlocation) error {
var err error
isOrganizationDone, _ := fsPointlocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsPointlocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -542,11 +527,30 @@ func (o *FSPointlocationTemplate) Create(ctx context.Context, exec bob.Executor)
opt := o.BuildSetter()
ensureCreatableFSPointlocation(opt)
if o.r.Organization == nil {
FSPointlocationMods.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.FSPointlocations.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
}
@ -676,14 +680,14 @@ func (m fsPointlocationMods) RandomizeAllColumns(f *faker.Faker) FSPointlocation
}
// Set the model columns to this value
func (m fsPointlocationMods) OrganizationID(val null.Val[int32]) FSPointlocationMod {
func (m fsPointlocationMods) OrganizationID(val int32) FSPointlocationMod {
return FSPointlocationModFunc(func(_ context.Context, o *FSPointlocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsPointlocationMods) OrganizationIDFunc(f func() null.Val[int32]) FSPointlocationMod {
func (m fsPointlocationMods) OrganizationIDFunc(f func() int32) FSPointlocationMod {
return FSPointlocationModFunc(func(_ context.Context, o *FSPointlocationTemplate) {
o.OrganizationID = f
})
@ -698,32 +702,10 @@ func (m fsPointlocationMods) UnsetOrganizationID() FSPointlocationMod {
// 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 fsPointlocationMods) RandomOrganizationID(f *faker.Faker) FSPointlocationMod {
return FSPointlocationModFunc(func(_ context.Context, o *FSPointlocationTemplate) {
o.OrganizationID = 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 fsPointlocationMods) RandomOrganizationIDNotNull(f *faker.Faker) FSPointlocationMod {
return FSPointlocationModFunc(func(_ context.Context, o *FSPointlocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSPolygonlocationModSlice) Apply(ctx context.Context, n *FSPolygonloc
// FSPolygonlocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSPolygonlocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Acres func() null.Val[float64]
Active func() null.Val[int16]
@ -111,7 +111,7 @@ func (t FSPolygonlocationTemplate) setModelRels(o *models.FSPolygonlocation) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSPolygonlocations = append(rel.R.FSPolygonlocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -123,7 +123,7 @@ func (o FSPolygonlocationTemplate) BuildSetter() *models.FSPolygonlocationSetter
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -485,6 +485,10 @@ func (o FSPolygonlocationTemplate) BuildMany(number int) models.FSPolygonlocatio
}
func ensureCreatableFSPolygonlocation(m *models.FSPolygonlocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -497,25 +501,6 @@ func ensureCreatableFSPolygonlocation(m *models.FSPolygonlocationSetter) {
func (o *FSPolygonlocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSPolygonlocation) error {
var err error
isOrganizationDone, _ := fsPolygonlocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsPolygonlocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -526,11 +511,30 @@ func (o *FSPolygonlocationTemplate) Create(ctx context.Context, exec bob.Executo
opt := o.BuildSetter()
ensureCreatableFSPolygonlocation(opt)
if o.r.Organization == nil {
FSPolygonlocationMods.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.FSPolygonlocations.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
}
@ -658,14 +662,14 @@ func (m fsPolygonlocationMods) RandomizeAllColumns(f *faker.Faker) FSPolygonloca
}
// Set the model columns to this value
func (m fsPolygonlocationMods) OrganizationID(val null.Val[int32]) FSPolygonlocationMod {
func (m fsPolygonlocationMods) OrganizationID(val int32) FSPolygonlocationMod {
return FSPolygonlocationModFunc(func(_ context.Context, o *FSPolygonlocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsPolygonlocationMods) OrganizationIDFunc(f func() null.Val[int32]) FSPolygonlocationMod {
func (m fsPolygonlocationMods) OrganizationIDFunc(f func() int32) FSPolygonlocationMod {
return FSPolygonlocationModFunc(func(_ context.Context, o *FSPolygonlocationTemplate) {
o.OrganizationID = f
})
@ -680,32 +684,10 @@ func (m fsPolygonlocationMods) UnsetOrganizationID() FSPolygonlocationMod {
// 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 fsPolygonlocationMods) RandomOrganizationID(f *faker.Faker) FSPolygonlocationMod {
return FSPolygonlocationModFunc(func(_ context.Context, o *FSPolygonlocationTemplate) {
o.OrganizationID = 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 fsPolygonlocationMods) RandomOrganizationIDNotNull(f *faker.Faker) FSPolygonlocationMod {
return FSPolygonlocationModFunc(func(_ context.Context, o *FSPolygonlocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSPoolModSlice) Apply(ctx context.Context, n *FSPoolTemplate) {
// FSPoolTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSPoolTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -97,7 +97,7 @@ func (t FSPoolTemplate) setModelRels(o *models.FSPool) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSPools = append(rel.R.FSPools, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -109,7 +109,7 @@ func (o FSPoolTemplate) BuildSetter() *models.FSPoolSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Comments != nil {
val := o.Comments()
@ -373,6 +373,10 @@ func (o FSPoolTemplate) BuildMany(number int) models.FSPoolSlice {
}
func ensureCreatableFSPool(m *models.FSPoolSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -385,25 +389,6 @@ func ensureCreatableFSPool(m *models.FSPoolSetter) {
func (o *FSPoolTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSPool) error {
var err error
isOrganizationDone, _ := fsPoolRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsPoolRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -414,11 +399,30 @@ func (o *FSPoolTemplate) Create(ctx context.Context, exec bob.Executor) (*models
opt := o.BuildSetter()
ensureCreatableFSPool(opt)
if o.r.Organization == nil {
FSPoolMods.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.FSPools.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
}
@ -532,14 +536,14 @@ func (m fsPoolMods) RandomizeAllColumns(f *faker.Faker) FSPoolMod {
}
// Set the model columns to this value
func (m fsPoolMods) OrganizationID(val null.Val[int32]) FSPoolMod {
func (m fsPoolMods) OrganizationID(val int32) FSPoolMod {
return FSPoolModFunc(func(_ context.Context, o *FSPoolTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsPoolMods) OrganizationIDFunc(f func() null.Val[int32]) FSPoolMod {
func (m fsPoolMods) OrganizationIDFunc(f func() int32) FSPoolMod {
return FSPoolModFunc(func(_ context.Context, o *FSPoolTemplate) {
o.OrganizationID = f
})
@ -554,32 +558,10 @@ func (m fsPoolMods) UnsetOrganizationID() FSPoolMod {
// 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 fsPoolMods) RandomOrganizationID(f *faker.Faker) FSPoolMod {
return FSPoolModFunc(func(_ context.Context, o *FSPoolTemplate) {
o.OrganizationID = 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 fsPoolMods) RandomOrganizationIDNotNull(f *faker.Faker) FSPoolMod {
return FSPoolModFunc(func(_ context.Context, o *FSPoolTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSPooldetailModSlice) Apply(ctx context.Context, n *FSPooldetailTempl
// FSPooldetailTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSPooldetailTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -83,7 +83,7 @@ func (t FSPooldetailTemplate) setModelRels(o *models.FSPooldetail) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSPooldetails = append(rel.R.FSPooldetails, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -95,7 +95,7 @@ func (o FSPooldetailTemplate) BuildSetter() *models.FSPooldetailSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -261,6 +261,10 @@ func (o FSPooldetailTemplate) BuildMany(number int) models.FSPooldetailSlice {
}
func ensureCreatableFSPooldetail(m *models.FSPooldetailSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -273,25 +277,6 @@ func ensureCreatableFSPooldetail(m *models.FSPooldetailSetter) {
func (o *FSPooldetailTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSPooldetail) error {
var err error
isOrganizationDone, _ := fsPooldetailRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsPooldetailRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -302,11 +287,30 @@ func (o *FSPooldetailTemplate) Create(ctx context.Context, exec bob.Executor) (*
opt := o.BuildSetter()
ensureCreatableFSPooldetail(opt)
if o.r.Organization == nil {
FSPooldetailMods.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.FSPooldetails.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
}
@ -406,14 +410,14 @@ func (m fsPooldetailMods) RandomizeAllColumns(f *faker.Faker) FSPooldetailMod {
}
// Set the model columns to this value
func (m fsPooldetailMods) OrganizationID(val null.Val[int32]) FSPooldetailMod {
func (m fsPooldetailMods) OrganizationID(val int32) FSPooldetailMod {
return FSPooldetailModFunc(func(_ context.Context, o *FSPooldetailTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsPooldetailMods) OrganizationIDFunc(f func() null.Val[int32]) FSPooldetailMod {
func (m fsPooldetailMods) OrganizationIDFunc(f func() int32) FSPooldetailMod {
return FSPooldetailModFunc(func(_ context.Context, o *FSPooldetailTemplate) {
o.OrganizationID = f
})
@ -428,32 +432,10 @@ func (m fsPooldetailMods) UnsetOrganizationID() FSPooldetailMod {
// 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 fsPooldetailMods) RandomOrganizationID(f *faker.Faker) FSPooldetailMod {
return FSPooldetailModFunc(func(_ context.Context, o *FSPooldetailTemplate) {
o.OrganizationID = 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 fsPooldetailMods) RandomOrganizationIDNotNull(f *faker.Faker) FSPooldetailMod {
return FSPooldetailModFunc(func(_ context.Context, o *FSPooldetailTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSProposedtreatmentareaModSlice) Apply(ctx context.Context, n *FSProp
// FSProposedtreatmentareaTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSProposedtreatmentareaTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Acres func() null.Val[float64]
Comments func() null.Val[string]
Completed func() null.Val[int16]
@ -102,7 +102,7 @@ func (t FSProposedtreatmentareaTemplate) setModelRels(o *models.FSProposedtreatm
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSProposedtreatmentareas = append(rel.R.FSProposedtreatmentareas, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -114,7 +114,7 @@ func (o FSProposedtreatmentareaTemplate) BuildSetter() *models.FSProposedtreatme
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Acres != nil {
val := o.Acres()
@ -413,6 +413,10 @@ func (o FSProposedtreatmentareaTemplate) BuildMany(number int) models.FSProposed
}
func ensureCreatableFSProposedtreatmentarea(m *models.FSProposedtreatmentareaSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -425,25 +429,6 @@ func ensureCreatableFSProposedtreatmentarea(m *models.FSProposedtreatmentareaSet
func (o *FSProposedtreatmentareaTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSProposedtreatmentarea) error {
var err error
isOrganizationDone, _ := fsProposedtreatmentareaRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsProposedtreatmentareaRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -454,11 +439,30 @@ func (o *FSProposedtreatmentareaTemplate) Create(ctx context.Context, exec bob.E
opt := o.BuildSetter()
ensureCreatableFSProposedtreatmentarea(opt)
if o.r.Organization == nil {
FSProposedtreatmentareaMods.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.FSProposedtreatmentareas.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
}
@ -577,14 +581,14 @@ func (m fsProposedtreatmentareaMods) RandomizeAllColumns(f *faker.Faker) FSPropo
}
// Set the model columns to this value
func (m fsProposedtreatmentareaMods) OrganizationID(val null.Val[int32]) FSProposedtreatmentareaMod {
func (m fsProposedtreatmentareaMods) OrganizationID(val int32) FSProposedtreatmentareaMod {
return FSProposedtreatmentareaModFunc(func(_ context.Context, o *FSProposedtreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsProposedtreatmentareaMods) OrganizationIDFunc(f func() null.Val[int32]) FSProposedtreatmentareaMod {
func (m fsProposedtreatmentareaMods) OrganizationIDFunc(f func() int32) FSProposedtreatmentareaMod {
return FSProposedtreatmentareaModFunc(func(_ context.Context, o *FSProposedtreatmentareaTemplate) {
o.OrganizationID = f
})
@ -599,32 +603,10 @@ func (m fsProposedtreatmentareaMods) UnsetOrganizationID() FSProposedtreatmentar
// 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 fsProposedtreatmentareaMods) RandomOrganizationID(f *faker.Faker) FSProposedtreatmentareaMod {
return FSProposedtreatmentareaModFunc(func(_ context.Context, o *FSProposedtreatmentareaTemplate) {
o.OrganizationID = 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 fsProposedtreatmentareaMods) RandomOrganizationIDNotNull(f *faker.Faker) FSProposedtreatmentareaMod {
return FSProposedtreatmentareaModFunc(func(_ context.Context, o *FSProposedtreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSQamosquitoinspectionModSlice) Apply(ctx context.Context, n *FSQamos
// FSQamosquitoinspectionTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSQamosquitoinspectionTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Acresbreeding func() null.Val[float64]
Actiontaken func() null.Val[string]
Adultactivity func() null.Val[int16]
@ -131,7 +131,7 @@ func (t FSQamosquitoinspectionTemplate) setModelRels(o *models.FSQamosquitoinspe
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSQamosquitoinspections = append(rel.R.FSQamosquitoinspections, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -143,7 +143,7 @@ func (o FSQamosquitoinspectionTemplate) BuildSetter() *models.FSQamosquitoinspec
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Acresbreeding != nil {
val := o.Acresbreeding()
@ -645,6 +645,10 @@ func (o FSQamosquitoinspectionTemplate) BuildMany(number int) models.FSQamosquit
}
func ensureCreatableFSQamosquitoinspection(m *models.FSQamosquitoinspectionSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -657,25 +661,6 @@ func ensureCreatableFSQamosquitoinspection(m *models.FSQamosquitoinspectionSette
func (o *FSQamosquitoinspectionTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSQamosquitoinspection) error {
var err error
isOrganizationDone, _ := fsQamosquitoinspectionRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsQamosquitoinspectionRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -686,11 +671,30 @@ func (o *FSQamosquitoinspectionTemplate) Create(ctx context.Context, exec bob.Ex
opt := o.BuildSetter()
ensureCreatableFSQamosquitoinspection(opt)
if o.r.Organization == nil {
FSQamosquitoinspectionMods.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.FSQamosquitoinspections.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
}
@ -838,14 +842,14 @@ func (m fsQamosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) FSQamosq
}
// Set the model columns to this value
func (m fsQamosquitoinspectionMods) OrganizationID(val null.Val[int32]) FSQamosquitoinspectionMod {
func (m fsQamosquitoinspectionMods) OrganizationID(val int32) FSQamosquitoinspectionMod {
return FSQamosquitoinspectionModFunc(func(_ context.Context, o *FSQamosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsQamosquitoinspectionMods) OrganizationIDFunc(f func() null.Val[int32]) FSQamosquitoinspectionMod {
func (m fsQamosquitoinspectionMods) OrganizationIDFunc(f func() int32) FSQamosquitoinspectionMod {
return FSQamosquitoinspectionModFunc(func(_ context.Context, o *FSQamosquitoinspectionTemplate) {
o.OrganizationID = f
})
@ -860,32 +864,10 @@ func (m fsQamosquitoinspectionMods) UnsetOrganizationID() FSQamosquitoinspection
// 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 fsQamosquitoinspectionMods) RandomOrganizationID(f *faker.Faker) FSQamosquitoinspectionMod {
return FSQamosquitoinspectionModFunc(func(_ context.Context, o *FSQamosquitoinspectionTemplate) {
o.OrganizationID = 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 fsQamosquitoinspectionMods) RandomOrganizationIDNotNull(f *faker.Faker) FSQamosquitoinspectionMod {
return FSQamosquitoinspectionModFunc(func(_ context.Context, o *FSQamosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSRodentlocationModSlice) Apply(ctx context.Context, n *FSRodentlocat
// FSRodentlocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSRodentlocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -99,7 +99,7 @@ func (t FSRodentlocationTemplate) setModelRels(o *models.FSRodentlocation) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSRodentlocations = append(rel.R.FSRodentlocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -111,7 +111,7 @@ func (o FSRodentlocationTemplate) BuildSetter() *models.FSRodentlocationSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -389,6 +389,10 @@ func (o FSRodentlocationTemplate) BuildMany(number int) models.FSRodentlocationS
}
func ensureCreatableFSRodentlocation(m *models.FSRodentlocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -401,25 +405,6 @@ func ensureCreatableFSRodentlocation(m *models.FSRodentlocationSetter) {
func (o *FSRodentlocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSRodentlocation) error {
var err error
isOrganizationDone, _ := fsRodentlocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsRodentlocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -430,11 +415,30 @@ func (o *FSRodentlocationTemplate) Create(ctx context.Context, exec bob.Executor
opt := o.BuildSetter()
ensureCreatableFSRodentlocation(opt)
if o.r.Organization == nil {
FSRodentlocationMods.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.FSRodentlocations.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
}
@ -550,14 +554,14 @@ func (m fsRodentlocationMods) RandomizeAllColumns(f *faker.Faker) FSRodentlocati
}
// Set the model columns to this value
func (m fsRodentlocationMods) OrganizationID(val null.Val[int32]) FSRodentlocationMod {
func (m fsRodentlocationMods) OrganizationID(val int32) FSRodentlocationMod {
return FSRodentlocationModFunc(func(_ context.Context, o *FSRodentlocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsRodentlocationMods) OrganizationIDFunc(f func() null.Val[int32]) FSRodentlocationMod {
func (m fsRodentlocationMods) OrganizationIDFunc(f func() int32) FSRodentlocationMod {
return FSRodentlocationModFunc(func(_ context.Context, o *FSRodentlocationTemplate) {
o.OrganizationID = f
})
@ -572,32 +576,10 @@ func (m fsRodentlocationMods) UnsetOrganizationID() FSRodentlocationMod {
// 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 fsRodentlocationMods) RandomOrganizationID(f *faker.Faker) FSRodentlocationMod {
return FSRodentlocationModFunc(func(_ context.Context, o *FSRodentlocationTemplate) {
o.OrganizationID = 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 fsRodentlocationMods) RandomOrganizationIDNotNull(f *faker.Faker) FSRodentlocationMod {
return FSRodentlocationModFunc(func(_ context.Context, o *FSRodentlocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSSamplecollectionModSlice) Apply(ctx context.Context, n *FSSamplecol
// FSSamplecollectionTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSSamplecollectionTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Activity func() null.Val[string]
Avetemp func() null.Val[float64]
Chickenid func() null.Val[string]
@ -115,7 +115,7 @@ func (t FSSamplecollectionTemplate) setModelRels(o *models.FSSamplecollection) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSSamplecollections = append(rel.R.FSSamplecollections, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -127,7 +127,7 @@ func (o FSSamplecollectionTemplate) BuildSetter() *models.FSSamplecollectionSett
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Activity != nil {
val := o.Activity()
@ -517,6 +517,10 @@ func (o FSSamplecollectionTemplate) BuildMany(number int) models.FSSamplecollect
}
func ensureCreatableFSSamplecollection(m *models.FSSamplecollectionSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -529,25 +533,6 @@ func ensureCreatableFSSamplecollection(m *models.FSSamplecollectionSetter) {
func (o *FSSamplecollectionTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSSamplecollection) error {
var err error
isOrganizationDone, _ := fsSamplecollectionRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsSamplecollectionRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -558,11 +543,30 @@ func (o *FSSamplecollectionTemplate) Create(ctx context.Context, exec bob.Execut
opt := o.BuildSetter()
ensureCreatableFSSamplecollection(opt)
if o.r.Organization == nil {
FSSamplecollectionMods.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.FSSamplecollections.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
}
@ -694,14 +698,14 @@ func (m fsSamplecollectionMods) RandomizeAllColumns(f *faker.Faker) FSSamplecoll
}
// Set the model columns to this value
func (m fsSamplecollectionMods) OrganizationID(val null.Val[int32]) FSSamplecollectionMod {
func (m fsSamplecollectionMods) OrganizationID(val int32) FSSamplecollectionMod {
return FSSamplecollectionModFunc(func(_ context.Context, o *FSSamplecollectionTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsSamplecollectionMods) OrganizationIDFunc(f func() null.Val[int32]) FSSamplecollectionMod {
func (m fsSamplecollectionMods) OrganizationIDFunc(f func() int32) FSSamplecollectionMod {
return FSSamplecollectionModFunc(func(_ context.Context, o *FSSamplecollectionTemplate) {
o.OrganizationID = f
})
@ -716,32 +720,10 @@ func (m fsSamplecollectionMods) UnsetOrganizationID() FSSamplecollectionMod {
// 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 fsSamplecollectionMods) RandomOrganizationID(f *faker.Faker) FSSamplecollectionMod {
return FSSamplecollectionModFunc(func(_ context.Context, o *FSSamplecollectionTemplate) {
o.OrganizationID = 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 fsSamplecollectionMods) RandomOrganizationIDNotNull(f *faker.Faker) FSSamplecollectionMod {
return FSSamplecollectionModFunc(func(_ context.Context, o *FSSamplecollectionTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSSamplelocationModSlice) Apply(ctx context.Context, n *FSSamplelocat
// FSSamplelocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSSamplelocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -93,7 +93,7 @@ func (t FSSamplelocationTemplate) setModelRels(o *models.FSSamplelocation) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSSamplelocations = append(rel.R.FSSamplelocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -105,7 +105,7 @@ func (o FSSamplelocationTemplate) BuildSetter() *models.FSSamplelocationSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -341,6 +341,10 @@ func (o FSSamplelocationTemplate) BuildMany(number int) models.FSSamplelocationS
}
func ensureCreatableFSSamplelocation(m *models.FSSamplelocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -353,25 +357,6 @@ func ensureCreatableFSSamplelocation(m *models.FSSamplelocationSetter) {
func (o *FSSamplelocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSSamplelocation) error {
var err error
isOrganizationDone, _ := fsSamplelocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsSamplelocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -382,11 +367,30 @@ func (o *FSSamplelocationTemplate) Create(ctx context.Context, exec bob.Executor
opt := o.BuildSetter()
ensureCreatableFSSamplelocation(opt)
if o.r.Organization == nil {
FSSamplelocationMods.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.FSSamplelocations.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
}
@ -496,14 +500,14 @@ func (m fsSamplelocationMods) RandomizeAllColumns(f *faker.Faker) FSSamplelocati
}
// Set the model columns to this value
func (m fsSamplelocationMods) OrganizationID(val null.Val[int32]) FSSamplelocationMod {
func (m fsSamplelocationMods) OrganizationID(val int32) FSSamplelocationMod {
return FSSamplelocationModFunc(func(_ context.Context, o *FSSamplelocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsSamplelocationMods) OrganizationIDFunc(f func() null.Val[int32]) FSSamplelocationMod {
func (m fsSamplelocationMods) OrganizationIDFunc(f func() int32) FSSamplelocationMod {
return FSSamplelocationModFunc(func(_ context.Context, o *FSSamplelocationTemplate) {
o.OrganizationID = f
})
@ -518,32 +522,10 @@ func (m fsSamplelocationMods) UnsetOrganizationID() FSSamplelocationMod {
// 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 fsSamplelocationMods) RandomOrganizationID(f *faker.Faker) FSSamplelocationMod {
return FSSamplelocationModFunc(func(_ context.Context, o *FSSamplelocationTemplate) {
o.OrganizationID = 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 fsSamplelocationMods) RandomOrganizationIDNotNull(f *faker.Faker) FSSamplelocationMod {
return FSSamplelocationModFunc(func(_ context.Context, o *FSSamplelocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSServicerequestModSlice) Apply(ctx context.Context, n *FSServicerequ
// FSServicerequestTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSServicerequestTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accepted func() null.Val[int16]
Acceptedby func() null.Val[string]
Accepteddate func() null.Val[int64]
@ -155,7 +155,7 @@ func (t FSServicerequestTemplate) setModelRels(o *models.FSServicerequest) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSServicerequests = append(rel.R.FSServicerequests, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -167,7 +167,7 @@ func (o FSServicerequestTemplate) BuildSetter() *models.FSServicerequestSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accepted != nil {
val := o.Accepted()
@ -837,6 +837,10 @@ func (o FSServicerequestTemplate) BuildMany(number int) models.FSServicerequestS
}
func ensureCreatableFSServicerequest(m *models.FSServicerequestSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -849,25 +853,6 @@ func ensureCreatableFSServicerequest(m *models.FSServicerequestSetter) {
func (o *FSServicerequestTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSServicerequest) error {
var err error
isOrganizationDone, _ := fsServicerequestRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsServicerequestRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -878,11 +863,30 @@ func (o *FSServicerequestTemplate) Create(ctx context.Context, exec bob.Executor
opt := o.BuildSetter()
ensureCreatableFSServicerequest(opt)
if o.r.Organization == nil {
FSServicerequestMods.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.FSServicerequests.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
}
@ -1054,14 +1058,14 @@ func (m fsServicerequestMods) RandomizeAllColumns(f *faker.Faker) FSServicereque
}
// Set the model columns to this value
func (m fsServicerequestMods) OrganizationID(val null.Val[int32]) FSServicerequestMod {
func (m fsServicerequestMods) OrganizationID(val int32) FSServicerequestMod {
return FSServicerequestModFunc(func(_ context.Context, o *FSServicerequestTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsServicerequestMods) OrganizationIDFunc(f func() null.Val[int32]) FSServicerequestMod {
func (m fsServicerequestMods) OrganizationIDFunc(f func() int32) FSServicerequestMod {
return FSServicerequestModFunc(func(_ context.Context, o *FSServicerequestTemplate) {
o.OrganizationID = f
})
@ -1076,32 +1080,10 @@ func (m fsServicerequestMods) UnsetOrganizationID() FSServicerequestMod {
// 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 fsServicerequestMods) RandomOrganizationID(f *faker.Faker) FSServicerequestMod {
return FSServicerequestModFunc(func(_ context.Context, o *FSServicerequestTemplate) {
o.OrganizationID = 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 fsServicerequestMods) RandomOrganizationIDNotNull(f *faker.Faker) FSServicerequestMod {
return FSServicerequestModFunc(func(_ context.Context, o *FSServicerequestTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSSpeciesabundanceModSlice) Apply(ctx context.Context, n *FSSpeciesab
// FSSpeciesabundanceTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSSpeciesabundanceTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Bloodedfem func() null.Val[int16]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -98,7 +98,7 @@ func (t FSSpeciesabundanceTemplate) setModelRels(o *models.FSSpeciesabundance) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSSpeciesabundances = append(rel.R.FSSpeciesabundances, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -110,7 +110,7 @@ func (o FSSpeciesabundanceTemplate) BuildSetter() *models.FSSpeciesabundanceSett
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Bloodedfem != nil {
val := o.Bloodedfem()
@ -381,6 +381,10 @@ func (o FSSpeciesabundanceTemplate) BuildMany(number int) models.FSSpeciesabunda
}
func ensureCreatableFSSpeciesabundance(m *models.FSSpeciesabundanceSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -393,25 +397,6 @@ func ensureCreatableFSSpeciesabundance(m *models.FSSpeciesabundanceSetter) {
func (o *FSSpeciesabundanceTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSSpeciesabundance) error {
var err error
isOrganizationDone, _ := fsSpeciesabundanceRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsSpeciesabundanceRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -422,11 +407,30 @@ func (o *FSSpeciesabundanceTemplate) Create(ctx context.Context, exec bob.Execut
opt := o.BuildSetter()
ensureCreatableFSSpeciesabundance(opt)
if o.r.Organization == nil {
FSSpeciesabundanceMods.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.FSSpeciesabundances.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
}
@ -541,14 +545,14 @@ func (m fsSpeciesabundanceMods) RandomizeAllColumns(f *faker.Faker) FSSpeciesabu
}
// Set the model columns to this value
func (m fsSpeciesabundanceMods) OrganizationID(val null.Val[int32]) FSSpeciesabundanceMod {
func (m fsSpeciesabundanceMods) OrganizationID(val int32) FSSpeciesabundanceMod {
return FSSpeciesabundanceModFunc(func(_ context.Context, o *FSSpeciesabundanceTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsSpeciesabundanceMods) OrganizationIDFunc(f func() null.Val[int32]) FSSpeciesabundanceMod {
func (m fsSpeciesabundanceMods) OrganizationIDFunc(f func() int32) FSSpeciesabundanceMod {
return FSSpeciesabundanceModFunc(func(_ context.Context, o *FSSpeciesabundanceTemplate) {
o.OrganizationID = f
})
@ -563,32 +567,10 @@ func (m fsSpeciesabundanceMods) UnsetOrganizationID() FSSpeciesabundanceMod {
// 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 fsSpeciesabundanceMods) RandomOrganizationID(f *faker.Faker) FSSpeciesabundanceMod {
return FSSpeciesabundanceModFunc(func(_ context.Context, o *FSSpeciesabundanceTemplate) {
o.OrganizationID = 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 fsSpeciesabundanceMods) RandomOrganizationIDNotNull(f *faker.Faker) FSSpeciesabundanceMod {
return FSSpeciesabundanceModFunc(func(_ context.Context, o *FSSpeciesabundanceTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSStormdrainModSlice) Apply(ctx context.Context, n *FSStormdrainTempl
// FSStormdrainTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSStormdrainTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -88,7 +88,7 @@ func (t FSStormdrainTemplate) setModelRels(o *models.FSStormdrain) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSStormdrains = append(rel.R.FSStormdrains, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -100,7 +100,7 @@ func (o FSStormdrainTemplate) BuildSetter() *models.FSStormdrainSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -301,6 +301,10 @@ func (o FSStormdrainTemplate) BuildMany(number int) models.FSStormdrainSlice {
}
func ensureCreatableFSStormdrain(m *models.FSStormdrainSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -313,25 +317,6 @@ func ensureCreatableFSStormdrain(m *models.FSStormdrainSetter) {
func (o *FSStormdrainTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSStormdrain) error {
var err error
isOrganizationDone, _ := fsStormdrainRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsStormdrainRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -342,11 +327,30 @@ func (o *FSStormdrainTemplate) Create(ctx context.Context, exec bob.Executor) (*
opt := o.BuildSetter()
ensureCreatableFSStormdrain(opt)
if o.r.Organization == nil {
FSStormdrainMods.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.FSStormdrains.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
}
@ -451,14 +455,14 @@ func (m fsStormdrainMods) RandomizeAllColumns(f *faker.Faker) FSStormdrainMod {
}
// Set the model columns to this value
func (m fsStormdrainMods) OrganizationID(val null.Val[int32]) FSStormdrainMod {
func (m fsStormdrainMods) OrganizationID(val int32) FSStormdrainMod {
return FSStormdrainModFunc(func(_ context.Context, o *FSStormdrainTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsStormdrainMods) OrganizationIDFunc(f func() null.Val[int32]) FSStormdrainMod {
func (m fsStormdrainMods) OrganizationIDFunc(f func() int32) FSStormdrainMod {
return FSStormdrainModFunc(func(_ context.Context, o *FSStormdrainTemplate) {
o.OrganizationID = f
})
@ -473,32 +477,10 @@ func (m fsStormdrainMods) UnsetOrganizationID() FSStormdrainMod {
// 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 fsStormdrainMods) RandomOrganizationID(f *faker.Faker) FSStormdrainMod {
return FSStormdrainModFunc(func(_ context.Context, o *FSStormdrainTemplate) {
o.OrganizationID = 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 fsStormdrainMods) RandomOrganizationIDNotNull(f *faker.Faker) FSStormdrainMod {
return FSStormdrainModFunc(func(_ context.Context, o *FSStormdrainTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSTimecardModSlice) Apply(ctx context.Context, n *FSTimecardTemplate)
// FSTimecardTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSTimecardTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Activity func() null.Val[string]
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
@ -97,7 +97,7 @@ func (t FSTimecardTemplate) setModelRels(o *models.FSTimecard) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSTimecards = append(rel.R.FSTimecards, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -109,7 +109,7 @@ func (o FSTimecardTemplate) BuildSetter() *models.FSTimecardSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Activity != nil {
val := o.Activity()
@ -373,6 +373,10 @@ func (o FSTimecardTemplate) BuildMany(number int) models.FSTimecardSlice {
}
func ensureCreatableFSTimecard(m *models.FSTimecardSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -385,25 +389,6 @@ func ensureCreatableFSTimecard(m *models.FSTimecardSetter) {
func (o *FSTimecardTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSTimecard) error {
var err error
isOrganizationDone, _ := fsTimecardRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsTimecardRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -414,11 +399,30 @@ func (o *FSTimecardTemplate) Create(ctx context.Context, exec bob.Executor) (*mo
opt := o.BuildSetter()
ensureCreatableFSTimecard(opt)
if o.r.Organization == nil {
FSTimecardMods.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.FSTimecards.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
}
@ -532,14 +536,14 @@ func (m fsTimecardMods) RandomizeAllColumns(f *faker.Faker) FSTimecardMod {
}
// Set the model columns to this value
func (m fsTimecardMods) OrganizationID(val null.Val[int32]) FSTimecardMod {
func (m fsTimecardMods) OrganizationID(val int32) FSTimecardMod {
return FSTimecardModFunc(func(_ context.Context, o *FSTimecardTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsTimecardMods) OrganizationIDFunc(f func() null.Val[int32]) FSTimecardMod {
func (m fsTimecardMods) OrganizationIDFunc(f func() int32) FSTimecardMod {
return FSTimecardModFunc(func(_ context.Context, o *FSTimecardTemplate) {
o.OrganizationID = f
})
@ -554,32 +558,10 @@ func (m fsTimecardMods) UnsetOrganizationID() FSTimecardMod {
// 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 fsTimecardMods) RandomOrganizationID(f *faker.Faker) FSTimecardMod {
return FSTimecardModFunc(func(_ context.Context, o *FSTimecardTemplate) {
o.OrganizationID = 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 fsTimecardMods) RandomOrganizationIDNotNull(f *faker.Faker) FSTimecardMod {
return FSTimecardModFunc(func(_ context.Context, o *FSTimecardTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSTrapdatumModSlice) Apply(ctx context.Context, n *FSTrapdatumTemplat
// FSTrapdatumTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSTrapdatumTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Avetemp func() null.Val[float64]
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
@ -111,7 +111,7 @@ func (t FSTrapdatumTemplate) setModelRels(o *models.FSTrapdatum) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSTrapdata = append(rel.R.FSTrapdata, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -123,7 +123,7 @@ func (o FSTrapdatumTemplate) BuildSetter() *models.FSTrapdatumSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Avetemp != nil {
val := o.Avetemp()
@ -485,6 +485,10 @@ func (o FSTrapdatumTemplate) BuildMany(number int) models.FSTrapdatumSlice {
}
func ensureCreatableFSTrapdatum(m *models.FSTrapdatumSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -497,25 +501,6 @@ func ensureCreatableFSTrapdatum(m *models.FSTrapdatumSetter) {
func (o *FSTrapdatumTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSTrapdatum) error {
var err error
isOrganizationDone, _ := fsTrapdatumRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsTrapdatumRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -526,11 +511,30 @@ func (o *FSTrapdatumTemplate) Create(ctx context.Context, exec bob.Executor) (*m
opt := o.BuildSetter()
ensureCreatableFSTrapdatum(opt)
if o.r.Organization == nil {
FSTrapdatumMods.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.FSTrapdata.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
}
@ -658,14 +662,14 @@ func (m fsTrapdatumMods) RandomizeAllColumns(f *faker.Faker) FSTrapdatumMod {
}
// Set the model columns to this value
func (m fsTrapdatumMods) OrganizationID(val null.Val[int32]) FSTrapdatumMod {
func (m fsTrapdatumMods) OrganizationID(val int32) FSTrapdatumMod {
return FSTrapdatumModFunc(func(_ context.Context, o *FSTrapdatumTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsTrapdatumMods) OrganizationIDFunc(f func() null.Val[int32]) FSTrapdatumMod {
func (m fsTrapdatumMods) OrganizationIDFunc(f func() int32) FSTrapdatumMod {
return FSTrapdatumModFunc(func(_ context.Context, o *FSTrapdatumTemplate) {
o.OrganizationID = f
})
@ -680,32 +684,10 @@ func (m fsTrapdatumMods) UnsetOrganizationID() FSTrapdatumMod {
// 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 fsTrapdatumMods) RandomOrganizationID(f *faker.Faker) FSTrapdatumMod {
return FSTrapdatumModFunc(func(_ context.Context, o *FSTrapdatumTemplate) {
o.OrganizationID = 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 fsTrapdatumMods) RandomOrganizationIDNotNull(f *faker.Faker) FSTrapdatumMod {
return FSTrapdatumModFunc(func(_ context.Context, o *FSTrapdatumTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSTraplocationModSlice) Apply(ctx context.Context, n *FSTraplocationT
// FSTraplocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSTraplocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -99,7 +99,7 @@ func (t FSTraplocationTemplate) setModelRels(o *models.FSTraplocation) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSTraplocations = append(rel.R.FSTraplocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -111,7 +111,7 @@ func (o FSTraplocationTemplate) BuildSetter() *models.FSTraplocationSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -389,6 +389,10 @@ func (o FSTraplocationTemplate) BuildMany(number int) models.FSTraplocationSlice
}
func ensureCreatableFSTraplocation(m *models.FSTraplocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -401,25 +405,6 @@ func ensureCreatableFSTraplocation(m *models.FSTraplocationSetter) {
func (o *FSTraplocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSTraplocation) error {
var err error
isOrganizationDone, _ := fsTraplocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsTraplocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -430,11 +415,30 @@ func (o *FSTraplocationTemplate) Create(ctx context.Context, exec bob.Executor)
opt := o.BuildSetter()
ensureCreatableFSTraplocation(opt)
if o.r.Organization == nil {
FSTraplocationMods.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.FSTraplocations.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
}
@ -550,14 +554,14 @@ func (m fsTraplocationMods) RandomizeAllColumns(f *faker.Faker) FSTraplocationMo
}
// Set the model columns to this value
func (m fsTraplocationMods) OrganizationID(val null.Val[int32]) FSTraplocationMod {
func (m fsTraplocationMods) OrganizationID(val int32) FSTraplocationMod {
return FSTraplocationModFunc(func(_ context.Context, o *FSTraplocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsTraplocationMods) OrganizationIDFunc(f func() null.Val[int32]) FSTraplocationMod {
func (m fsTraplocationMods) OrganizationIDFunc(f func() int32) FSTraplocationMod {
return FSTraplocationModFunc(func(_ context.Context, o *FSTraplocationTemplate) {
o.OrganizationID = f
})
@ -572,32 +576,10 @@ func (m fsTraplocationMods) UnsetOrganizationID() FSTraplocationMod {
// 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 fsTraplocationMods) RandomOrganizationID(f *faker.Faker) FSTraplocationMod {
return FSTraplocationModFunc(func(_ context.Context, o *FSTraplocationTemplate) {
o.OrganizationID = 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 fsTraplocationMods) RandomOrganizationIDNotNull(f *faker.Faker) FSTraplocationMod {
return FSTraplocationModFunc(func(_ context.Context, o *FSTraplocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSTreatmentModSlice) Apply(ctx context.Context, n *FSTreatmentTemplat
// FSTreatmentTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSTreatmentTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Activity func() null.Val[string]
Areaunit func() null.Val[string]
Avetemp func() null.Val[float64]
@ -123,7 +123,7 @@ func (t FSTreatmentTemplate) setModelRels(o *models.FSTreatment) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSTreatments = append(rel.R.FSTreatments, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -135,7 +135,7 @@ func (o FSTreatmentTemplate) BuildSetter() *models.FSTreatmentSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Activity != nil {
val := o.Activity()
@ -581,6 +581,10 @@ func (o FSTreatmentTemplate) BuildMany(number int) models.FSTreatmentSlice {
}
func ensureCreatableFSTreatment(m *models.FSTreatmentSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -593,25 +597,6 @@ func ensureCreatableFSTreatment(m *models.FSTreatmentSetter) {
func (o *FSTreatmentTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSTreatment) error {
var err error
isOrganizationDone, _ := fsTreatmentRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsTreatmentRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -622,11 +607,30 @@ func (o *FSTreatmentTemplate) Create(ctx context.Context, exec bob.Executor) (*m
opt := o.BuildSetter()
ensureCreatableFSTreatment(opt)
if o.r.Organization == nil {
FSTreatmentMods.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.FSTreatments.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
}
@ -766,14 +770,14 @@ func (m fsTreatmentMods) RandomizeAllColumns(f *faker.Faker) FSTreatmentMod {
}
// Set the model columns to this value
func (m fsTreatmentMods) OrganizationID(val null.Val[int32]) FSTreatmentMod {
func (m fsTreatmentMods) OrganizationID(val int32) FSTreatmentMod {
return FSTreatmentModFunc(func(_ context.Context, o *FSTreatmentTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsTreatmentMods) OrganizationIDFunc(f func() null.Val[int32]) FSTreatmentMod {
func (m fsTreatmentMods) OrganizationIDFunc(f func() int32) FSTreatmentMod {
return FSTreatmentModFunc(func(_ context.Context, o *FSTreatmentTemplate) {
o.OrganizationID = f
})
@ -788,32 +792,10 @@ func (m fsTreatmentMods) UnsetOrganizationID() FSTreatmentMod {
// 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 fsTreatmentMods) RandomOrganizationID(f *faker.Faker) FSTreatmentMod {
return FSTreatmentModFunc(func(_ context.Context, o *FSTreatmentTemplate) {
o.OrganizationID = 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 fsTreatmentMods) RandomOrganizationIDNotNull(f *faker.Faker) FSTreatmentMod {
return FSTreatmentModFunc(func(_ context.Context, o *FSTreatmentTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSTreatmentareaModSlice) Apply(ctx context.Context, n *FSTreatmentare
// FSTreatmentareaTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSTreatmentareaTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -87,7 +87,7 @@ func (t FSTreatmentareaTemplate) setModelRels(o *models.FSTreatmentarea) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSTreatmentareas = append(rel.R.FSTreatmentareas, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -99,7 +99,7 @@ func (o FSTreatmentareaTemplate) BuildSetter() *models.FSTreatmentareaSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Comments != nil {
val := o.Comments()
@ -293,6 +293,10 @@ func (o FSTreatmentareaTemplate) BuildMany(number int) models.FSTreatmentareaSli
}
func ensureCreatableFSTreatmentarea(m *models.FSTreatmentareaSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -305,25 +309,6 @@ func ensureCreatableFSTreatmentarea(m *models.FSTreatmentareaSetter) {
func (o *FSTreatmentareaTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSTreatmentarea) error {
var err error
isOrganizationDone, _ := fsTreatmentareaRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsTreatmentareaRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -334,11 +319,30 @@ func (o *FSTreatmentareaTemplate) Create(ctx context.Context, exec bob.Executor)
opt := o.BuildSetter()
ensureCreatableFSTreatmentarea(opt)
if o.r.Organization == nil {
FSTreatmentareaMods.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.FSTreatmentareas.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
}
@ -442,14 +446,14 @@ func (m fsTreatmentareaMods) RandomizeAllColumns(f *faker.Faker) FSTreatmentarea
}
// Set the model columns to this value
func (m fsTreatmentareaMods) OrganizationID(val null.Val[int32]) FSTreatmentareaMod {
func (m fsTreatmentareaMods) OrganizationID(val int32) FSTreatmentareaMod {
return FSTreatmentareaModFunc(func(_ context.Context, o *FSTreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsTreatmentareaMods) OrganizationIDFunc(f func() null.Val[int32]) FSTreatmentareaMod {
func (m fsTreatmentareaMods) OrganizationIDFunc(f func() int32) FSTreatmentareaMod {
return FSTreatmentareaModFunc(func(_ context.Context, o *FSTreatmentareaTemplate) {
o.OrganizationID = f
})
@ -464,32 +468,10 @@ func (m fsTreatmentareaMods) UnsetOrganizationID() FSTreatmentareaMod {
// 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 fsTreatmentareaMods) RandomOrganizationID(f *faker.Faker) FSTreatmentareaMod {
return FSTreatmentareaModFunc(func(_ context.Context, o *FSTreatmentareaTemplate) {
o.OrganizationID = 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 fsTreatmentareaMods) RandomOrganizationIDNotNull(f *faker.Faker) FSTreatmentareaMod {
return FSTreatmentareaModFunc(func(_ context.Context, o *FSTreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSZoneModSlice) Apply(ctx context.Context, n *FSZoneTemplate) {
// FSZoneTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FSZoneTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Active func() null.Val[int64]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -83,7 +83,7 @@ func (t FSZoneTemplate) setModelRels(o *models.FSZone) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSZones = append(rel.R.FSZones, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -95,7 +95,7 @@ func (o FSZoneTemplate) BuildSetter() *models.FSZoneSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Active != nil {
val := o.Active()
@ -261,6 +261,10 @@ func (o FSZoneTemplate) BuildMany(number int) models.FSZoneSlice {
}
func ensureCreatableFSZone(m *models.FSZoneSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -273,25 +277,6 @@ func ensureCreatableFSZone(m *models.FSZoneSetter) {
func (o *FSZoneTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSZone) error {
var err error
isOrganizationDone, _ := fsZoneRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsZoneRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -302,11 +287,30 @@ func (o *FSZoneTemplate) Create(ctx context.Context, exec bob.Executor) (*models
opt := o.BuildSetter()
ensureCreatableFSZone(opt)
if o.r.Organization == nil {
FSZoneMods.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.FSZones.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
}
@ -406,14 +410,14 @@ func (m fsZoneMods) RandomizeAllColumns(f *faker.Faker) FSZoneMod {
}
// Set the model columns to this value
func (m fsZoneMods) OrganizationID(val null.Val[int32]) FSZoneMod {
func (m fsZoneMods) OrganizationID(val int32) FSZoneMod {
return FSZoneModFunc(func(_ context.Context, o *FSZoneTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsZoneMods) OrganizationIDFunc(f func() null.Val[int32]) FSZoneMod {
func (m fsZoneMods) OrganizationIDFunc(f func() int32) FSZoneMod {
return FSZoneModFunc(func(_ context.Context, o *FSZoneTemplate) {
o.OrganizationID = f
})
@ -428,32 +432,10 @@ func (m fsZoneMods) UnsetOrganizationID() FSZoneMod {
// 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 fsZoneMods) RandomOrganizationID(f *faker.Faker) FSZoneMod {
return FSZoneModFunc(func(_ context.Context, o *FSZoneTemplate) {
o.OrganizationID = 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 fsZoneMods) RandomOrganizationIDNotNull(f *faker.Faker) FSZoneMod {
return FSZoneModFunc(func(_ context.Context, o *FSZoneTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -37,7 +37,7 @@ func (mods FSZones2ModSlice) Apply(ctx context.Context, n *FSZones2Template) {
// FSZones2Template is an object representing the database table.
// all columns are optional and should be set by mods
type FSZones2Template struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -82,7 +82,7 @@ func (t FSZones2Template) setModelRels(o *models.FSZones2) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.FSZones2s = append(rel.R.FSZones2s, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -94,7 +94,7 @@ func (o FSZones2Template) BuildSetter() *models.FSZones2Setter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -253,6 +253,10 @@ func (o FSZones2Template) BuildMany(number int) models.FSZones2Slice {
}
func ensureCreatableFSZones2(m *models.FSZones2Setter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -265,25 +269,6 @@ func ensureCreatableFSZones2(m *models.FSZones2Setter) {
func (o *FSZones2Template) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FSZones2) error {
var err error
isOrganizationDone, _ := fsZones2RelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = fsZones2RelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -294,11 +279,30 @@ func (o *FSZones2Template) Create(ctx context.Context, exec bob.Executor) (*mode
opt := o.BuildSetter()
ensureCreatableFSZones2(opt)
if o.r.Organization == nil {
FSZones2Mods.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.FSZones2s.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
}
@ -397,14 +401,14 @@ func (m fsZones2Mods) RandomizeAllColumns(f *faker.Faker) FSZones2Mod {
}
// Set the model columns to this value
func (m fsZones2Mods) OrganizationID(val null.Val[int32]) FSZones2Mod {
func (m fsZones2Mods) OrganizationID(val int32) FSZones2Mod {
return FSZones2ModFunc(func(_ context.Context, o *FSZones2Template) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m fsZones2Mods) OrganizationIDFunc(f func() null.Val[int32]) FSZones2Mod {
func (m fsZones2Mods) OrganizationIDFunc(f func() int32) FSZones2Mod {
return FSZones2ModFunc(func(_ context.Context, o *FSZones2Template) {
o.OrganizationID = f
})
@ -419,32 +423,10 @@ func (m fsZones2Mods) UnsetOrganizationID() FSZones2Mod {
// 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 fsZones2Mods) RandomOrganizationID(f *faker.Faker) FSZones2Mod {
return FSZones2ModFunc(func(_ context.Context, o *FSZones2Template) {
o.OrganizationID = 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 fsZones2Mods) RandomOrganizationIDNotNull(f *faker.Faker) FSZones2Mod {
return FSZones2ModFunc(func(_ context.Context, o *FSZones2Template) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryContainerrelateModSlice) Apply(ctx context.Context, n *History
// HistoryContainerrelateTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryContainerrelateTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Containertype func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -47,6 +48,7 @@ type HistoryContainerrelateTemplate struct {
Mosquitoinspid func() null.Val[string]
Objectid func() int32
Treatmentid func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -82,7 +84,7 @@ func (t HistoryContainerrelateTemplate) setModelRels(o *models.HistoryContainerr
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryContainerrelates = append(rel.R.HistoryContainerrelates, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -94,7 +96,7 @@ func (o HistoryContainerrelateTemplate) BuildSetter() *models.HistoryContainerre
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Containertype != nil {
val := o.Containertype()
@ -136,6 +138,10 @@ func (o HistoryContainerrelateTemplate) BuildSetter() *models.HistoryContainerre
val := o.Treatmentid()
m.Treatmentid = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -219,6 +225,9 @@ func (o HistoryContainerrelateTemplate) Build() *models.HistoryContainerrelate {
if o.Treatmentid != nil {
m.Treatmentid = o.Treatmentid()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -260,6 +269,10 @@ func (o HistoryContainerrelateTemplate) BuildMany(number int) models.HistoryCont
}
func ensureCreatableHistoryContainerrelate(m *models.HistoryContainerrelateSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -276,25 +289,6 @@ func ensureCreatableHistoryContainerrelate(m *models.HistoryContainerrelateSette
func (o *HistoryContainerrelateTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryContainerrelate) error {
var err error
isOrganizationDone, _ := historyContainerrelateRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyContainerrelateRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -305,11 +299,30 @@ func (o *HistoryContainerrelateTemplate) Create(ctx context.Context, exec bob.Ex
opt := o.BuildSetter()
ensureCreatableHistoryContainerrelate(opt)
if o.r.Organization == nil {
HistoryContainerrelateMods.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.HistoryContainerrelates.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
}
@ -398,6 +411,7 @@ func (m historyContainerrelateMods) RandomizeAllColumns(f *faker.Faker) HistoryC
HistoryContainerrelateMods.RandomMosquitoinspid(f),
HistoryContainerrelateMods.RandomObjectid(f),
HistoryContainerrelateMods.RandomTreatmentid(f),
HistoryContainerrelateMods.RandomCreated(f),
HistoryContainerrelateMods.RandomCreatedDate(f),
HistoryContainerrelateMods.RandomCreatedUser(f),
HistoryContainerrelateMods.RandomGeometryX(f),
@ -409,14 +423,14 @@ func (m historyContainerrelateMods) RandomizeAllColumns(f *faker.Faker) HistoryC
}
// Set the model columns to this value
func (m historyContainerrelateMods) OrganizationID(val null.Val[int32]) HistoryContainerrelateMod {
func (m historyContainerrelateMods) OrganizationID(val int32) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyContainerrelateMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryContainerrelateMod {
func (m historyContainerrelateMods) OrganizationIDFunc(f func() int32) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.OrganizationID = f
})
@ -431,32 +445,10 @@ func (m historyContainerrelateMods) UnsetOrganizationID() HistoryContainerrelate
// 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 historyContainerrelateMods) RandomOrganizationID(f *faker.Faker) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.OrganizationID = 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 historyContainerrelateMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -969,6 +961,59 @@ func (m historyContainerrelateMods) RandomTreatmentidNotNull(f *faker.Faker) His
})
}
// Set the model columns to this value
func (m historyContainerrelateMods) Created(val null.Val[time.Time]) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyContainerrelateMods) CreatedFunc(f func() null.Val[time.Time]) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyContainerrelateMods) UnsetCreated() HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.Created = 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 historyContainerrelateMods) RandomCreated(f *faker.Faker) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.Created = 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 historyContainerrelateMods) RandomCreatedNotNull(f *faker.Faker) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {
o.Created = 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 historyContainerrelateMods) CreatedDate(val null.Val[int64]) HistoryContainerrelateMod {
return HistoryContainerrelateModFunc(func(_ context.Context, o *HistoryContainerrelateTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryFieldscoutinglogModSlice) Apply(ctx context.Context, n *Histor
// HistoryFieldscoutinglogTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryFieldscoutinglogTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -44,6 +45,7 @@ type HistoryFieldscoutinglogTemplate struct {
Globalid func() null.Val[string]
Objectid func() int32
Status func() null.Val[int16]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -79,7 +81,7 @@ func (t HistoryFieldscoutinglogTemplate) setModelRels(o *models.HistoryFieldscou
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryFieldscoutinglogs = append(rel.R.HistoryFieldscoutinglogs, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -91,7 +93,7 @@ func (o HistoryFieldscoutinglogTemplate) BuildSetter() *models.HistoryFieldscout
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -121,6 +123,10 @@ func (o HistoryFieldscoutinglogTemplate) BuildSetter() *models.HistoryFieldscout
val := o.Status()
m.Status = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -195,6 +201,9 @@ func (o HistoryFieldscoutinglogTemplate) Build() *models.HistoryFieldscoutinglog
if o.Status != nil {
m.Status = o.Status()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -236,6 +245,10 @@ func (o HistoryFieldscoutinglogTemplate) BuildMany(number int) models.HistoryFie
}
func ensureCreatableHistoryFieldscoutinglog(m *models.HistoryFieldscoutinglogSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -252,25 +265,6 @@ func ensureCreatableHistoryFieldscoutinglog(m *models.HistoryFieldscoutinglogSet
func (o *HistoryFieldscoutinglogTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryFieldscoutinglog) error {
var err error
isOrganizationDone, _ := historyFieldscoutinglogRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyFieldscoutinglogRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -281,11 +275,30 @@ func (o *HistoryFieldscoutinglogTemplate) Create(ctx context.Context, exec bob.E
opt := o.BuildSetter()
ensureCreatableHistoryFieldscoutinglog(opt)
if o.r.Organization == nil {
HistoryFieldscoutinglogMods.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.HistoryFieldscoutinglogs.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
}
@ -371,6 +384,7 @@ func (m historyFieldscoutinglogMods) RandomizeAllColumns(f *faker.Faker) History
HistoryFieldscoutinglogMods.RandomGlobalid(f),
HistoryFieldscoutinglogMods.RandomObjectid(f),
HistoryFieldscoutinglogMods.RandomStatus(f),
HistoryFieldscoutinglogMods.RandomCreated(f),
HistoryFieldscoutinglogMods.RandomCreatedDate(f),
HistoryFieldscoutinglogMods.RandomCreatedUser(f),
HistoryFieldscoutinglogMods.RandomGeometryX(f),
@ -382,14 +396,14 @@ func (m historyFieldscoutinglogMods) RandomizeAllColumns(f *faker.Faker) History
}
// Set the model columns to this value
func (m historyFieldscoutinglogMods) OrganizationID(val null.Val[int32]) HistoryFieldscoutinglogMod {
func (m historyFieldscoutinglogMods) OrganizationID(val int32) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyFieldscoutinglogMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryFieldscoutinglogMod {
func (m historyFieldscoutinglogMods) OrganizationIDFunc(f func() int32) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.OrganizationID = f
})
@ -404,32 +418,10 @@ func (m historyFieldscoutinglogMods) UnsetOrganizationID() HistoryFieldscoutingl
// 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 historyFieldscoutinglogMods) RandomOrganizationID(f *faker.Faker) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.OrganizationID = 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 historyFieldscoutinglogMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -783,6 +775,59 @@ func (m historyFieldscoutinglogMods) RandomStatusNotNull(f *faker.Faker) History
})
}
// Set the model columns to this value
func (m historyFieldscoutinglogMods) Created(val null.Val[time.Time]) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyFieldscoutinglogMods) CreatedFunc(f func() null.Val[time.Time]) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyFieldscoutinglogMods) UnsetCreated() HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.Created = 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 historyFieldscoutinglogMods) RandomCreated(f *faker.Faker) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.Created = 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 historyFieldscoutinglogMods) RandomCreatedNotNull(f *faker.Faker) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {
o.Created = 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 historyFieldscoutinglogMods) CreatedDate(val null.Val[int64]) HistoryFieldscoutinglogMod {
return HistoryFieldscoutinglogModFunc(func(_ context.Context, o *HistoryFieldscoutinglogTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryHabitatrelateModSlice) Apply(ctx context.Context, n *HistoryHa
// HistoryHabitatrelateTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryHabitatrelateTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -45,6 +46,7 @@ type HistoryHabitatrelateTemplate struct {
Globalid func() null.Val[string]
Habitattype func() null.Val[string]
Objectid func() int32
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -80,7 +82,7 @@ func (t HistoryHabitatrelateTemplate) setModelRels(o *models.HistoryHabitatrelat
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryHabitatrelates = append(rel.R.HistoryHabitatrelates, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -92,7 +94,7 @@ func (o HistoryHabitatrelateTemplate) BuildSetter() *models.HistoryHabitatrelate
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -126,6 +128,10 @@ func (o HistoryHabitatrelateTemplate) BuildSetter() *models.HistoryHabitatrelate
val := o.Objectid()
m.Objectid = omit.From(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -203,6 +209,9 @@ func (o HistoryHabitatrelateTemplate) Build() *models.HistoryHabitatrelate {
if o.Objectid != nil {
m.Objectid = o.Objectid()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -244,6 +253,10 @@ func (o HistoryHabitatrelateTemplate) BuildMany(number int) models.HistoryHabita
}
func ensureCreatableHistoryHabitatrelate(m *models.HistoryHabitatrelateSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -260,25 +273,6 @@ func ensureCreatableHistoryHabitatrelate(m *models.HistoryHabitatrelateSetter) {
func (o *HistoryHabitatrelateTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryHabitatrelate) error {
var err error
isOrganizationDone, _ := historyHabitatrelateRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyHabitatrelateRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -289,11 +283,30 @@ func (o *HistoryHabitatrelateTemplate) Create(ctx context.Context, exec bob.Exec
opt := o.BuildSetter()
ensureCreatableHistoryHabitatrelate(opt)
if o.r.Organization == nil {
HistoryHabitatrelateMods.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.HistoryHabitatrelates.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
}
@ -380,6 +393,7 @@ func (m historyHabitatrelateMods) RandomizeAllColumns(f *faker.Faker) HistoryHab
HistoryHabitatrelateMods.RandomGlobalid(f),
HistoryHabitatrelateMods.RandomHabitattype(f),
HistoryHabitatrelateMods.RandomObjectid(f),
HistoryHabitatrelateMods.RandomCreated(f),
HistoryHabitatrelateMods.RandomCreatedDate(f),
HistoryHabitatrelateMods.RandomCreatedUser(f),
HistoryHabitatrelateMods.RandomGeometryX(f),
@ -391,14 +405,14 @@ func (m historyHabitatrelateMods) RandomizeAllColumns(f *faker.Faker) HistoryHab
}
// Set the model columns to this value
func (m historyHabitatrelateMods) OrganizationID(val null.Val[int32]) HistoryHabitatrelateMod {
func (m historyHabitatrelateMods) OrganizationID(val int32) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyHabitatrelateMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryHabitatrelateMod {
func (m historyHabitatrelateMods) OrganizationIDFunc(f func() int32) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.OrganizationID = f
})
@ -413,32 +427,10 @@ func (m historyHabitatrelateMods) UnsetOrganizationID() HistoryHabitatrelateMod
// 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 historyHabitatrelateMods) RandomOrganizationID(f *faker.Faker) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.OrganizationID = 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 historyHabitatrelateMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -845,6 +837,59 @@ func (m historyHabitatrelateMods) RandomObjectid(f *faker.Faker) HistoryHabitatr
})
}
// Set the model columns to this value
func (m historyHabitatrelateMods) Created(val null.Val[time.Time]) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyHabitatrelateMods) CreatedFunc(f func() null.Val[time.Time]) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyHabitatrelateMods) UnsetCreated() HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.Created = 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 historyHabitatrelateMods) RandomCreated(f *faker.Faker) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.Created = 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 historyHabitatrelateMods) RandomCreatedNotNull(f *faker.Faker) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {
o.Created = 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 historyHabitatrelateMods) CreatedDate(val null.Val[int64]) HistoryHabitatrelateMod {
return HistoryHabitatrelateModFunc(func(_ context.Context, o *HistoryHabitatrelateTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryInspectionsampleModSlice) Apply(ctx context.Context, n *Histor
// HistoryInspectionsampleTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryInspectionsampleTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -47,6 +48,7 @@ type HistoryInspectionsampleTemplate struct {
Objectid func() int32
Processed func() null.Val[int16]
Sampleid func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -82,7 +84,7 @@ func (t HistoryInspectionsampleTemplate) setModelRels(o *models.HistoryInspectio
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryInspectionsamples = append(rel.R.HistoryInspectionsamples, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -94,7 +96,7 @@ func (o HistoryInspectionsampleTemplate) BuildSetter() *models.HistoryInspection
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -136,6 +138,10 @@ func (o HistoryInspectionsampleTemplate) BuildSetter() *models.HistoryInspection
val := o.Sampleid()
m.Sampleid = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -219,6 +225,9 @@ func (o HistoryInspectionsampleTemplate) Build() *models.HistoryInspectionsample
if o.Sampleid != nil {
m.Sampleid = o.Sampleid()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -260,6 +269,10 @@ func (o HistoryInspectionsampleTemplate) BuildMany(number int) models.HistoryIns
}
func ensureCreatableHistoryInspectionsample(m *models.HistoryInspectionsampleSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -276,25 +289,6 @@ func ensureCreatableHistoryInspectionsample(m *models.HistoryInspectionsampleSet
func (o *HistoryInspectionsampleTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryInspectionsample) error {
var err error
isOrganizationDone, _ := historyInspectionsampleRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyInspectionsampleRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -305,11 +299,30 @@ func (o *HistoryInspectionsampleTemplate) Create(ctx context.Context, exec bob.E
opt := o.BuildSetter()
ensureCreatableHistoryInspectionsample(opt)
if o.r.Organization == nil {
HistoryInspectionsampleMods.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.HistoryInspectionsamples.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
}
@ -398,6 +411,7 @@ func (m historyInspectionsampleMods) RandomizeAllColumns(f *faker.Faker) History
HistoryInspectionsampleMods.RandomObjectid(f),
HistoryInspectionsampleMods.RandomProcessed(f),
HistoryInspectionsampleMods.RandomSampleid(f),
HistoryInspectionsampleMods.RandomCreated(f),
HistoryInspectionsampleMods.RandomCreatedDate(f),
HistoryInspectionsampleMods.RandomCreatedUser(f),
HistoryInspectionsampleMods.RandomGeometryX(f),
@ -409,14 +423,14 @@ func (m historyInspectionsampleMods) RandomizeAllColumns(f *faker.Faker) History
}
// Set the model columns to this value
func (m historyInspectionsampleMods) OrganizationID(val null.Val[int32]) HistoryInspectionsampleMod {
func (m historyInspectionsampleMods) OrganizationID(val int32) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyInspectionsampleMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryInspectionsampleMod {
func (m historyInspectionsampleMods) OrganizationIDFunc(f func() int32) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.OrganizationID = f
})
@ -431,32 +445,10 @@ func (m historyInspectionsampleMods) UnsetOrganizationID() HistoryInspectionsamp
// 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 historyInspectionsampleMods) RandomOrganizationID(f *faker.Faker) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.OrganizationID = 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 historyInspectionsampleMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -969,6 +961,59 @@ func (m historyInspectionsampleMods) RandomSampleidNotNull(f *faker.Faker) Histo
})
}
// Set the model columns to this value
func (m historyInspectionsampleMods) Created(val null.Val[time.Time]) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyInspectionsampleMods) CreatedFunc(f func() null.Val[time.Time]) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyInspectionsampleMods) UnsetCreated() HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.Created = 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 historyInspectionsampleMods) RandomCreated(f *faker.Faker) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.Created = 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 historyInspectionsampleMods) RandomCreatedNotNull(f *faker.Faker) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {
o.Created = 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 historyInspectionsampleMods) CreatedDate(val null.Val[int64]) HistoryInspectionsampleMod {
return HistoryInspectionsampleModFunc(func(_ context.Context, o *HistoryInspectionsampleTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryInspectionsampledetailModSlice) Apply(ctx context.Context, n *
// HistoryInspectionsampledetailTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryInspectionsampledetailTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -58,6 +59,7 @@ type HistoryInspectionsampledetailTemplate struct {
Lpupcount func() null.Val[int16]
Objectid func() int32
Processed func() null.Val[int16]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -93,7 +95,7 @@ func (t HistoryInspectionsampledetailTemplate) setModelRels(o *models.HistoryIns
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryInspectionsampledetails = append(rel.R.HistoryInspectionsampledetails, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -105,7 +107,7 @@ func (o HistoryInspectionsampledetailTemplate) BuildSetter() *models.HistoryInsp
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Comments != nil {
val := o.Comments()
@ -191,6 +193,10 @@ func (o HistoryInspectionsampledetailTemplate) BuildSetter() *models.HistoryInsp
val := o.Processed()
m.Processed = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -307,6 +313,9 @@ func (o HistoryInspectionsampledetailTemplate) Build() *models.HistoryInspection
if o.Processed != nil {
m.Processed = o.Processed()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -348,6 +357,10 @@ func (o HistoryInspectionsampledetailTemplate) BuildMany(number int) models.Hist
}
func ensureCreatableHistoryInspectionsampledetail(m *models.HistoryInspectionsampledetailSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -364,25 +377,6 @@ func ensureCreatableHistoryInspectionsampledetail(m *models.HistoryInspectionsam
func (o *HistoryInspectionsampledetailTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryInspectionsampledetail) error {
var err error
isOrganizationDone, _ := historyInspectionsampledetailRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyInspectionsampledetailRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -393,11 +387,30 @@ func (o *HistoryInspectionsampledetailTemplate) Create(ctx context.Context, exec
opt := o.BuildSetter()
ensureCreatableHistoryInspectionsampledetail(opt)
if o.r.Organization == nil {
HistoryInspectionsampledetailMods.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.HistoryInspectionsampledetails.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
}
@ -497,6 +510,7 @@ func (m historyInspectionsampledetailMods) RandomizeAllColumns(f *faker.Faker) H
HistoryInspectionsampledetailMods.RandomLpupcount(f),
HistoryInspectionsampledetailMods.RandomObjectid(f),
HistoryInspectionsampledetailMods.RandomProcessed(f),
HistoryInspectionsampledetailMods.RandomCreated(f),
HistoryInspectionsampledetailMods.RandomCreatedDate(f),
HistoryInspectionsampledetailMods.RandomCreatedUser(f),
HistoryInspectionsampledetailMods.RandomGeometryX(f),
@ -508,14 +522,14 @@ func (m historyInspectionsampledetailMods) RandomizeAllColumns(f *faker.Faker) H
}
// Set the model columns to this value
func (m historyInspectionsampledetailMods) OrganizationID(val null.Val[int32]) HistoryInspectionsampledetailMod {
func (m historyInspectionsampledetailMods) OrganizationID(val int32) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyInspectionsampledetailMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryInspectionsampledetailMod {
func (m historyInspectionsampledetailMods) OrganizationIDFunc(f func() int32) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.OrganizationID = f
})
@ -530,32 +544,10 @@ func (m historyInspectionsampledetailMods) UnsetOrganizationID() HistoryInspecti
// 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 historyInspectionsampledetailMods) RandomOrganizationID(f *faker.Faker) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.OrganizationID = 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 historyInspectionsampledetailMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1651,6 +1643,59 @@ func (m historyInspectionsampledetailMods) RandomProcessedNotNull(f *faker.Faker
})
}
// Set the model columns to this value
func (m historyInspectionsampledetailMods) Created(val null.Val[time.Time]) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyInspectionsampledetailMods) CreatedFunc(f func() null.Val[time.Time]) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyInspectionsampledetailMods) UnsetCreated() HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.Created = 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 historyInspectionsampledetailMods) RandomCreated(f *faker.Faker) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.Created = 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 historyInspectionsampledetailMods) RandomCreatedNotNull(f *faker.Faker) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {
o.Created = 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 historyInspectionsampledetailMods) CreatedDate(val null.Val[int64]) HistoryInspectionsampledetailMod {
return HistoryInspectionsampledetailModFunc(func(_ context.Context, o *HistoryInspectionsampledetailTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryLinelocationModSlice) Apply(ctx context.Context, n *HistoryLin
// HistoryLinelocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryLinelocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Acres func() null.Val[float64]
Active func() null.Val[int16]
@ -81,6 +82,7 @@ type HistoryLinelocationTemplate struct {
WidthMeters func() null.Val[float64]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -116,7 +118,7 @@ func (t HistoryLinelocationTemplate) setModelRels(o *models.HistoryLinelocation)
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryLinelocations = append(rel.R.HistoryLinelocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -128,7 +130,7 @@ func (o HistoryLinelocationTemplate) BuildSetter() *models.HistoryLinelocationSe
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -306,6 +308,10 @@ func (o HistoryLinelocationTemplate) BuildSetter() *models.HistoryLinelocationSe
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -491,6 +497,9 @@ func (o HistoryLinelocationTemplate) Build() *models.HistoryLinelocation {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -532,6 +541,10 @@ func (o HistoryLinelocationTemplate) BuildMany(number int) models.HistoryLineloc
}
func ensureCreatableHistoryLinelocation(m *models.HistoryLinelocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -548,25 +561,6 @@ func ensureCreatableHistoryLinelocation(m *models.HistoryLinelocationSetter) {
func (o *HistoryLinelocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryLinelocation) error {
var err error
isOrganizationDone, _ := historyLinelocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyLinelocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -577,11 +571,30 @@ func (o *HistoryLinelocationTemplate) Create(ctx context.Context, exec bob.Execu
opt := o.BuildSetter()
ensureCreatableHistoryLinelocation(opt)
if o.r.Organization == nil {
HistoryLinelocationMods.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.HistoryLinelocations.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
}
@ -704,6 +717,7 @@ func (m historyLinelocationMods) RandomizeAllColumns(f *faker.Faker) HistoryLine
HistoryLinelocationMods.RandomWidthMeters(f),
HistoryLinelocationMods.RandomZone(f),
HistoryLinelocationMods.RandomZone2(f),
HistoryLinelocationMods.RandomCreated(f),
HistoryLinelocationMods.RandomCreatedDate(f),
HistoryLinelocationMods.RandomCreatedUser(f),
HistoryLinelocationMods.RandomGeometryX(f),
@ -715,14 +729,14 @@ func (m historyLinelocationMods) RandomizeAllColumns(f *faker.Faker) HistoryLine
}
// Set the model columns to this value
func (m historyLinelocationMods) OrganizationID(val null.Val[int32]) HistoryLinelocationMod {
func (m historyLinelocationMods) OrganizationID(val int32) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyLinelocationMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryLinelocationMod {
func (m historyLinelocationMods) OrganizationIDFunc(f func() int32) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.OrganizationID = f
})
@ -737,32 +751,10 @@ func (m historyLinelocationMods) UnsetOrganizationID() HistoryLinelocationMod {
// 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 historyLinelocationMods) RandomOrganizationID(f *faker.Faker) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.OrganizationID = 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 historyLinelocationMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -3077,6 +3069,59 @@ func (m historyLinelocationMods) RandomZone2NotNull(f *faker.Faker) HistoryLinel
})
}
// Set the model columns to this value
func (m historyLinelocationMods) Created(val null.Val[time.Time]) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyLinelocationMods) CreatedFunc(f func() null.Val[time.Time]) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyLinelocationMods) UnsetCreated() HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.Created = 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 historyLinelocationMods) RandomCreated(f *faker.Faker) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.Created = 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 historyLinelocationMods) RandomCreatedNotNull(f *faker.Faker) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {
o.Created = 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 historyLinelocationMods) CreatedDate(val null.Val[int64]) HistoryLinelocationMod {
return HistoryLinelocationModFunc(func(_ context.Context, o *HistoryLinelocationTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryLocationtrackingModSlice) Apply(ctx context.Context, n *Histor
// HistoryLocationtrackingTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryLocationtrackingTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accuracy func() null.Val[float64]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -45,6 +46,7 @@ type HistoryLocationtrackingTemplate struct {
Fieldtech func() null.Val[string]
Globalid func() null.Val[string]
Objectid func() int32
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -80,7 +82,7 @@ func (t HistoryLocationtrackingTemplate) setModelRels(o *models.HistoryLocationt
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryLocationtrackings = append(rel.R.HistoryLocationtrackings, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -92,7 +94,7 @@ func (o HistoryLocationtrackingTemplate) BuildSetter() *models.HistoryLocationtr
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accuracy != nil {
val := o.Accuracy()
@ -126,6 +128,10 @@ func (o HistoryLocationtrackingTemplate) BuildSetter() *models.HistoryLocationtr
val := o.Objectid()
m.Objectid = omit.From(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -203,6 +209,9 @@ func (o HistoryLocationtrackingTemplate) Build() *models.HistoryLocationtracking
if o.Objectid != nil {
m.Objectid = o.Objectid()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -244,6 +253,10 @@ func (o HistoryLocationtrackingTemplate) BuildMany(number int) models.HistoryLoc
}
func ensureCreatableHistoryLocationtracking(m *models.HistoryLocationtrackingSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -260,25 +273,6 @@ func ensureCreatableHistoryLocationtracking(m *models.HistoryLocationtrackingSet
func (o *HistoryLocationtrackingTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryLocationtracking) error {
var err error
isOrganizationDone, _ := historyLocationtrackingRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyLocationtrackingRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -289,11 +283,30 @@ func (o *HistoryLocationtrackingTemplate) Create(ctx context.Context, exec bob.E
opt := o.BuildSetter()
ensureCreatableHistoryLocationtracking(opt)
if o.r.Organization == nil {
HistoryLocationtrackingMods.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.HistoryLocationtrackings.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
}
@ -380,6 +393,7 @@ func (m historyLocationtrackingMods) RandomizeAllColumns(f *faker.Faker) History
HistoryLocationtrackingMods.RandomFieldtech(f),
HistoryLocationtrackingMods.RandomGlobalid(f),
HistoryLocationtrackingMods.RandomObjectid(f),
HistoryLocationtrackingMods.RandomCreated(f),
HistoryLocationtrackingMods.RandomCreatedDate(f),
HistoryLocationtrackingMods.RandomCreatedUser(f),
HistoryLocationtrackingMods.RandomGeometryX(f),
@ -391,14 +405,14 @@ func (m historyLocationtrackingMods) RandomizeAllColumns(f *faker.Faker) History
}
// Set the model columns to this value
func (m historyLocationtrackingMods) OrganizationID(val null.Val[int32]) HistoryLocationtrackingMod {
func (m historyLocationtrackingMods) OrganizationID(val int32) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyLocationtrackingMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryLocationtrackingMod {
func (m historyLocationtrackingMods) OrganizationIDFunc(f func() int32) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.OrganizationID = f
})
@ -413,32 +427,10 @@ func (m historyLocationtrackingMods) UnsetOrganizationID() HistoryLocationtracki
// 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 historyLocationtrackingMods) RandomOrganizationID(f *faker.Faker) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.OrganizationID = 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 historyLocationtrackingMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -845,6 +837,59 @@ func (m historyLocationtrackingMods) RandomObjectid(f *faker.Faker) HistoryLocat
})
}
// Set the model columns to this value
func (m historyLocationtrackingMods) Created(val null.Val[time.Time]) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyLocationtrackingMods) CreatedFunc(f func() null.Val[time.Time]) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyLocationtrackingMods) UnsetCreated() HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.Created = 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 historyLocationtrackingMods) RandomCreated(f *faker.Faker) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.Created = 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 historyLocationtrackingMods) RandomCreatedNotNull(f *faker.Faker) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {
o.Created = 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 historyLocationtrackingMods) CreatedDate(val null.Val[int64]) HistoryLocationtrackingMod {
return HistoryLocationtrackingModFunc(func(_ context.Context, o *HistoryLocationtrackingTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryMosquitoinspectionModSlice) Apply(ctx context.Context, n *Hist
// HistoryMosquitoinspectionTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryMosquitoinspectionTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Actiontaken func() null.Val[string]
Activity func() null.Val[string]
Adultact func() null.Val[string]
@ -88,6 +89,7 @@ type HistoryMosquitoinspectionTemplate struct {
Windspeed func() null.Val[float64]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -125,7 +127,7 @@ func (t HistoryMosquitoinspectionTemplate) setModelRels(o *models.HistoryMosquit
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryMosquitoinspections = append(rel.R.HistoryMosquitoinspections, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -137,7 +139,7 @@ func (o HistoryMosquitoinspectionTemplate) BuildSetter() *models.HistoryMosquito
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Actiontaken != nil {
val := o.Actiontaken()
@ -343,6 +345,10 @@ func (o HistoryMosquitoinspectionTemplate) BuildSetter() *models.HistoryMosquito
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -557,6 +563,9 @@ func (o HistoryMosquitoinspectionTemplate) Build() *models.HistoryMosquitoinspec
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -604,6 +613,10 @@ func (o HistoryMosquitoinspectionTemplate) BuildMany(number int) models.HistoryM
}
func ensureCreatableHistoryMosquitoinspection(m *models.HistoryMosquitoinspectionSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -620,25 +633,6 @@ func ensureCreatableHistoryMosquitoinspection(m *models.HistoryMosquitoinspectio
func (o *HistoryMosquitoinspectionTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryMosquitoinspection) error {
var err error
isOrganizationDone, _ := historyMosquitoinspectionRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyMosquitoinspectionRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -649,11 +643,30 @@ func (o *HistoryMosquitoinspectionTemplate) Create(ctx context.Context, exec bob
opt := o.BuildSetter()
ensureCreatableHistoryMosquitoinspection(opt)
if o.r.Organization == nil {
HistoryMosquitoinspectionMods.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.HistoryMosquitoinspections.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
}
@ -783,6 +796,7 @@ func (m historyMosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) Histo
HistoryMosquitoinspectionMods.RandomWindspeed(f),
HistoryMosquitoinspectionMods.RandomZone(f),
HistoryMosquitoinspectionMods.RandomZone2(f),
HistoryMosquitoinspectionMods.RandomCreated(f),
HistoryMosquitoinspectionMods.RandomCreatedDate(f),
HistoryMosquitoinspectionMods.RandomCreatedUser(f),
HistoryMosquitoinspectionMods.RandomGeometryX(f),
@ -796,14 +810,14 @@ func (m historyMosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) Histo
}
// Set the model columns to this value
func (m historyMosquitoinspectionMods) OrganizationID(val null.Val[int32]) HistoryMosquitoinspectionMod {
func (m historyMosquitoinspectionMods) OrganizationID(val int32) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyMosquitoinspectionMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryMosquitoinspectionMod {
func (m historyMosquitoinspectionMods) OrganizationIDFunc(f func() int32) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.OrganizationID = f
})
@ -818,32 +832,10 @@ func (m historyMosquitoinspectionMods) UnsetOrganizationID() HistoryMosquitoinsp
// 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 historyMosquitoinspectionMods) RandomOrganizationID(f *faker.Faker) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.OrganizationID = 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 historyMosquitoinspectionMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -3529,6 +3521,59 @@ func (m historyMosquitoinspectionMods) RandomZone2NotNull(f *faker.Faker) Histor
})
}
// Set the model columns to this value
func (m historyMosquitoinspectionMods) Created(val null.Val[time.Time]) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyMosquitoinspectionMods) CreatedFunc(f func() null.Val[time.Time]) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyMosquitoinspectionMods) UnsetCreated() HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.Created = 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 historyMosquitoinspectionMods) RandomCreated(f *faker.Faker) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.Created = 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 historyMosquitoinspectionMods) RandomCreatedNotNull(f *faker.Faker) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {
o.Created = 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 historyMosquitoinspectionMods) CreatedDate(val null.Val[int64]) HistoryMosquitoinspectionMod {
return HistoryMosquitoinspectionModFunc(func(_ context.Context, o *HistoryMosquitoinspectionTemplate) {

View file

@ -36,7 +36,7 @@ func (mods HistoryPointlocationModSlice) Apply(ctx context.Context, n *HistoryPo
// HistoryPointlocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryPointlocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -112,7 +112,7 @@ func (t HistoryPointlocationTemplate) setModelRels(o *models.HistoryPointlocatio
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryPointlocations = append(rel.R.HistoryPointlocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -124,7 +124,7 @@ func (o HistoryPointlocationTemplate) BuildSetter() *models.HistoryPointlocation
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -500,6 +500,10 @@ func (o HistoryPointlocationTemplate) BuildMany(number int) models.HistoryPointl
}
func ensureCreatableHistoryPointlocation(m *models.HistoryPointlocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -516,25 +520,6 @@ func ensureCreatableHistoryPointlocation(m *models.HistoryPointlocationSetter) {
func (o *HistoryPointlocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryPointlocation) error {
var err error
isOrganizationDone, _ := historyPointlocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyPointlocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -545,11 +530,30 @@ func (o *HistoryPointlocationTemplate) Create(ctx context.Context, exec bob.Exec
opt := o.BuildSetter()
ensureCreatableHistoryPointlocation(opt)
if o.r.Organization == nil {
HistoryPointlocationMods.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.HistoryPointlocations.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
}
@ -679,14 +683,14 @@ func (m historyPointlocationMods) RandomizeAllColumns(f *faker.Faker) HistoryPoi
}
// Set the model columns to this value
func (m historyPointlocationMods) OrganizationID(val null.Val[int32]) HistoryPointlocationMod {
func (m historyPointlocationMods) OrganizationID(val int32) HistoryPointlocationMod {
return HistoryPointlocationModFunc(func(_ context.Context, o *HistoryPointlocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyPointlocationMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryPointlocationMod {
func (m historyPointlocationMods) OrganizationIDFunc(f func() int32) HistoryPointlocationMod {
return HistoryPointlocationModFunc(func(_ context.Context, o *HistoryPointlocationTemplate) {
o.OrganizationID = f
})
@ -701,32 +705,10 @@ func (m historyPointlocationMods) UnsetOrganizationID() HistoryPointlocationMod
// 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 historyPointlocationMods) RandomOrganizationID(f *faker.Faker) HistoryPointlocationMod {
return HistoryPointlocationModFunc(func(_ context.Context, o *HistoryPointlocationTemplate) {
o.OrganizationID = 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 historyPointlocationMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryPointlocationMod {
return HistoryPointlocationModFunc(func(_ context.Context, o *HistoryPointlocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -36,7 +36,7 @@ func (mods HistoryPolygonlocationModSlice) Apply(ctx context.Context, n *History
// HistoryPolygonlocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryPolygonlocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Acres func() null.Val[float64]
Active func() null.Val[int16]
@ -110,7 +110,7 @@ func (t HistoryPolygonlocationTemplate) setModelRels(o *models.HistoryPolygonloc
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryPolygonlocations = append(rel.R.HistoryPolygonlocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -122,7 +122,7 @@ func (o HistoryPolygonlocationTemplate) BuildSetter() *models.HistoryPolygonloca
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -484,6 +484,10 @@ func (o HistoryPolygonlocationTemplate) BuildMany(number int) models.HistoryPoly
}
func ensureCreatableHistoryPolygonlocation(m *models.HistoryPolygonlocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -500,25 +504,6 @@ func ensureCreatableHistoryPolygonlocation(m *models.HistoryPolygonlocationSette
func (o *HistoryPolygonlocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryPolygonlocation) error {
var err error
isOrganizationDone, _ := historyPolygonlocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyPolygonlocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -529,11 +514,30 @@ func (o *HistoryPolygonlocationTemplate) Create(ctx context.Context, exec bob.Ex
opt := o.BuildSetter()
ensureCreatableHistoryPolygonlocation(opt)
if o.r.Organization == nil {
HistoryPolygonlocationMods.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.HistoryPolygonlocations.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
}
@ -661,14 +665,14 @@ func (m historyPolygonlocationMods) RandomizeAllColumns(f *faker.Faker) HistoryP
}
// Set the model columns to this value
func (m historyPolygonlocationMods) OrganizationID(val null.Val[int32]) HistoryPolygonlocationMod {
func (m historyPolygonlocationMods) OrganizationID(val int32) HistoryPolygonlocationMod {
return HistoryPolygonlocationModFunc(func(_ context.Context, o *HistoryPolygonlocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyPolygonlocationMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryPolygonlocationMod {
func (m historyPolygonlocationMods) OrganizationIDFunc(f func() int32) HistoryPolygonlocationMod {
return HistoryPolygonlocationModFunc(func(_ context.Context, o *HistoryPolygonlocationTemplate) {
o.OrganizationID = f
})
@ -683,32 +687,10 @@ func (m historyPolygonlocationMods) UnsetOrganizationID() HistoryPolygonlocation
// 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 historyPolygonlocationMods) RandomOrganizationID(f *faker.Faker) HistoryPolygonlocationMod {
return HistoryPolygonlocationModFunc(func(_ context.Context, o *HistoryPolygonlocationTemplate) {
o.OrganizationID = 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 historyPolygonlocationMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryPolygonlocationMod {
return HistoryPolygonlocationModFunc(func(_ context.Context, o *HistoryPolygonlocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryPoolModSlice) Apply(ctx context.Context, n *HistoryPoolTemplat
// HistoryPoolTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryPoolTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -58,6 +59,7 @@ type HistoryPoolTemplate struct {
Testmethod func() null.Val[string]
Testtech func() null.Val[string]
TrapdataID func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -96,7 +98,7 @@ func (t HistoryPoolTemplate) setModelRels(o *models.HistoryPool) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryPools = append(rel.R.HistoryPools, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -108,7 +110,7 @@ func (o HistoryPoolTemplate) BuildSetter() *models.HistoryPoolSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Comments != nil {
val := o.Comments()
@ -194,6 +196,10 @@ func (o HistoryPoolTemplate) BuildSetter() *models.HistoryPoolSetter {
val := o.TrapdataID()
m.TrapdataID = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -322,6 +328,9 @@ func (o HistoryPoolTemplate) Build() *models.HistoryPool {
if o.TrapdataID != nil {
m.TrapdataID = o.TrapdataID()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -372,6 +381,10 @@ func (o HistoryPoolTemplate) BuildMany(number int) models.HistoryPoolSlice {
}
func ensureCreatableHistoryPool(m *models.HistoryPoolSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -388,25 +401,6 @@ func ensureCreatableHistoryPool(m *models.HistoryPoolSetter) {
func (o *HistoryPoolTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryPool) error {
var err error
isOrganizationDone, _ := historyPoolRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyPoolRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -417,11 +411,30 @@ func (o *HistoryPoolTemplate) Create(ctx context.Context, exec bob.Executor) (*m
opt := o.BuildSetter()
ensureCreatableHistoryPool(opt)
if o.r.Organization == nil {
HistoryPoolMods.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.HistoryPools.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
}
@ -521,6 +534,7 @@ func (m historyPoolMods) RandomizeAllColumns(f *faker.Faker) HistoryPoolMod {
HistoryPoolMods.RandomTestmethod(f),
HistoryPoolMods.RandomTesttech(f),
HistoryPoolMods.RandomTrapdataID(f),
HistoryPoolMods.RandomCreated(f),
HistoryPoolMods.RandomCreatedDate(f),
HistoryPoolMods.RandomCreatedUser(f),
HistoryPoolMods.RandomGeometryX(f),
@ -535,14 +549,14 @@ func (m historyPoolMods) RandomizeAllColumns(f *faker.Faker) HistoryPoolMod {
}
// Set the model columns to this value
func (m historyPoolMods) OrganizationID(val null.Val[int32]) HistoryPoolMod {
func (m historyPoolMods) OrganizationID(val int32) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyPoolMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryPoolMod {
func (m historyPoolMods) OrganizationIDFunc(f func() int32) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.OrganizationID = f
})
@ -557,32 +571,10 @@ func (m historyPoolMods) UnsetOrganizationID() HistoryPoolMod {
// 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 historyPoolMods) RandomOrganizationID(f *faker.Faker) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.OrganizationID = 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 historyPoolMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1678,6 +1670,59 @@ func (m historyPoolMods) RandomTrapdataIDNotNull(f *faker.Faker) HistoryPoolMod
})
}
// Set the model columns to this value
func (m historyPoolMods) Created(val null.Val[time.Time]) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyPoolMods) CreatedFunc(f func() null.Val[time.Time]) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyPoolMods) UnsetCreated() HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.Created = 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 historyPoolMods) RandomCreated(f *faker.Faker) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.Created = 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 historyPoolMods) RandomCreatedNotNull(f *faker.Faker) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {
o.Created = 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 historyPoolMods) CreatedDate(val null.Val[int64]) HistoryPoolMod {
return HistoryPoolModFunc(func(_ context.Context, o *HistoryPoolTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryPooldetailModSlice) Apply(ctx context.Context, n *HistoryPoold
// HistoryPooldetailTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryPooldetailTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -47,6 +48,7 @@ type HistoryPooldetailTemplate struct {
PoolID func() null.Val[string]
Species func() null.Val[string]
TrapdataID func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -82,7 +84,7 @@ func (t HistoryPooldetailTemplate) setModelRels(o *models.HistoryPooldetail) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryPooldetails = append(rel.R.HistoryPooldetails, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -94,7 +96,7 @@ func (o HistoryPooldetailTemplate) BuildSetter() *models.HistoryPooldetailSetter
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -136,6 +138,10 @@ func (o HistoryPooldetailTemplate) BuildSetter() *models.HistoryPooldetailSetter
val := o.TrapdataID()
m.TrapdataID = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -219,6 +225,9 @@ func (o HistoryPooldetailTemplate) Build() *models.HistoryPooldetail {
if o.TrapdataID != nil {
m.TrapdataID = o.TrapdataID()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -260,6 +269,10 @@ func (o HistoryPooldetailTemplate) BuildMany(number int) models.HistoryPooldetai
}
func ensureCreatableHistoryPooldetail(m *models.HistoryPooldetailSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -276,25 +289,6 @@ func ensureCreatableHistoryPooldetail(m *models.HistoryPooldetailSetter) {
func (o *HistoryPooldetailTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryPooldetail) error {
var err error
isOrganizationDone, _ := historyPooldetailRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyPooldetailRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -305,11 +299,30 @@ func (o *HistoryPooldetailTemplate) Create(ctx context.Context, exec bob.Executo
opt := o.BuildSetter()
ensureCreatableHistoryPooldetail(opt)
if o.r.Organization == nil {
HistoryPooldetailMods.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.HistoryPooldetails.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
}
@ -398,6 +411,7 @@ func (m historyPooldetailMods) RandomizeAllColumns(f *faker.Faker) HistoryPoolde
HistoryPooldetailMods.RandomPoolID(f),
HistoryPooldetailMods.RandomSpecies(f),
HistoryPooldetailMods.RandomTrapdataID(f),
HistoryPooldetailMods.RandomCreated(f),
HistoryPooldetailMods.RandomCreatedDate(f),
HistoryPooldetailMods.RandomCreatedUser(f),
HistoryPooldetailMods.RandomGeometryX(f),
@ -409,14 +423,14 @@ func (m historyPooldetailMods) RandomizeAllColumns(f *faker.Faker) HistoryPoolde
}
// Set the model columns to this value
func (m historyPooldetailMods) OrganizationID(val null.Val[int32]) HistoryPooldetailMod {
func (m historyPooldetailMods) OrganizationID(val int32) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyPooldetailMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryPooldetailMod {
func (m historyPooldetailMods) OrganizationIDFunc(f func() int32) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.OrganizationID = f
})
@ -431,32 +445,10 @@ func (m historyPooldetailMods) UnsetOrganizationID() HistoryPooldetailMod {
// 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 historyPooldetailMods) RandomOrganizationID(f *faker.Faker) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.OrganizationID = 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 historyPooldetailMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -969,6 +961,59 @@ func (m historyPooldetailMods) RandomTrapdataIDNotNull(f *faker.Faker) HistoryPo
})
}
// Set the model columns to this value
func (m historyPooldetailMods) Created(val null.Val[time.Time]) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyPooldetailMods) CreatedFunc(f func() null.Val[time.Time]) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyPooldetailMods) UnsetCreated() HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.Created = 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 historyPooldetailMods) RandomCreated(f *faker.Faker) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.Created = 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 historyPooldetailMods) RandomCreatedNotNull(f *faker.Faker) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {
o.Created = 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 historyPooldetailMods) CreatedDate(val null.Val[int64]) HistoryPooldetailMod {
return HistoryPooldetailModFunc(func(_ context.Context, o *HistoryPooldetailTemplate) {

View file

@ -36,7 +36,7 @@ func (mods HistoryProposedtreatmentareaModSlice) Apply(ctx context.Context, n *H
// HistoryProposedtreatmentareaTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryProposedtreatmentareaTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Acres func() null.Val[float64]
Comments func() null.Val[string]
Completed func() null.Val[int16]
@ -101,7 +101,7 @@ func (t HistoryProposedtreatmentareaTemplate) setModelRels(o *models.HistoryProp
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryProposedtreatmentareas = append(rel.R.HistoryProposedtreatmentareas, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -113,7 +113,7 @@ func (o HistoryProposedtreatmentareaTemplate) BuildSetter() *models.HistoryPropo
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Acres != nil {
val := o.Acres()
@ -412,6 +412,10 @@ func (o HistoryProposedtreatmentareaTemplate) BuildMany(number int) models.Histo
}
func ensureCreatableHistoryProposedtreatmentarea(m *models.HistoryProposedtreatmentareaSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -428,25 +432,6 @@ func ensureCreatableHistoryProposedtreatmentarea(m *models.HistoryProposedtreatm
func (o *HistoryProposedtreatmentareaTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryProposedtreatmentarea) error {
var err error
isOrganizationDone, _ := historyProposedtreatmentareaRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyProposedtreatmentareaRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -457,11 +442,30 @@ func (o *HistoryProposedtreatmentareaTemplate) Create(ctx context.Context, exec
opt := o.BuildSetter()
ensureCreatableHistoryProposedtreatmentarea(opt)
if o.r.Organization == nil {
HistoryProposedtreatmentareaMods.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.HistoryProposedtreatmentareas.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
}
@ -580,14 +584,14 @@ func (m historyProposedtreatmentareaMods) RandomizeAllColumns(f *faker.Faker) Hi
}
// Set the model columns to this value
func (m historyProposedtreatmentareaMods) OrganizationID(val null.Val[int32]) HistoryProposedtreatmentareaMod {
func (m historyProposedtreatmentareaMods) OrganizationID(val int32) HistoryProposedtreatmentareaMod {
return HistoryProposedtreatmentareaModFunc(func(_ context.Context, o *HistoryProposedtreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyProposedtreatmentareaMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryProposedtreatmentareaMod {
func (m historyProposedtreatmentareaMods) OrganizationIDFunc(f func() int32) HistoryProposedtreatmentareaMod {
return HistoryProposedtreatmentareaModFunc(func(_ context.Context, o *HistoryProposedtreatmentareaTemplate) {
o.OrganizationID = f
})
@ -602,32 +606,10 @@ func (m historyProposedtreatmentareaMods) UnsetOrganizationID() HistoryProposedt
// 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 historyProposedtreatmentareaMods) RandomOrganizationID(f *faker.Faker) HistoryProposedtreatmentareaMod {
return HistoryProposedtreatmentareaModFunc(func(_ context.Context, o *HistoryProposedtreatmentareaTemplate) {
o.OrganizationID = 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 historyProposedtreatmentareaMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryProposedtreatmentareaMod {
return HistoryProposedtreatmentareaModFunc(func(_ context.Context, o *HistoryProposedtreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryQamosquitoinspectionModSlice) Apply(ctx context.Context, n *Hi
// HistoryQamosquitoinspectionTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryQamosquitoinspectionTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Acresbreeding func() null.Val[float64]
Actiontaken func() null.Val[string]
Adultactivity func() null.Val[int16]
@ -95,6 +96,7 @@ type HistoryQamosquitoinspectionTemplate struct {
Windspeed func() null.Val[float64]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -130,7 +132,7 @@ func (t HistoryQamosquitoinspectionTemplate) setModelRels(o *models.HistoryQamos
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryQamosquitoinspections = append(rel.R.HistoryQamosquitoinspections, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -142,7 +144,7 @@ func (o HistoryQamosquitoinspectionTemplate) BuildSetter() *models.HistoryQamosq
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Acresbreeding != nil {
val := o.Acresbreeding()
@ -376,6 +378,10 @@ func (o HistoryQamosquitoinspectionTemplate) BuildSetter() *models.HistoryQamosq
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -603,6 +609,9 @@ func (o HistoryQamosquitoinspectionTemplate) Build() *models.HistoryQamosquitoin
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -644,6 +653,10 @@ func (o HistoryQamosquitoinspectionTemplate) BuildMany(number int) models.Histor
}
func ensureCreatableHistoryQamosquitoinspection(m *models.HistoryQamosquitoinspectionSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -660,25 +673,6 @@ func ensureCreatableHistoryQamosquitoinspection(m *models.HistoryQamosquitoinspe
func (o *HistoryQamosquitoinspectionTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryQamosquitoinspection) error {
var err error
isOrganizationDone, _ := historyQamosquitoinspectionRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyQamosquitoinspectionRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -689,11 +683,30 @@ func (o *HistoryQamosquitoinspectionTemplate) Create(ctx context.Context, exec b
opt := o.BuildSetter()
ensureCreatableHistoryQamosquitoinspection(opt)
if o.r.Organization == nil {
HistoryQamosquitoinspectionMods.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.HistoryQamosquitoinspections.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
}
@ -830,6 +843,7 @@ func (m historyQamosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) His
HistoryQamosquitoinspectionMods.RandomWindspeed(f),
HistoryQamosquitoinspectionMods.RandomZone(f),
HistoryQamosquitoinspectionMods.RandomZone2(f),
HistoryQamosquitoinspectionMods.RandomCreated(f),
HistoryQamosquitoinspectionMods.RandomCreatedDate(f),
HistoryQamosquitoinspectionMods.RandomCreatedUser(f),
HistoryQamosquitoinspectionMods.RandomGeometryX(f),
@ -841,14 +855,14 @@ func (m historyQamosquitoinspectionMods) RandomizeAllColumns(f *faker.Faker) His
}
// Set the model columns to this value
func (m historyQamosquitoinspectionMods) OrganizationID(val null.Val[int32]) HistoryQamosquitoinspectionMod {
func (m historyQamosquitoinspectionMods) OrganizationID(val int32) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyQamosquitoinspectionMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryQamosquitoinspectionMod {
func (m historyQamosquitoinspectionMods) OrganizationIDFunc(f func() int32) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.OrganizationID = f
})
@ -863,32 +877,10 @@ func (m historyQamosquitoinspectionMods) UnsetOrganizationID() HistoryQamosquito
// 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 historyQamosquitoinspectionMods) RandomOrganizationID(f *faker.Faker) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.OrganizationID = 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 historyQamosquitoinspectionMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -3945,6 +3937,59 @@ func (m historyQamosquitoinspectionMods) RandomZone2NotNull(f *faker.Faker) Hist
})
}
// Set the model columns to this value
func (m historyQamosquitoinspectionMods) Created(val null.Val[time.Time]) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyQamosquitoinspectionMods) CreatedFunc(f func() null.Val[time.Time]) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyQamosquitoinspectionMods) UnsetCreated() HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.Created = 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 historyQamosquitoinspectionMods) RandomCreated(f *faker.Faker) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.Created = 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 historyQamosquitoinspectionMods) RandomCreatedNotNull(f *faker.Faker) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {
o.Created = 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 historyQamosquitoinspectionMods) CreatedDate(val null.Val[int64]) HistoryQamosquitoinspectionMod {
return HistoryQamosquitoinspectionModFunc(func(_ context.Context, o *HistoryQamosquitoinspectionTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryRodentlocationModSlice) Apply(ctx context.Context, n *HistoryR
// HistoryRodentlocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryRodentlocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -62,6 +63,7 @@ type HistoryRodentlocationTemplate struct {
Usetype func() null.Val[string]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -98,7 +100,7 @@ func (t HistoryRodentlocationTemplate) setModelRels(o *models.HistoryRodentlocat
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryRodentlocations = append(rel.R.HistoryRodentlocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -110,7 +112,7 @@ func (o HistoryRodentlocationTemplate) BuildSetter() *models.HistoryRodentlocati
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -212,6 +214,10 @@ func (o HistoryRodentlocationTemplate) BuildSetter() *models.HistoryRodentlocati
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -344,6 +350,9 @@ func (o HistoryRodentlocationTemplate) Build() *models.HistoryRodentlocation {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -388,6 +397,10 @@ func (o HistoryRodentlocationTemplate) BuildMany(number int) models.HistoryRoden
}
func ensureCreatableHistoryRodentlocation(m *models.HistoryRodentlocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -404,25 +417,6 @@ func ensureCreatableHistoryRodentlocation(m *models.HistoryRodentlocationSetter)
func (o *HistoryRodentlocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryRodentlocation) error {
var err error
isOrganizationDone, _ := historyRodentlocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyRodentlocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -433,11 +427,30 @@ func (o *HistoryRodentlocationTemplate) Create(ctx context.Context, exec bob.Exe
opt := o.BuildSetter()
ensureCreatableHistoryRodentlocation(opt)
if o.r.Organization == nil {
HistoryRodentlocationMods.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.HistoryRodentlocations.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
}
@ -541,6 +554,7 @@ func (m historyRodentlocationMods) RandomizeAllColumns(f *faker.Faker) HistoryRo
HistoryRodentlocationMods.RandomUsetype(f),
HistoryRodentlocationMods.RandomZone(f),
HistoryRodentlocationMods.RandomZone2(f),
HistoryRodentlocationMods.RandomCreated(f),
HistoryRodentlocationMods.RandomCreatedDate(f),
HistoryRodentlocationMods.RandomCreatedUser(f),
HistoryRodentlocationMods.RandomGeometryX(f),
@ -553,14 +567,14 @@ func (m historyRodentlocationMods) RandomizeAllColumns(f *faker.Faker) HistoryRo
}
// Set the model columns to this value
func (m historyRodentlocationMods) OrganizationID(val null.Val[int32]) HistoryRodentlocationMod {
func (m historyRodentlocationMods) OrganizationID(val int32) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyRodentlocationMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryRodentlocationMod {
func (m historyRodentlocationMods) OrganizationIDFunc(f func() int32) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.OrganizationID = f
})
@ -575,32 +589,10 @@ func (m historyRodentlocationMods) UnsetOrganizationID() HistoryRodentlocationMo
// 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 historyRodentlocationMods) RandomOrganizationID(f *faker.Faker) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.OrganizationID = 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 historyRodentlocationMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1908,6 +1900,59 @@ func (m historyRodentlocationMods) RandomZone2NotNull(f *faker.Faker) HistoryRod
})
}
// Set the model columns to this value
func (m historyRodentlocationMods) Created(val null.Val[time.Time]) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyRodentlocationMods) CreatedFunc(f func() null.Val[time.Time]) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyRodentlocationMods) UnsetCreated() HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.Created = 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 historyRodentlocationMods) RandomCreated(f *faker.Faker) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.Created = 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 historyRodentlocationMods) RandomCreatedNotNull(f *faker.Faker) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {
o.Created = 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 historyRodentlocationMods) CreatedDate(val null.Val[int64]) HistoryRodentlocationMod {
return HistoryRodentlocationModFunc(func(_ context.Context, o *HistoryRodentlocationTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistorySamplecollectionModSlice) Apply(ctx context.Context, n *Histor
// HistorySamplecollectionTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistorySamplecollectionTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Activity func() null.Val[string]
Avetemp func() null.Val[float64]
Chickenid func() null.Val[string]
@ -79,6 +80,7 @@ type HistorySamplecollectionTemplate struct {
Windspeed func() null.Val[float64]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -114,7 +116,7 @@ func (t HistorySamplecollectionTemplate) setModelRels(o *models.HistorySamplecol
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistorySamplecollections = append(rel.R.HistorySamplecollections, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -126,7 +128,7 @@ func (o HistorySamplecollectionTemplate) BuildSetter() *models.HistorySamplecoll
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Activity != nil {
val := o.Activity()
@ -296,6 +298,10 @@ func (o HistorySamplecollectionTemplate) BuildSetter() *models.HistorySamplecoll
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -475,6 +481,9 @@ func (o HistorySamplecollectionTemplate) Build() *models.HistorySamplecollection
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -516,6 +525,10 @@ func (o HistorySamplecollectionTemplate) BuildMany(number int) models.HistorySam
}
func ensureCreatableHistorySamplecollection(m *models.HistorySamplecollectionSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -532,25 +545,6 @@ func ensureCreatableHistorySamplecollection(m *models.HistorySamplecollectionSet
func (o *HistorySamplecollectionTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistorySamplecollection) error {
var err error
isOrganizationDone, _ := historySamplecollectionRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historySamplecollectionRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -561,11 +555,30 @@ func (o *HistorySamplecollectionTemplate) Create(ctx context.Context, exec bob.E
opt := o.BuildSetter()
ensureCreatableHistorySamplecollection(opt)
if o.r.Organization == nil {
HistorySamplecollectionMods.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.HistorySamplecollections.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
}
@ -686,6 +699,7 @@ func (m historySamplecollectionMods) RandomizeAllColumns(f *faker.Faker) History
HistorySamplecollectionMods.RandomWindspeed(f),
HistorySamplecollectionMods.RandomZone(f),
HistorySamplecollectionMods.RandomZone2(f),
HistorySamplecollectionMods.RandomCreated(f),
HistorySamplecollectionMods.RandomCreatedDate(f),
HistorySamplecollectionMods.RandomCreatedUser(f),
HistorySamplecollectionMods.RandomGeometryX(f),
@ -697,14 +711,14 @@ func (m historySamplecollectionMods) RandomizeAllColumns(f *faker.Faker) History
}
// Set the model columns to this value
func (m historySamplecollectionMods) OrganizationID(val null.Val[int32]) HistorySamplecollectionMod {
func (m historySamplecollectionMods) OrganizationID(val int32) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historySamplecollectionMods) OrganizationIDFunc(f func() null.Val[int32]) HistorySamplecollectionMod {
func (m historySamplecollectionMods) OrganizationIDFunc(f func() int32) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.OrganizationID = f
})
@ -719,32 +733,10 @@ func (m historySamplecollectionMods) UnsetOrganizationID() HistorySamplecollecti
// 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 historySamplecollectionMods) RandomOrganizationID(f *faker.Faker) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.OrganizationID = 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 historySamplecollectionMods) RandomOrganizationIDNotNull(f *faker.Faker) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -2953,6 +2945,59 @@ func (m historySamplecollectionMods) RandomZone2NotNull(f *faker.Faker) HistoryS
})
}
// Set the model columns to this value
func (m historySamplecollectionMods) Created(val null.Val[time.Time]) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historySamplecollectionMods) CreatedFunc(f func() null.Val[time.Time]) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historySamplecollectionMods) UnsetCreated() HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.Created = 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 historySamplecollectionMods) RandomCreated(f *faker.Faker) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.Created = 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 historySamplecollectionMods) RandomCreatedNotNull(f *faker.Faker) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {
o.Created = 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 historySamplecollectionMods) CreatedDate(val null.Val[int64]) HistorySamplecollectionMod {
return HistorySamplecollectionModFunc(func(_ context.Context, o *HistorySamplecollectionTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistorySamplelocationModSlice) Apply(ctx context.Context, n *HistoryS
// HistorySamplelocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistorySamplelocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -57,6 +58,7 @@ type HistorySamplelocationTemplate struct {
Usetype func() null.Val[string]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -92,7 +94,7 @@ func (t HistorySamplelocationTemplate) setModelRels(o *models.HistorySamplelocat
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistorySamplelocations = append(rel.R.HistorySamplelocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -104,7 +106,7 @@ func (o HistorySamplelocationTemplate) BuildSetter() *models.HistorySamplelocati
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -186,6 +188,10 @@ func (o HistorySamplelocationTemplate) BuildSetter() *models.HistorySamplelocati
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -299,6 +305,9 @@ func (o HistorySamplelocationTemplate) Build() *models.HistorySamplelocation {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -340,6 +349,10 @@ func (o HistorySamplelocationTemplate) BuildMany(number int) models.HistorySampl
}
func ensureCreatableHistorySamplelocation(m *models.HistorySamplelocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -356,25 +369,6 @@ func ensureCreatableHistorySamplelocation(m *models.HistorySamplelocationSetter)
func (o *HistorySamplelocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistorySamplelocation) error {
var err error
isOrganizationDone, _ := historySamplelocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historySamplelocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -385,11 +379,30 @@ func (o *HistorySamplelocationTemplate) Create(ctx context.Context, exec bob.Exe
opt := o.BuildSetter()
ensureCreatableHistorySamplelocation(opt)
if o.r.Organization == nil {
HistorySamplelocationMods.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.HistorySamplelocations.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
}
@ -488,6 +501,7 @@ func (m historySamplelocationMods) RandomizeAllColumns(f *faker.Faker) HistorySa
HistorySamplelocationMods.RandomUsetype(f),
HistorySamplelocationMods.RandomZone(f),
HistorySamplelocationMods.RandomZone2(f),
HistorySamplelocationMods.RandomCreated(f),
HistorySamplelocationMods.RandomCreatedDate(f),
HistorySamplelocationMods.RandomCreatedUser(f),
HistorySamplelocationMods.RandomGeometryX(f),
@ -499,14 +513,14 @@ func (m historySamplelocationMods) RandomizeAllColumns(f *faker.Faker) HistorySa
}
// Set the model columns to this value
func (m historySamplelocationMods) OrganizationID(val null.Val[int32]) HistorySamplelocationMod {
func (m historySamplelocationMods) OrganizationID(val int32) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historySamplelocationMods) OrganizationIDFunc(f func() null.Val[int32]) HistorySamplelocationMod {
func (m historySamplelocationMods) OrganizationIDFunc(f func() int32) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.OrganizationID = f
})
@ -521,32 +535,10 @@ func (m historySamplelocationMods) UnsetOrganizationID() HistorySamplelocationMo
// 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 historySamplelocationMods) RandomOrganizationID(f *faker.Faker) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.OrganizationID = 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 historySamplelocationMods) RandomOrganizationIDNotNull(f *faker.Faker) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1589,6 +1581,59 @@ func (m historySamplelocationMods) RandomZone2NotNull(f *faker.Faker) HistorySam
})
}
// Set the model columns to this value
func (m historySamplelocationMods) Created(val null.Val[time.Time]) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historySamplelocationMods) CreatedFunc(f func() null.Val[time.Time]) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historySamplelocationMods) UnsetCreated() HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.Created = 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 historySamplelocationMods) RandomCreated(f *faker.Faker) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.Created = 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 historySamplelocationMods) RandomCreatedNotNull(f *faker.Faker) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {
o.Created = 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 historySamplelocationMods) CreatedDate(val null.Val[int64]) HistorySamplelocationMod {
return HistorySamplelocationModFunc(func(_ context.Context, o *HistorySamplelocationTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryServicerequestModSlice) Apply(ctx context.Context, n *HistoryS
// HistoryServicerequestTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryServicerequestTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accepted func() null.Val[int16]
Acceptedby func() null.Val[string]
Accepteddate func() null.Val[int64]
@ -115,6 +116,7 @@ type HistoryServicerequestTemplate struct {
Yvalue func() null.Val[string]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -154,7 +156,7 @@ func (t HistoryServicerequestTemplate) setModelRels(o *models.HistoryServicerequ
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryServicerequests = append(rel.R.HistoryServicerequests, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -166,7 +168,7 @@ func (o HistoryServicerequestTemplate) BuildSetter() *models.HistoryServicereque
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accepted != nil {
val := o.Accepted()
@ -480,6 +482,10 @@ func (o HistoryServicerequestTemplate) BuildSetter() *models.HistoryServicereque
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -783,6 +789,9 @@ func (o HistoryServicerequestTemplate) Build() *models.HistoryServicerequest {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -836,6 +845,10 @@ func (o HistoryServicerequestTemplate) BuildMany(number int) models.HistoryServi
}
func ensureCreatableHistoryServicerequest(m *models.HistoryServicerequestSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -852,25 +865,6 @@ func ensureCreatableHistoryServicerequest(m *models.HistoryServicerequestSetter)
func (o *HistoryServicerequestTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryServicerequest) error {
var err error
isOrganizationDone, _ := historyServicerequestRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyServicerequestRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -881,11 +875,30 @@ func (o *HistoryServicerequestTemplate) Create(ctx context.Context, exec bob.Exe
opt := o.BuildSetter()
ensureCreatableHistoryServicerequest(opt)
if o.r.Organization == nil {
HistoryServicerequestMods.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.HistoryServicerequests.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
}
@ -1042,6 +1055,7 @@ func (m historyServicerequestMods) RandomizeAllColumns(f *faker.Faker) HistorySe
HistoryServicerequestMods.RandomYvalue(f),
HistoryServicerequestMods.RandomZone(f),
HistoryServicerequestMods.RandomZone2(f),
HistoryServicerequestMods.RandomCreated(f),
HistoryServicerequestMods.RandomCreatedDate(f),
HistoryServicerequestMods.RandomCreatedUser(f),
HistoryServicerequestMods.RandomGeometryX(f),
@ -1057,14 +1071,14 @@ func (m historyServicerequestMods) RandomizeAllColumns(f *faker.Faker) HistorySe
}
// Set the model columns to this value
func (m historyServicerequestMods) OrganizationID(val null.Val[int32]) HistoryServicerequestMod {
func (m historyServicerequestMods) OrganizationID(val int32) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyServicerequestMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryServicerequestMod {
func (m historyServicerequestMods) OrganizationIDFunc(f func() int32) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.OrganizationID = f
})
@ -1079,32 +1093,10 @@ func (m historyServicerequestMods) UnsetOrganizationID() HistoryServicerequestMo
// 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 historyServicerequestMods) RandomOrganizationID(f *faker.Faker) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.OrganizationID = 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 historyServicerequestMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -5221,6 +5213,59 @@ func (m historyServicerequestMods) RandomZone2NotNull(f *faker.Faker) HistorySer
})
}
// Set the model columns to this value
func (m historyServicerequestMods) Created(val null.Val[time.Time]) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyServicerequestMods) CreatedFunc(f func() null.Val[time.Time]) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyServicerequestMods) UnsetCreated() HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.Created = 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 historyServicerequestMods) RandomCreated(f *faker.Faker) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.Created = 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 historyServicerequestMods) RandomCreatedNotNull(f *faker.Faker) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {
o.Created = 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 historyServicerequestMods) CreatedDate(val null.Val[int64]) HistoryServicerequestMod {
return HistoryServicerequestModFunc(func(_ context.Context, o *HistoryServicerequestTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistorySpeciesabundanceModSlice) Apply(ctx context.Context, n *Histor
// HistorySpeciesabundanceTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistorySpeciesabundanceTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Bloodedfem func() null.Val[int16]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -56,6 +57,7 @@ type HistorySpeciesabundanceTemplate struct {
Total func() null.Val[int64]
TrapdataID func() null.Val[string]
Unknown func() null.Val[int16]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -97,7 +99,7 @@ func (t HistorySpeciesabundanceTemplate) setModelRels(o *models.HistorySpeciesab
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistorySpeciesabundances = append(rel.R.HistorySpeciesabundances, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -109,7 +111,7 @@ func (o HistorySpeciesabundanceTemplate) BuildSetter() *models.HistorySpeciesabu
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Bloodedfem != nil {
val := o.Bloodedfem()
@ -187,6 +189,10 @@ func (o HistorySpeciesabundanceTemplate) BuildSetter() *models.HistorySpeciesabu
val := o.Unknown()
m.Unknown = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -321,6 +327,9 @@ func (o HistorySpeciesabundanceTemplate) Build() *models.HistorySpeciesabundance
if o.Unknown != nil {
m.Unknown = o.Unknown()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -380,6 +389,10 @@ func (o HistorySpeciesabundanceTemplate) BuildMany(number int) models.HistorySpe
}
func ensureCreatableHistorySpeciesabundance(m *models.HistorySpeciesabundanceSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -396,25 +409,6 @@ func ensureCreatableHistorySpeciesabundance(m *models.HistorySpeciesabundanceSet
func (o *HistorySpeciesabundanceTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistorySpeciesabundance) error {
var err error
isOrganizationDone, _ := historySpeciesabundanceRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historySpeciesabundanceRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -425,11 +419,30 @@ func (o *HistorySpeciesabundanceTemplate) Create(ctx context.Context, exec bob.E
opt := o.BuildSetter()
ensureCreatableHistorySpeciesabundance(opt)
if o.r.Organization == nil {
HistorySpeciesabundanceMods.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.HistorySpeciesabundances.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
}
@ -527,6 +540,7 @@ func (m historySpeciesabundanceMods) RandomizeAllColumns(f *faker.Faker) History
HistorySpeciesabundanceMods.RandomTotal(f),
HistorySpeciesabundanceMods.RandomTrapdataID(f),
HistorySpeciesabundanceMods.RandomUnknown(f),
HistorySpeciesabundanceMods.RandomCreated(f),
HistorySpeciesabundanceMods.RandomCreatedDate(f),
HistorySpeciesabundanceMods.RandomCreatedUser(f),
HistorySpeciesabundanceMods.RandomGeometryX(f),
@ -544,14 +558,14 @@ func (m historySpeciesabundanceMods) RandomizeAllColumns(f *faker.Faker) History
}
// Set the model columns to this value
func (m historySpeciesabundanceMods) OrganizationID(val null.Val[int32]) HistorySpeciesabundanceMod {
func (m historySpeciesabundanceMods) OrganizationID(val int32) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historySpeciesabundanceMods) OrganizationIDFunc(f func() null.Val[int32]) HistorySpeciesabundanceMod {
func (m historySpeciesabundanceMods) OrganizationIDFunc(f func() int32) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.OrganizationID = f
})
@ -566,32 +580,10 @@ func (m historySpeciesabundanceMods) UnsetOrganizationID() HistorySpeciesabundan
// 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 historySpeciesabundanceMods) RandomOrganizationID(f *faker.Faker) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.OrganizationID = 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 historySpeciesabundanceMods) RandomOrganizationIDNotNull(f *faker.Faker) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1581,6 +1573,59 @@ func (m historySpeciesabundanceMods) RandomUnknownNotNull(f *faker.Faker) Histor
})
}
// Set the model columns to this value
func (m historySpeciesabundanceMods) Created(val null.Val[time.Time]) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historySpeciesabundanceMods) CreatedFunc(f func() null.Val[time.Time]) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historySpeciesabundanceMods) UnsetCreated() HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.Created = 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 historySpeciesabundanceMods) RandomCreated(f *faker.Faker) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.Created = 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 historySpeciesabundanceMods) RandomCreatedNotNull(f *faker.Faker) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {
o.Created = 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 historySpeciesabundanceMods) CreatedDate(val null.Val[int64]) HistorySpeciesabundanceMod {
return HistorySpeciesabundanceModFunc(func(_ context.Context, o *HistorySpeciesabundanceTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryStormdrainModSlice) Apply(ctx context.Context, n *HistoryStorm
// HistoryStormdrainTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryStormdrainTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -52,6 +53,7 @@ type HistoryStormdrainTemplate struct {
Type func() null.Val[string]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -87,7 +89,7 @@ func (t HistoryStormdrainTemplate) setModelRels(o *models.HistoryStormdrain) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryStormdrains = append(rel.R.HistoryStormdrains, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -99,7 +101,7 @@ func (o HistoryStormdrainTemplate) BuildSetter() *models.HistoryStormdrainSetter
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -161,6 +163,10 @@ func (o HistoryStormdrainTemplate) BuildSetter() *models.HistoryStormdrainSetter
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -259,6 +265,9 @@ func (o HistoryStormdrainTemplate) Build() *models.HistoryStormdrain {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -300,6 +309,10 @@ func (o HistoryStormdrainTemplate) BuildMany(number int) models.HistoryStormdrai
}
func ensureCreatableHistoryStormdrain(m *models.HistoryStormdrainSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -316,25 +329,6 @@ func ensureCreatableHistoryStormdrain(m *models.HistoryStormdrainSetter) {
func (o *HistoryStormdrainTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryStormdrain) error {
var err error
isOrganizationDone, _ := historyStormdrainRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyStormdrainRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -345,11 +339,30 @@ func (o *HistoryStormdrainTemplate) Create(ctx context.Context, exec bob.Executo
opt := o.BuildSetter()
ensureCreatableHistoryStormdrain(opt)
if o.r.Organization == nil {
HistoryStormdrainMods.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.HistoryStormdrains.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
}
@ -443,6 +456,7 @@ func (m historyStormdrainMods) RandomizeAllColumns(f *faker.Faker) HistoryStormd
HistoryStormdrainMods.RandomType(f),
HistoryStormdrainMods.RandomZone(f),
HistoryStormdrainMods.RandomZone2(f),
HistoryStormdrainMods.RandomCreated(f),
HistoryStormdrainMods.RandomCreatedDate(f),
HistoryStormdrainMods.RandomCreatedUser(f),
HistoryStormdrainMods.RandomGeometryX(f),
@ -454,14 +468,14 @@ func (m historyStormdrainMods) RandomizeAllColumns(f *faker.Faker) HistoryStormd
}
// Set the model columns to this value
func (m historyStormdrainMods) OrganizationID(val null.Val[int32]) HistoryStormdrainMod {
func (m historyStormdrainMods) OrganizationID(val int32) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyStormdrainMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryStormdrainMod {
func (m historyStormdrainMods) OrganizationIDFunc(f func() int32) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.OrganizationID = f
})
@ -476,32 +490,10 @@ func (m historyStormdrainMods) UnsetOrganizationID() HistoryStormdrainMod {
// 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 historyStormdrainMods) RandomOrganizationID(f *faker.Faker) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.OrganizationID = 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 historyStormdrainMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1279,6 +1271,59 @@ func (m historyStormdrainMods) RandomZone2NotNull(f *faker.Faker) HistoryStormdr
})
}
// Set the model columns to this value
func (m historyStormdrainMods) Created(val null.Val[time.Time]) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyStormdrainMods) CreatedFunc(f func() null.Val[time.Time]) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyStormdrainMods) UnsetCreated() HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.Created = 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 historyStormdrainMods) RandomCreated(f *faker.Faker) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.Created = 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 historyStormdrainMods) RandomCreatedNotNull(f *faker.Faker) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {
o.Created = 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 historyStormdrainMods) CreatedDate(val null.Val[int64]) HistoryStormdrainMod {
return HistoryStormdrainModFunc(func(_ context.Context, o *HistoryStormdrainTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryTimecardModSlice) Apply(ctx context.Context, n *HistoryTimecar
// HistoryTimecardTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryTimecardTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Activity func() null.Val[string]
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
@ -60,6 +61,7 @@ type HistoryTimecardTemplate struct {
Traplocid func() null.Val[string]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -96,7 +98,7 @@ func (t HistoryTimecardTemplate) setModelRels(o *models.HistoryTimecard) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryTimecards = append(rel.R.HistoryTimecards, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -108,7 +110,7 @@ func (o HistoryTimecardTemplate) BuildSetter() *models.HistoryTimecardSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Activity != nil {
val := o.Activity()
@ -202,6 +204,10 @@ func (o HistoryTimecardTemplate) BuildSetter() *models.HistoryTimecardSetter {
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -328,6 +334,9 @@ func (o HistoryTimecardTemplate) Build() *models.HistoryTimecard {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -372,6 +381,10 @@ func (o HistoryTimecardTemplate) BuildMany(number int) models.HistoryTimecardSli
}
func ensureCreatableHistoryTimecard(m *models.HistoryTimecardSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -388,25 +401,6 @@ func ensureCreatableHistoryTimecard(m *models.HistoryTimecardSetter) {
func (o *HistoryTimecardTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryTimecard) error {
var err error
isOrganizationDone, _ := historyTimecardRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyTimecardRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -417,11 +411,30 @@ func (o *HistoryTimecardTemplate) Create(ctx context.Context, exec bob.Executor)
opt := o.BuildSetter()
ensureCreatableHistoryTimecard(opt)
if o.r.Organization == nil {
HistoryTimecardMods.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.HistoryTimecards.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
}
@ -523,6 +536,7 @@ func (m historyTimecardMods) RandomizeAllColumns(f *faker.Faker) HistoryTimecard
HistoryTimecardMods.RandomTraplocid(f),
HistoryTimecardMods.RandomZone(f),
HistoryTimecardMods.RandomZone2(f),
HistoryTimecardMods.RandomCreated(f),
HistoryTimecardMods.RandomCreatedDate(f),
HistoryTimecardMods.RandomCreatedUser(f),
HistoryTimecardMods.RandomGeometryX(f),
@ -535,14 +549,14 @@ func (m historyTimecardMods) RandomizeAllColumns(f *faker.Faker) HistoryTimecard
}
// Set the model columns to this value
func (m historyTimecardMods) OrganizationID(val null.Val[int32]) HistoryTimecardMod {
func (m historyTimecardMods) OrganizationID(val int32) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyTimecardMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryTimecardMod {
func (m historyTimecardMods) OrganizationIDFunc(f func() int32) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.OrganizationID = f
})
@ -557,32 +571,10 @@ func (m historyTimecardMods) UnsetOrganizationID() HistoryTimecardMod {
// 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 historyTimecardMods) RandomOrganizationID(f *faker.Faker) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.OrganizationID = 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 historyTimecardMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1784,6 +1776,59 @@ func (m historyTimecardMods) RandomZone2NotNull(f *faker.Faker) HistoryTimecardM
})
}
// Set the model columns to this value
func (m historyTimecardMods) Created(val null.Val[time.Time]) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyTimecardMods) CreatedFunc(f func() null.Val[time.Time]) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyTimecardMods) UnsetCreated() HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.Created = 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 historyTimecardMods) RandomCreated(f *faker.Faker) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.Created = 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 historyTimecardMods) RandomCreatedNotNull(f *faker.Faker) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {
o.Created = 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 historyTimecardMods) CreatedDate(val null.Val[int64]) HistoryTimecardMod {
return HistoryTimecardModFunc(func(_ context.Context, o *HistoryTimecardTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryTrapdatumModSlice) Apply(ctx context.Context, n *HistoryTrapda
// HistoryTrapdatumTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryTrapdatumTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Avetemp func() null.Val[float64]
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
@ -72,6 +73,7 @@ type HistoryTrapdatumTemplate struct {
Windspeed func() null.Val[float64]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -110,7 +112,7 @@ func (t HistoryTrapdatumTemplate) setModelRels(o *models.HistoryTrapdatum) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryTrapdata = append(rel.R.HistoryTrapdata, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -122,7 +124,7 @@ func (o HistoryTrapdatumTemplate) BuildSetter() *models.HistoryTrapdatumSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Avetemp != nil {
val := o.Avetemp()
@ -264,6 +266,10 @@ func (o HistoryTrapdatumTemplate) BuildSetter() *models.HistoryTrapdatumSetter {
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -434,6 +440,9 @@ func (o HistoryTrapdatumTemplate) Build() *models.HistoryTrapdatum {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -484,6 +493,10 @@ func (o HistoryTrapdatumTemplate) BuildMany(number int) models.HistoryTrapdatumS
}
func ensureCreatableHistoryTrapdatum(m *models.HistoryTrapdatumSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -500,25 +513,6 @@ func ensureCreatableHistoryTrapdatum(m *models.HistoryTrapdatumSetter) {
func (o *HistoryTrapdatumTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryTrapdatum) error {
var err error
isOrganizationDone, _ := historyTrapdatumRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyTrapdatumRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -529,11 +523,30 @@ func (o *HistoryTrapdatumTemplate) Create(ctx context.Context, exec bob.Executor
opt := o.BuildSetter()
ensureCreatableHistoryTrapdatum(opt)
if o.r.Organization == nil {
HistoryTrapdatumMods.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.HistoryTrapdata.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
}
@ -647,6 +660,7 @@ func (m historyTrapdatumMods) RandomizeAllColumns(f *faker.Faker) HistoryTrapdat
HistoryTrapdatumMods.RandomWindspeed(f),
HistoryTrapdatumMods.RandomZone(f),
HistoryTrapdatumMods.RandomZone2(f),
HistoryTrapdatumMods.RandomCreated(f),
HistoryTrapdatumMods.RandomCreatedDate(f),
HistoryTrapdatumMods.RandomCreatedUser(f),
HistoryTrapdatumMods.RandomGeometryX(f),
@ -661,14 +675,14 @@ func (m historyTrapdatumMods) RandomizeAllColumns(f *faker.Faker) HistoryTrapdat
}
// Set the model columns to this value
func (m historyTrapdatumMods) OrganizationID(val null.Val[int32]) HistoryTrapdatumMod {
func (m historyTrapdatumMods) OrganizationID(val int32) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyTrapdatumMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryTrapdatumMod {
func (m historyTrapdatumMods) OrganizationIDFunc(f func() int32) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.OrganizationID = f
})
@ -683,32 +697,10 @@ func (m historyTrapdatumMods) UnsetOrganizationID() HistoryTrapdatumMod {
// 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 historyTrapdatumMods) RandomOrganizationID(f *faker.Faker) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.OrganizationID = 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 historyTrapdatumMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -2546,6 +2538,59 @@ func (m historyTrapdatumMods) RandomZone2NotNull(f *faker.Faker) HistoryTrapdatu
})
}
// Set the model columns to this value
func (m historyTrapdatumMods) Created(val null.Val[time.Time]) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyTrapdatumMods) CreatedFunc(f func() null.Val[time.Time]) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyTrapdatumMods) UnsetCreated() HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.Created = 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 historyTrapdatumMods) RandomCreated(f *faker.Faker) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.Created = 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 historyTrapdatumMods) RandomCreatedNotNull(f *faker.Faker) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {
o.Created = 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 historyTrapdatumMods) CreatedDate(val null.Val[int64]) HistoryTrapdatumMod {
return HistoryTrapdatumModFunc(func(_ context.Context, o *HistoryTrapdatumTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryTraplocationModSlice) Apply(ctx context.Context, n *HistoryTra
// HistoryTraplocationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryTraplocationTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Accessdesc func() null.Val[string]
Active func() null.Val[int16]
Comments func() null.Val[string]
@ -57,6 +58,7 @@ type HistoryTraplocationTemplate struct {
Usetype func() null.Val[string]
Zone func() null.Val[string]
Zone2 func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -98,7 +100,7 @@ func (t HistoryTraplocationTemplate) setModelRels(o *models.HistoryTraplocation)
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryTraplocations = append(rel.R.HistoryTraplocations, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -110,7 +112,7 @@ func (o HistoryTraplocationTemplate) BuildSetter() *models.HistoryTraplocationSe
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Accessdesc != nil {
val := o.Accessdesc()
@ -192,6 +194,10 @@ func (o HistoryTraplocationTemplate) BuildSetter() *models.HistoryTraplocationSe
val := o.Zone2()
m.Zone2 = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -329,6 +335,9 @@ func (o HistoryTraplocationTemplate) Build() *models.HistoryTraplocation {
if o.Zone2 != nil {
m.Zone2 = o.Zone2()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -388,6 +397,10 @@ func (o HistoryTraplocationTemplate) BuildMany(number int) models.HistoryTraploc
}
func ensureCreatableHistoryTraplocation(m *models.HistoryTraplocationSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -404,25 +417,6 @@ func ensureCreatableHistoryTraplocation(m *models.HistoryTraplocationSetter) {
func (o *HistoryTraplocationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryTraplocation) error {
var err error
isOrganizationDone, _ := historyTraplocationRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyTraplocationRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -433,11 +427,30 @@ func (o *HistoryTraplocationTemplate) Create(ctx context.Context, exec bob.Execu
opt := o.BuildSetter()
ensureCreatableHistoryTraplocation(opt)
if o.r.Organization == nil {
HistoryTraplocationMods.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.HistoryTraplocations.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
}
@ -536,6 +549,7 @@ func (m historyTraplocationMods) RandomizeAllColumns(f *faker.Faker) HistoryTrap
HistoryTraplocationMods.RandomUsetype(f),
HistoryTraplocationMods.RandomZone(f),
HistoryTraplocationMods.RandomZone2(f),
HistoryTraplocationMods.RandomCreated(f),
HistoryTraplocationMods.RandomCreatedDate(f),
HistoryTraplocationMods.RandomCreatedUser(f),
HistoryTraplocationMods.RandomGeometryX(f),
@ -553,14 +567,14 @@ func (m historyTraplocationMods) RandomizeAllColumns(f *faker.Faker) HistoryTrap
}
// Set the model columns to this value
func (m historyTraplocationMods) OrganizationID(val null.Val[int32]) HistoryTraplocationMod {
func (m historyTraplocationMods) OrganizationID(val int32) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyTraplocationMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryTraplocationMod {
func (m historyTraplocationMods) OrganizationIDFunc(f func() int32) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.OrganizationID = f
})
@ -575,32 +589,10 @@ func (m historyTraplocationMods) UnsetOrganizationID() HistoryTraplocationMod {
// 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 historyTraplocationMods) RandomOrganizationID(f *faker.Faker) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.OrganizationID = 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 historyTraplocationMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1643,6 +1635,59 @@ func (m historyTraplocationMods) RandomZone2NotNull(f *faker.Faker) HistoryTrapl
})
}
// Set the model columns to this value
func (m historyTraplocationMods) Created(val null.Val[time.Time]) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyTraplocationMods) CreatedFunc(f func() null.Val[time.Time]) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyTraplocationMods) UnsetCreated() HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.Created = 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 historyTraplocationMods) RandomCreated(f *faker.Faker) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.Created = 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 historyTraplocationMods) RandomCreatedNotNull(f *faker.Faker) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {
o.Created = 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 historyTraplocationMods) CreatedDate(val null.Val[int64]) HistoryTraplocationMod {
return HistoryTraplocationModFunc(func(_ context.Context, o *HistoryTraplocationTemplate) {

View file

@ -36,7 +36,7 @@ func (mods HistoryTreatmentModSlice) Apply(ctx context.Context, n *HistoryTreatm
// HistoryTreatmentTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryTreatmentTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Activity func() null.Val[string]
Areaunit func() null.Val[string]
Avetemp func() null.Val[float64]
@ -122,7 +122,7 @@ func (t HistoryTreatmentTemplate) setModelRels(o *models.HistoryTreatment) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryTreatments = append(rel.R.HistoryTreatments, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -134,7 +134,7 @@ func (o HistoryTreatmentTemplate) BuildSetter() *models.HistoryTreatmentSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Activity != nil {
val := o.Activity()
@ -580,6 +580,10 @@ func (o HistoryTreatmentTemplate) BuildMany(number int) models.HistoryTreatmentS
}
func ensureCreatableHistoryTreatment(m *models.HistoryTreatmentSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -596,25 +600,6 @@ func ensureCreatableHistoryTreatment(m *models.HistoryTreatmentSetter) {
func (o *HistoryTreatmentTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryTreatment) error {
var err error
isOrganizationDone, _ := historyTreatmentRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyTreatmentRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -625,11 +610,30 @@ func (o *HistoryTreatmentTemplate) Create(ctx context.Context, exec bob.Executor
opt := o.BuildSetter()
ensureCreatableHistoryTreatment(opt)
if o.r.Organization == nil {
HistoryTreatmentMods.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.HistoryTreatments.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
}
@ -769,14 +773,14 @@ func (m historyTreatmentMods) RandomizeAllColumns(f *faker.Faker) HistoryTreatme
}
// Set the model columns to this value
func (m historyTreatmentMods) OrganizationID(val null.Val[int32]) HistoryTreatmentMod {
func (m historyTreatmentMods) OrganizationID(val int32) HistoryTreatmentMod {
return HistoryTreatmentModFunc(func(_ context.Context, o *HistoryTreatmentTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyTreatmentMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryTreatmentMod {
func (m historyTreatmentMods) OrganizationIDFunc(f func() int32) HistoryTreatmentMod {
return HistoryTreatmentModFunc(func(_ context.Context, o *HistoryTreatmentTemplate) {
o.OrganizationID = f
})
@ -791,32 +795,10 @@ func (m historyTreatmentMods) UnsetOrganizationID() HistoryTreatmentMod {
// 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 historyTreatmentMods) RandomOrganizationID(f *faker.Faker) HistoryTreatmentMod {
return HistoryTreatmentModFunc(func(_ context.Context, o *HistoryTreatmentTemplate) {
o.OrganizationID = 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 historyTreatmentMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryTreatmentMod {
return HistoryTreatmentModFunc(func(_ context.Context, o *HistoryTreatmentTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryTreatmentareaModSlice) Apply(ctx context.Context, n *HistoryTr
// HistoryTreatmentareaTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryTreatmentareaTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Comments func() null.Val[string]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -51,6 +52,7 @@ type HistoryTreatmentareaTemplate struct {
Treatdate func() null.Val[int64]
TreatID func() null.Val[string]
Type func() null.Val[string]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -86,7 +88,7 @@ func (t HistoryTreatmentareaTemplate) setModelRels(o *models.HistoryTreatmentare
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryTreatmentareas = append(rel.R.HistoryTreatmentareas, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -98,7 +100,7 @@ func (o HistoryTreatmentareaTemplate) BuildSetter() *models.HistoryTreatmentarea
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Comments != nil {
val := o.Comments()
@ -156,6 +158,10 @@ func (o HistoryTreatmentareaTemplate) BuildSetter() *models.HistoryTreatmentarea
val := o.Type()
m.Type = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -251,6 +257,9 @@ func (o HistoryTreatmentareaTemplate) Build() *models.HistoryTreatmentarea {
if o.Type != nil {
m.Type = o.Type()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -292,6 +301,10 @@ func (o HistoryTreatmentareaTemplate) BuildMany(number int) models.HistoryTreatm
}
func ensureCreatableHistoryTreatmentarea(m *models.HistoryTreatmentareaSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -308,25 +321,6 @@ func ensureCreatableHistoryTreatmentarea(m *models.HistoryTreatmentareaSetter) {
func (o *HistoryTreatmentareaTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryTreatmentarea) error {
var err error
isOrganizationDone, _ := historyTreatmentareaRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyTreatmentareaRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -337,11 +331,30 @@ func (o *HistoryTreatmentareaTemplate) Create(ctx context.Context, exec bob.Exec
opt := o.BuildSetter()
ensureCreatableHistoryTreatmentarea(opt)
if o.r.Organization == nil {
HistoryTreatmentareaMods.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.HistoryTreatmentareas.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
}
@ -434,6 +447,7 @@ func (m historyTreatmentareaMods) RandomizeAllColumns(f *faker.Faker) HistoryTre
HistoryTreatmentareaMods.RandomTreatdate(f),
HistoryTreatmentareaMods.RandomTreatID(f),
HistoryTreatmentareaMods.RandomType(f),
HistoryTreatmentareaMods.RandomCreated(f),
HistoryTreatmentareaMods.RandomCreatedDate(f),
HistoryTreatmentareaMods.RandomCreatedUser(f),
HistoryTreatmentareaMods.RandomGeometryX(f),
@ -445,14 +459,14 @@ func (m historyTreatmentareaMods) RandomizeAllColumns(f *faker.Faker) HistoryTre
}
// Set the model columns to this value
func (m historyTreatmentareaMods) OrganizationID(val null.Val[int32]) HistoryTreatmentareaMod {
func (m historyTreatmentareaMods) OrganizationID(val int32) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyTreatmentareaMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryTreatmentareaMod {
func (m historyTreatmentareaMods) OrganizationIDFunc(f func() int32) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.OrganizationID = f
})
@ -467,32 +481,10 @@ func (m historyTreatmentareaMods) UnsetOrganizationID() HistoryTreatmentareaMod
// 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 historyTreatmentareaMods) RandomOrganizationID(f *faker.Faker) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.OrganizationID = 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 historyTreatmentareaMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -1217,6 +1209,59 @@ func (m historyTreatmentareaMods) RandomTypeNotNull(f *faker.Faker) HistoryTreat
})
}
// Set the model columns to this value
func (m historyTreatmentareaMods) Created(val null.Val[time.Time]) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyTreatmentareaMods) CreatedFunc(f func() null.Val[time.Time]) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyTreatmentareaMods) UnsetCreated() HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.Created = 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 historyTreatmentareaMods) RandomCreated(f *faker.Faker) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.Created = 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 historyTreatmentareaMods) RandomCreatedNotNull(f *faker.Faker) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {
o.Created = 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 historyTreatmentareaMods) CreatedDate(val null.Val[int64]) HistoryTreatmentareaMod {
return HistoryTreatmentareaModFunc(func(_ context.Context, o *HistoryTreatmentareaTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryZoneModSlice) Apply(ctx context.Context, n *HistoryZoneTemplat
// HistoryZoneTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryZoneTemplate struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Active func() null.Val[int64]
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
@ -47,6 +48,7 @@ type HistoryZoneTemplate struct {
Objectid func() int32
ShapeArea func() null.Val[float64]
ShapeLength func() null.Val[float64]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -82,7 +84,7 @@ func (t HistoryZoneTemplate) setModelRels(o *models.HistoryZone) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryZones = append(rel.R.HistoryZones, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -94,7 +96,7 @@ func (o HistoryZoneTemplate) BuildSetter() *models.HistoryZoneSetter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Active != nil {
val := o.Active()
@ -136,6 +138,10 @@ func (o HistoryZoneTemplate) BuildSetter() *models.HistoryZoneSetter {
val := o.ShapeLength()
m.ShapeLength = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -219,6 +225,9 @@ func (o HistoryZoneTemplate) Build() *models.HistoryZone {
if o.ShapeLength != nil {
m.ShapeLength = o.ShapeLength()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -260,6 +269,10 @@ func (o HistoryZoneTemplate) BuildMany(number int) models.HistoryZoneSlice {
}
func ensureCreatableHistoryZone(m *models.HistoryZoneSetter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -276,25 +289,6 @@ func ensureCreatableHistoryZone(m *models.HistoryZoneSetter) {
func (o *HistoryZoneTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryZone) error {
var err error
isOrganizationDone, _ := historyZoneRelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyZoneRelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -305,11 +299,30 @@ func (o *HistoryZoneTemplate) Create(ctx context.Context, exec bob.Executor) (*m
opt := o.BuildSetter()
ensureCreatableHistoryZone(opt)
if o.r.Organization == nil {
HistoryZoneMods.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.HistoryZones.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
}
@ -398,6 +411,7 @@ func (m historyZoneMods) RandomizeAllColumns(f *faker.Faker) HistoryZoneMod {
HistoryZoneMods.RandomObjectid(f),
HistoryZoneMods.RandomShapeArea(f),
HistoryZoneMods.RandomShapeLength(f),
HistoryZoneMods.RandomCreated(f),
HistoryZoneMods.RandomCreatedDate(f),
HistoryZoneMods.RandomCreatedUser(f),
HistoryZoneMods.RandomGeometryX(f),
@ -409,14 +423,14 @@ func (m historyZoneMods) RandomizeAllColumns(f *faker.Faker) HistoryZoneMod {
}
// Set the model columns to this value
func (m historyZoneMods) OrganizationID(val null.Val[int32]) HistoryZoneMod {
func (m historyZoneMods) OrganizationID(val int32) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyZoneMods) OrganizationIDFunc(f func() null.Val[int32]) HistoryZoneMod {
func (m historyZoneMods) OrganizationIDFunc(f func() int32) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.OrganizationID = f
})
@ -431,32 +445,10 @@ func (m historyZoneMods) UnsetOrganizationID() HistoryZoneMod {
// 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 historyZoneMods) RandomOrganizationID(f *faker.Faker) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.OrganizationID = 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 historyZoneMods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -969,6 +961,59 @@ func (m historyZoneMods) RandomShapeLengthNotNull(f *faker.Faker) HistoryZoneMod
})
}
// Set the model columns to this value
func (m historyZoneMods) Created(val null.Val[time.Time]) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyZoneMods) CreatedFunc(f func() null.Val[time.Time]) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m historyZoneMods) UnsetCreated() HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.Created = 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 historyZoneMods) RandomCreated(f *faker.Faker) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.Created = 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 historyZoneMods) RandomCreatedNotNull(f *faker.Faker) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {
o.Created = 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 historyZoneMods) CreatedDate(val null.Val[int64]) HistoryZoneMod {
return HistoryZoneModFunc(func(_ context.Context, o *HistoryZoneTemplate) {

View file

@ -6,6 +6,7 @@ package factory
import (
"context"
"testing"
"time"
models "github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
@ -36,7 +37,7 @@ func (mods HistoryZones2ModSlice) Apply(ctx context.Context, n *HistoryZones2Tem
// HistoryZones2Template is an object representing the database table.
// all columns are optional and should be set by mods
type HistoryZones2Template struct {
OrganizationID func() null.Val[int32]
OrganizationID func() int32
Creationdate func() null.Val[int64]
Creator func() null.Val[string]
Editdate func() null.Val[int64]
@ -46,6 +47,7 @@ type HistoryZones2Template struct {
Objectid func() int32
ShapeArea func() null.Val[float64]
ShapeLength func() null.Val[float64]
Created func() null.Val[time.Time]
CreatedDate func() null.Val[int64]
CreatedUser func() null.Val[string]
GeometryX func() null.Val[float64]
@ -81,7 +83,7 @@ func (t HistoryZones2Template) setModelRels(o *models.HistoryZones2) {
if t.r.Organization != nil {
rel := t.r.Organization.o.Build()
rel.R.HistoryZones2s = append(rel.R.HistoryZones2s, o)
o.OrganizationID = null.From(rel.ID) // h2
o.OrganizationID = rel.ID // h2
o.R.Organization = rel
}
}
@ -93,7 +95,7 @@ func (o HistoryZones2Template) BuildSetter() *models.HistoryZones2Setter {
if o.OrganizationID != nil {
val := o.OrganizationID()
m.OrganizationID = omitnull.FromNull(val)
m.OrganizationID = omit.From(val)
}
if o.Creationdate != nil {
val := o.Creationdate()
@ -131,6 +133,10 @@ func (o HistoryZones2Template) BuildSetter() *models.HistoryZones2Setter {
val := o.ShapeLength()
m.ShapeLength = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omitnull.FromNull(val)
}
if o.CreatedDate != nil {
val := o.CreatedDate()
m.CreatedDate = omitnull.FromNull(val)
@ -211,6 +217,9 @@ func (o HistoryZones2Template) Build() *models.HistoryZones2 {
if o.ShapeLength != nil {
m.ShapeLength = o.ShapeLength()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.CreatedDate != nil {
m.CreatedDate = o.CreatedDate()
}
@ -252,6 +261,10 @@ func (o HistoryZones2Template) BuildMany(number int) models.HistoryZones2Slice {
}
func ensureCreatableHistoryZones2(m *models.HistoryZones2Setter) {
if !(m.OrganizationID.IsValue()) {
val := random_int32(nil)
m.OrganizationID = omit.From(val)
}
if !(m.Objectid.IsValue()) {
val := random_int32(nil)
m.Objectid = omit.From(val)
@ -268,25 +281,6 @@ func ensureCreatableHistoryZones2(m *models.HistoryZones2Setter) {
func (o *HistoryZones2Template) insertOptRels(ctx context.Context, exec bob.Executor, m *models.HistoryZones2) error {
var err error
isOrganizationDone, _ := historyZones2RelOrganizationCtx.Value(ctx)
if !isOrganizationDone && o.r.Organization != nil {
ctx = historyZones2RelOrganizationCtx.WithValue(ctx, true)
if o.r.Organization.o.alreadyPersisted {
m.R.Organization = o.r.Organization.o.Build()
} else {
var rel0 *models.Organization
rel0, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachOrganization(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
@ -297,11 +291,30 @@ func (o *HistoryZones2Template) Create(ctx context.Context, exec bob.Executor) (
opt := o.BuildSetter()
ensureCreatableHistoryZones2(opt)
if o.r.Organization == nil {
HistoryZones2Mods.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.HistoryZones2s.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
}
@ -389,6 +402,7 @@ func (m historyZones2Mods) RandomizeAllColumns(f *faker.Faker) HistoryZones2Mod
HistoryZones2Mods.RandomObjectid(f),
HistoryZones2Mods.RandomShapeArea(f),
HistoryZones2Mods.RandomShapeLength(f),
HistoryZones2Mods.RandomCreated(f),
HistoryZones2Mods.RandomCreatedDate(f),
HistoryZones2Mods.RandomCreatedUser(f),
HistoryZones2Mods.RandomGeometryX(f),
@ -400,14 +414,14 @@ func (m historyZones2Mods) RandomizeAllColumns(f *faker.Faker) HistoryZones2Mod
}
// Set the model columns to this value
func (m historyZones2Mods) OrganizationID(val null.Val[int32]) HistoryZones2Mod {
func (m historyZones2Mods) OrganizationID(val int32) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.OrganizationID = func() null.Val[int32] { return val }
o.OrganizationID = func() int32 { return val }
})
}
// Set the Column from the function
func (m historyZones2Mods) OrganizationIDFunc(f func() null.Val[int32]) HistoryZones2Mod {
func (m historyZones2Mods) OrganizationIDFunc(f func() int32) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.OrganizationID = f
})
@ -422,32 +436,10 @@ func (m historyZones2Mods) UnsetOrganizationID() HistoryZones2Mod {
// 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 historyZones2Mods) RandomOrganizationID(f *faker.Faker) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.OrganizationID = 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 historyZones2Mods) RandomOrganizationIDNotNull(f *faker.Faker) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.OrganizationID = func() null.Val[int32] {
if f == nil {
f = &defaultFaker
}
val := random_int32(f)
return null.From(val)
o.OrganizationID = func() int32 {
return random_int32(f)
}
})
}
@ -907,6 +899,59 @@ func (m historyZones2Mods) RandomShapeLengthNotNull(f *faker.Faker) HistoryZones
})
}
// Set the model columns to this value
func (m historyZones2Mods) Created(val null.Val[time.Time]) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.Created = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m historyZones2Mods) CreatedFunc(f func() null.Val[time.Time]) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.Created = f
})
}
// Clear any values for the column
func (m historyZones2Mods) UnsetCreated() HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.Created = 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 historyZones2Mods) RandomCreated(f *faker.Faker) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.Created = 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 historyZones2Mods) RandomCreatedNotNull(f *faker.Faker) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {
o.Created = 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 historyZones2Mods) CreatedDate(val null.Val[int64]) HistoryZones2Mod {
return HistoryZones2ModFunc(func(_ context.Context, o *HistoryZones2Template) {

File diff suppressed because it is too large Load diff