Remove old FieldSeeker tables, use v2 generated tables.

This requires a bunch of changes since the types on these tables are
much closer to the underlying types of the Fieldseeker data we are
getting back from the API.

I now need to use proper UUID types everywhere, which means I had to
modify the bob gen config to consistently use google UUID, my UUID
library of choice.

I also had to add the organization_id to all the fieldseeker tables
since we rely on them existing for some of our compound queries.

There were some changes to the API type signatures to get things to
build. I may yet regret those.
This commit is contained in:
Eli Ribble 2025-12-24 17:49:39 -07:00
parent 58f5afccc9
commit 1395e3d3ac
445 changed files with 54077 additions and 275856 deletions

View file

@ -1,18 +1,19 @@
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
// Code generated by BobGen psql v0.0.4-0.20251216163753-8e325b7c773a+dirty. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
import (
"context"
"encoding/json"
"fmt"
"io"
"time"
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/aarondl/opt/null"
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"github.com/stephenafamo/bob"
"github.com/stephenafamo/bob/dialect/psql"
"github.com/stephenafamo/bob/dialect/psql/dialect"
@ -20,50 +21,69 @@ import (
"github.com/stephenafamo/bob/dialect/psql/sm"
"github.com/stephenafamo/bob/dialect/psql/um"
"github.com/stephenafamo/bob/expr"
"github.com/stephenafamo/bob/mods"
"github.com/stephenafamo/bob/orm"
"github.com/stephenafamo/bob/types"
"github.com/stephenafamo/bob/types/pgtypes"
)
// FieldseekerInspectionsampledetail is an object representing the database table.
type FieldseekerInspectionsampledetail struct {
Objectid int64 `db:"objectid,pk" `
Objectid int64 `db:"objectid,pk" `
// Original attribute from ArcGIS API is INSPSAMPLE_ID
InspsampleID null.Val[uuid.UUID] `db:"inspsample_id" `
// Field Species
Fieldspecies null.Val[enums.FieldseekerInspectionsampledetailMosquitofieldspeciesEnum] `db:"fieldspecies" `
// Field Larva Count
// Original attribute from ArcGIS API is FIELDSPECIES
Fieldspecies null.Val[string] `db:"fieldspecies" `
// Original attribute from ArcGIS API is FLARVCOUNT
Flarvcount null.Val[int16] `db:"flarvcount" `
// Field Pupa Count
// Original attribute from ArcGIS API is FPUPCOUNT
Fpupcount null.Val[int16] `db:"fpupcount" `
// Field Egg Count
// Original attribute from ArcGIS API is FEGGCOUNT
Feggcount null.Val[int16] `db:"feggcount" `
// Field Larval Stages
// Original attribute from ArcGIS API is FLSTAGES
Flstages null.Val[string] `db:"flstages" `
// Field Dominant Stage
Fdomstage null.Val[enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum] `db:"fdomstage" `
// Field Adult Activity
Fadultact null.Val[enums.FieldseekerInspectionsampledetailMosquitoadultactivityEnum] `db:"fadultact" `
// Lab Species
// Original attribute from ArcGIS API is FDOMSTAGE
Fdomstage null.Val[string] `db:"fdomstage" `
// Original attribute from ArcGIS API is FADULTACT
Fadultact null.Val[string] `db:"fadultact" `
// Original attribute from ArcGIS API is LABSPECIES
Labspecies null.Val[string] `db:"labspecies" `
// Lab Larva Count
// Original attribute from ArcGIS API is LLARVCOUNT
Llarvcount null.Val[int16] `db:"llarvcount" `
// Lab Pupa Count
// Original attribute from ArcGIS API is LPUPCOUNT
Lpupcount null.Val[int16] `db:"lpupcount" `
// Lab Egg Count
// Original attribute from ArcGIS API is LEGGCOUNT
Leggcount null.Val[int16] `db:"leggcount" `
// Lab Dominant Stage
Ldomstage null.Val[enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum] `db:"ldomstage" `
// Comments
Comments null.Val[string] `db:"comments" `
Globalid null.Val[uuid.UUID] `db:"globalid" `
CreatedUser null.Val[string] `db:"created_user" `
CreatedDate null.Val[time.Time] `db:"created_date" `
LastEditedUser null.Val[string] `db:"last_edited_user" `
// Original attribute from ArcGIS API is LDOMSTAGE
Ldomstage null.Val[string] `db:"ldomstage" `
// Original attribute from ArcGIS API is COMMENTS
Comments null.Val[string] `db:"comments" `
// Original attribute from ArcGIS API is GlobalID
Globalid null.Val[uuid.UUID] `db:"globalid" `
// Original attribute from ArcGIS API is created_user
CreatedUser null.Val[string] `db:"created_user" `
// Original attribute from ArcGIS API is created_date
CreatedDate null.Val[time.Time] `db:"created_date" `
// Original attribute from ArcGIS API is last_edited_user
LastEditedUser null.Val[string] `db:"last_edited_user" `
// Original attribute from ArcGIS API is last_edited_date
LastEditedDate null.Val[time.Time] `db:"last_edited_date" `
Processed null.Val[int16] `db:"processed" `
Creationdate null.Val[time.Time] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Editdate null.Val[time.Time] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
// Tracks version changes to the row. Increases when data is modified.
Version int32 `db:"version,pk" `
// Original attribute from ArcGIS API is PROCESSED
Processed null.Val[int16] `db:"processed" `
// Original attribute from ArcGIS API is CreationDate
Creationdate null.Val[time.Time] `db:"creationdate" `
// Original attribute from ArcGIS API is Creator
Creator null.Val[string] `db:"creator" `
// Original attribute from ArcGIS API is EditDate
Editdate null.Val[time.Time] `db:"editdate" `
// Original attribute from ArcGIS API is Editor
Editor null.Val[string] `db:"editor" `
Geometry types.JSON[json.RawMessage] `db:"geometry" `
Geospatial null.Val[string] `db:"geospatial" `
Version int32 `db:"version,pk" `
OrganizationID int32 `db:"organization_id" `
R fieldseekerInspectionsampledetailR `db:"-" `
}
// FieldseekerInspectionsampledetailSlice is an alias for a slice of pointers to FieldseekerInspectionsampledetail.
@ -76,10 +96,15 @@ var FieldseekerInspectionsampledetails = psql.NewTablex[*FieldseekerInspectionsa
// FieldseekerInspectionsampledetailsQuery is a query on the inspectionsampledetail table
type FieldseekerInspectionsampledetailsQuery = *psql.ViewQuery[*FieldseekerInspectionsampledetail, FieldseekerInspectionsampledetailSlice]
// fieldseekerInspectionsampledetailR is where relationships are stored.
type fieldseekerInspectionsampledetailR struct {
Organization *Organization // fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey
}
func buildFieldseekerInspectionsampledetailColumns(alias string) fieldseekerInspectionsampledetailColumns {
return fieldseekerInspectionsampledetailColumns{
ColumnsExpr: expr.NewColumnsExpr(
"objectid", "inspsample_id", "fieldspecies", "flarvcount", "fpupcount", "feggcount", "flstages", "fdomstage", "fadultact", "labspecies", "llarvcount", "lpupcount", "leggcount", "ldomstage", "comments", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "processed", "creationdate", "creator", "editdate", "editor", "version",
"objectid", "inspsample_id", "fieldspecies", "flarvcount", "fpupcount", "feggcount", "flstages", "fdomstage", "fadultact", "labspecies", "llarvcount", "lpupcount", "leggcount", "ldomstage", "comments", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "processed", "creationdate", "creator", "editdate", "editor", "geometry", "geospatial", "version", "organization_id",
).WithParent("fieldseeker.inspectionsampledetail"),
tableAlias: alias,
Objectid: psql.Quote(alias, "objectid"),
@ -107,7 +132,10 @@ func buildFieldseekerInspectionsampledetailColumns(alias string) fieldseekerInsp
Creator: psql.Quote(alias, "creator"),
Editdate: psql.Quote(alias, "editdate"),
Editor: psql.Quote(alias, "editor"),
Geometry: psql.Quote(alias, "geometry"),
Geospatial: psql.Quote(alias, "geospatial"),
Version: psql.Quote(alias, "version"),
OrganizationID: psql.Quote(alias, "organization_id"),
}
}
@ -139,7 +167,10 @@ type fieldseekerInspectionsampledetailColumns struct {
Creator psql.Expression
Editdate psql.Expression
Editor psql.Expression
Geometry psql.Expression
Geospatial psql.Expression
Version psql.Expression
OrganizationID psql.Expression
}
func (c fieldseekerInspectionsampledetailColumns) Alias() string {
@ -154,36 +185,39 @@ func (fieldseekerInspectionsampledetailColumns) AliasedAs(alias string) fieldsee
// All values are optional, and do not have to be set
// Generated columns are not included
type FieldseekerInspectionsampledetailSetter struct {
Objectid omit.Val[int64] `db:"objectid,pk" `
InspsampleID omitnull.Val[uuid.UUID] `db:"inspsample_id" `
Fieldspecies omitnull.Val[enums.FieldseekerInspectionsampledetailMosquitofieldspeciesEnum] `db:"fieldspecies" `
Flarvcount omitnull.Val[int16] `db:"flarvcount" `
Fpupcount omitnull.Val[int16] `db:"fpupcount" `
Feggcount omitnull.Val[int16] `db:"feggcount" `
Flstages omitnull.Val[string] `db:"flstages" `
Fdomstage omitnull.Val[enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum] `db:"fdomstage" `
Fadultact omitnull.Val[enums.FieldseekerInspectionsampledetailMosquitoadultactivityEnum] `db:"fadultact" `
Labspecies omitnull.Val[string] `db:"labspecies" `
Llarvcount omitnull.Val[int16] `db:"llarvcount" `
Lpupcount omitnull.Val[int16] `db:"lpupcount" `
Leggcount omitnull.Val[int16] `db:"leggcount" `
Ldomstage omitnull.Val[enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum] `db:"ldomstage" `
Comments omitnull.Val[string] `db:"comments" `
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
CreatedUser omitnull.Val[string] `db:"created_user" `
CreatedDate omitnull.Val[time.Time] `db:"created_date" `
LastEditedUser omitnull.Val[string] `db:"last_edited_user" `
LastEditedDate omitnull.Val[time.Time] `db:"last_edited_date" `
Processed omitnull.Val[int16] `db:"processed" `
Creationdate omitnull.Val[time.Time] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Editdate omitnull.Val[time.Time] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Version omit.Val[int32] `db:"version,pk" `
Objectid omit.Val[int64] `db:"objectid,pk" `
InspsampleID omitnull.Val[uuid.UUID] `db:"inspsample_id" `
Fieldspecies omitnull.Val[string] `db:"fieldspecies" `
Flarvcount omitnull.Val[int16] `db:"flarvcount" `
Fpupcount omitnull.Val[int16] `db:"fpupcount" `
Feggcount omitnull.Val[int16] `db:"feggcount" `
Flstages omitnull.Val[string] `db:"flstages" `
Fdomstage omitnull.Val[string] `db:"fdomstage" `
Fadultact omitnull.Val[string] `db:"fadultact" `
Labspecies omitnull.Val[string] `db:"labspecies" `
Llarvcount omitnull.Val[int16] `db:"llarvcount" `
Lpupcount omitnull.Val[int16] `db:"lpupcount" `
Leggcount omitnull.Val[int16] `db:"leggcount" `
Ldomstage omitnull.Val[string] `db:"ldomstage" `
Comments omitnull.Val[string] `db:"comments" `
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
CreatedUser omitnull.Val[string] `db:"created_user" `
CreatedDate omitnull.Val[time.Time] `db:"created_date" `
LastEditedUser omitnull.Val[string] `db:"last_edited_user" `
LastEditedDate omitnull.Val[time.Time] `db:"last_edited_date" `
Processed omitnull.Val[int16] `db:"processed" `
Creationdate omitnull.Val[time.Time] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Editdate omitnull.Val[time.Time] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Geometry omit.Val[types.JSON[json.RawMessage]] `db:"geometry" `
Geospatial omitnull.Val[string] `db:"geospatial" `
Version omit.Val[int32] `db:"version,pk" `
OrganizationID omit.Val[int32] `db:"organization_id" `
}
func (s FieldseekerInspectionsampledetailSetter) SetColumns() []string {
vals := make([]string, 0, 26)
vals := make([]string, 0, 29)
if s.Objectid.IsValue() {
vals = append(vals, "objectid")
}
@ -259,9 +293,18 @@ func (s FieldseekerInspectionsampledetailSetter) SetColumns() []string {
if !s.Editor.IsUnset() {
vals = append(vals, "editor")
}
if s.Geometry.IsValue() {
vals = append(vals, "geometry")
}
if !s.Geospatial.IsUnset() {
vals = append(vals, "geospatial")
}
if s.Version.IsValue() {
vals = append(vals, "version")
}
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
return vals
}
@ -341,9 +384,18 @@ func (s FieldseekerInspectionsampledetailSetter) Overwrite(t *FieldseekerInspect
if !s.Editor.IsUnset() {
t.Editor = s.Editor.MustGetNull()
}
if s.Geometry.IsValue() {
t.Geometry = s.Geometry.MustGet()
}
if !s.Geospatial.IsUnset() {
t.Geospatial = s.Geospatial.MustGetNull()
}
if s.Version.IsValue() {
t.Version = s.Version.MustGet()
}
if s.OrganizationID.IsValue() {
t.OrganizationID = s.OrganizationID.MustGet()
}
}
func (s *FieldseekerInspectionsampledetailSetter) Apply(q *dialect.InsertQuery) {
@ -352,7 +404,7 @@ func (s *FieldseekerInspectionsampledetailSetter) Apply(q *dialect.InsertQuery)
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 26)
vals := make([]bob.Expression, 29)
if s.Objectid.IsValue() {
vals[0] = psql.Arg(s.Objectid.MustGet())
} else {
@ -503,12 +555,30 @@ func (s *FieldseekerInspectionsampledetailSetter) Apply(q *dialect.InsertQuery)
vals[24] = psql.Raw("DEFAULT")
}
if s.Version.IsValue() {
vals[25] = psql.Arg(s.Version.MustGet())
if s.Geometry.IsValue() {
vals[25] = psql.Arg(s.Geometry.MustGet())
} else {
vals[25] = psql.Raw("DEFAULT")
}
if !s.Geospatial.IsUnset() {
vals[26] = psql.Arg(s.Geospatial.MustGetNull())
} else {
vals[26] = psql.Raw("DEFAULT")
}
if s.Version.IsValue() {
vals[27] = psql.Arg(s.Version.MustGet())
} else {
vals[27] = psql.Raw("DEFAULT")
}
if s.OrganizationID.IsValue() {
vals[28] = psql.Arg(s.OrganizationID.MustGet())
} else {
vals[28] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -518,7 +588,7 @@ func (s FieldseekerInspectionsampledetailSetter) UpdateMod() bob.Mod[*dialect.Up
}
func (s FieldseekerInspectionsampledetailSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 26)
exprs := make([]bob.Expression, 0, 29)
if s.Objectid.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -695,6 +765,20 @@ func (s FieldseekerInspectionsampledetailSetter) Expressions(prefix ...string) [
}})
}
if s.Geometry.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "geometry")...),
psql.Arg(s.Geometry),
}})
}
if !s.Geospatial.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "geospatial")...),
psql.Arg(s.Geospatial),
}})
}
if s.Version.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "version")...),
@ -702,6 +786,13 @@ func (s FieldseekerInspectionsampledetailSetter) Expressions(prefix ...string) [
}})
}
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "organization_id")...),
psql.Arg(s.OrganizationID),
}})
}
return exprs
}
@ -769,6 +860,7 @@ func (o *FieldseekerInspectionsampledetail) Update(ctx context.Context, exec bob
return err
}
o.R = v.R
*o = *v
return nil
@ -789,7 +881,7 @@ func (o *FieldseekerInspectionsampledetail) Reload(ctx context.Context, exec bob
if err != nil {
return err
}
o2.R = o.R
*o = *o2
return nil
@ -839,7 +931,7 @@ func (o FieldseekerInspectionsampledetailSlice) copyMatchingRows(from ...*Fields
if new.Version != old.Version {
continue
}
new.R = old.R
o[i] = new
break
}
@ -937,21 +1029,93 @@ func (o FieldseekerInspectionsampledetailSlice) ReloadAll(ctx context.Context, e
return nil
}
// Organization starts a query for related objects on organization
func (o *FieldseekerInspectionsampledetail) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
return Organizations.Query(append(mods,
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
)...)
}
func (os FieldseekerInspectionsampledetailSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
pkOrganizationID := make(pgtypes.Array[int32], 0, len(os))
for _, o := range os {
if o == nil {
continue
}
pkOrganizationID = append(pkOrganizationID, o.OrganizationID)
}
PKArgExpr := psql.Select(sm.Columns(
psql.F("unnest", psql.Cast(psql.Arg(pkOrganizationID), "integer[]")),
))
return Organizations.Query(append(mods,
sm.Where(psql.Group(Organizations.Columns.ID).OP("IN", PKArgExpr)),
)...)
}
func attachFieldseekerInspectionsampledetailOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerInspectionsampledetail0 *FieldseekerInspectionsampledetail, organization1 *Organization) (*FieldseekerInspectionsampledetail, error) {
setter := &FieldseekerInspectionsampledetailSetter{
OrganizationID: omit.From(organization1.ID),
}
err := fieldseekerInspectionsampledetail0.Update(ctx, exec, setter)
if err != nil {
return nil, fmt.Errorf("attachFieldseekerInspectionsampledetailOrganization0: %w", err)
}
return fieldseekerInspectionsampledetail0, nil
}
func (fieldseekerInspectionsampledetail0 *FieldseekerInspectionsampledetail) InsertOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error {
var err error
organization1, err := Organizations.Insert(related).One(ctx, exec)
if err != nil {
return fmt.Errorf("inserting related objects: %w", err)
}
_, err = attachFieldseekerInspectionsampledetailOrganization0(ctx, exec, 1, fieldseekerInspectionsampledetail0, organization1)
if err != nil {
return err
}
fieldseekerInspectionsampledetail0.R.Organization = organization1
organization1.R.Inspectionsampledetails = append(organization1.R.Inspectionsampledetails, fieldseekerInspectionsampledetail0)
return nil
}
func (fieldseekerInspectionsampledetail0 *FieldseekerInspectionsampledetail) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
var err error
_, err = attachFieldseekerInspectionsampledetailOrganization0(ctx, exec, 1, fieldseekerInspectionsampledetail0, organization1)
if err != nil {
return err
}
fieldseekerInspectionsampledetail0.R.Organization = organization1
organization1.R.Inspectionsampledetails = append(organization1.R.Inspectionsampledetails, fieldseekerInspectionsampledetail0)
return nil
}
type fieldseekerInspectionsampledetailWhere[Q psql.Filterable] struct {
Objectid psql.WhereMod[Q, int64]
InspsampleID psql.WhereNullMod[Q, uuid.UUID]
Fieldspecies psql.WhereNullMod[Q, enums.FieldseekerInspectionsampledetailMosquitofieldspeciesEnum]
Fieldspecies psql.WhereNullMod[Q, string]
Flarvcount psql.WhereNullMod[Q, int16]
Fpupcount psql.WhereNullMod[Q, int16]
Feggcount psql.WhereNullMod[Q, int16]
Flstages psql.WhereNullMod[Q, string]
Fdomstage psql.WhereNullMod[Q, enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum]
Fadultact psql.WhereNullMod[Q, enums.FieldseekerInspectionsampledetailMosquitoadultactivityEnum]
Fdomstage psql.WhereNullMod[Q, string]
Fadultact psql.WhereNullMod[Q, string]
Labspecies psql.WhereNullMod[Q, string]
Llarvcount psql.WhereNullMod[Q, int16]
Lpupcount psql.WhereNullMod[Q, int16]
Leggcount psql.WhereNullMod[Q, int16]
Ldomstage psql.WhereNullMod[Q, enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum]
Ldomstage psql.WhereNullMod[Q, string]
Comments psql.WhereNullMod[Q, string]
Globalid psql.WhereNullMod[Q, uuid.UUID]
CreatedUser psql.WhereNullMod[Q, string]
@ -963,7 +1127,10 @@ type fieldseekerInspectionsampledetailWhere[Q psql.Filterable] struct {
Creator psql.WhereNullMod[Q, string]
Editdate psql.WhereNullMod[Q, time.Time]
Editor psql.WhereNullMod[Q, string]
Geometry psql.WhereMod[Q, types.JSON[json.RawMessage]]
Geospatial psql.WhereNullMod[Q, string]
Version psql.WhereMod[Q, int32]
OrganizationID psql.WhereMod[Q, int32]
}
func (fieldseekerInspectionsampledetailWhere[Q]) AliasedAs(alias string) fieldseekerInspectionsampledetailWhere[Q] {
@ -974,18 +1141,18 @@ func buildFieldseekerInspectionsampledetailWhere[Q psql.Filterable](cols fieldse
return fieldseekerInspectionsampledetailWhere[Q]{
Objectid: psql.Where[Q, int64](cols.Objectid),
InspsampleID: psql.WhereNull[Q, uuid.UUID](cols.InspsampleID),
Fieldspecies: psql.WhereNull[Q, enums.FieldseekerInspectionsampledetailMosquitofieldspeciesEnum](cols.Fieldspecies),
Fieldspecies: psql.WhereNull[Q, string](cols.Fieldspecies),
Flarvcount: psql.WhereNull[Q, int16](cols.Flarvcount),
Fpupcount: psql.WhereNull[Q, int16](cols.Fpupcount),
Feggcount: psql.WhereNull[Q, int16](cols.Feggcount),
Flstages: psql.WhereNull[Q, string](cols.Flstages),
Fdomstage: psql.WhereNull[Q, enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum](cols.Fdomstage),
Fadultact: psql.WhereNull[Q, enums.FieldseekerInspectionsampledetailMosquitoadultactivityEnum](cols.Fadultact),
Fdomstage: psql.WhereNull[Q, string](cols.Fdomstage),
Fadultact: psql.WhereNull[Q, string](cols.Fadultact),
Labspecies: psql.WhereNull[Q, string](cols.Labspecies),
Llarvcount: psql.WhereNull[Q, int16](cols.Llarvcount),
Lpupcount: psql.WhereNull[Q, int16](cols.Lpupcount),
Leggcount: psql.WhereNull[Q, int16](cols.Leggcount),
Ldomstage: psql.WhereNull[Q, enums.FieldseekerInspectionsampledetailMosquitodominantstageEnum](cols.Ldomstage),
Ldomstage: psql.WhereNull[Q, string](cols.Ldomstage),
Comments: psql.WhereNull[Q, string](cols.Comments),
Globalid: psql.WhereNull[Q, uuid.UUID](cols.Globalid),
CreatedUser: psql.WhereNull[Q, string](cols.CreatedUser),
@ -997,6 +1164,154 @@ func buildFieldseekerInspectionsampledetailWhere[Q psql.Filterable](cols fieldse
Creator: psql.WhereNull[Q, string](cols.Creator),
Editdate: psql.WhereNull[Q, time.Time](cols.Editdate),
Editor: psql.WhereNull[Q, string](cols.Editor),
Geometry: psql.Where[Q, types.JSON[json.RawMessage]](cols.Geometry),
Geospatial: psql.WhereNull[Q, string](cols.Geospatial),
Version: psql.Where[Q, int32](cols.Version),
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
}
}
func (o *FieldseekerInspectionsampledetail) Preload(name string, retrieved any) error {
if o == nil {
return nil
}
switch name {
case "Organization":
rel, ok := retrieved.(*Organization)
if !ok {
return fmt.Errorf("fieldseekerInspectionsampledetail cannot load %T as %q", retrieved, name)
}
o.R.Organization = rel
if rel != nil {
rel.R.Inspectionsampledetails = FieldseekerInspectionsampledetailSlice{o}
}
return nil
default:
return fmt.Errorf("fieldseekerInspectionsampledetail has no relationship %q", name)
}
}
type fieldseekerInspectionsampledetailPreloader struct {
Organization func(...psql.PreloadOption) psql.Preloader
}
func buildFieldseekerInspectionsampledetailPreloader() fieldseekerInspectionsampledetailPreloader {
return fieldseekerInspectionsampledetailPreloader{
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
Name: "Organization",
Sides: []psql.PreloadSide{
{
From: FieldseekerInspectionsampledetails,
To: Organizations,
FromColumns: []string{"organization_id"},
ToColumns: []string{"id"},
},
},
}, Organizations.Columns.Names(), opts...)
},
}
}
type fieldseekerInspectionsampledetailThenLoader[Q orm.Loadable] struct {
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildFieldseekerInspectionsampledetailThenLoader[Q orm.Loadable]() fieldseekerInspectionsampledetailThenLoader[Q] {
type OrganizationLoadInterface interface {
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return fieldseekerInspectionsampledetailThenLoader[Q]{
Organization: thenLoadBuilder[Q](
"Organization",
func(ctx context.Context, exec bob.Executor, retrieved OrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
return retrieved.LoadOrganization(ctx, exec, mods...)
},
),
}
}
// LoadOrganization loads the fieldseekerInspectionsampledetail's Organization into the .R struct
func (o *FieldseekerInspectionsampledetail) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
// Reset the relationship
o.R.Organization = nil
related, err := o.Organization(mods...).One(ctx, exec)
if err != nil {
return err
}
related.R.Inspectionsampledetails = FieldseekerInspectionsampledetailSlice{o}
o.R.Organization = related
return nil
}
// LoadOrganization loads the fieldseekerInspectionsampledetail's Organization into the .R struct
func (os FieldseekerInspectionsampledetailSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
organizations, err := os.Organization(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, o := range os {
if o == nil {
continue
}
for _, rel := range organizations {
if !(o.OrganizationID == rel.ID) {
continue
}
rel.R.Inspectionsampledetails = append(rel.R.Inspectionsampledetails, o)
o.R.Organization = rel
break
}
}
return nil
}
type fieldseekerInspectionsampledetailJoins[Q dialect.Joinable] struct {
typ string
Organization modAs[Q, organizationColumns]
}
func (j fieldseekerInspectionsampledetailJoins[Q]) aliasedAs(alias string) fieldseekerInspectionsampledetailJoins[Q] {
return buildFieldseekerInspectionsampledetailJoins[Q](buildFieldseekerInspectionsampledetailColumns(alias), j.typ)
}
func buildFieldseekerInspectionsampledetailJoins[Q dialect.Joinable](cols fieldseekerInspectionsampledetailColumns, typ string) fieldseekerInspectionsampledetailJoins[Q] {
return fieldseekerInspectionsampledetailJoins[Q]{
typ: typ,
Organization: modAs[Q, organizationColumns]{
c: Organizations.Columns,
f: func(to organizationColumns) bob.Mod[Q] {
mods := make(mods.QueryMods[Q], 0, 1)
{
mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On(
to.ID.EQ(cols.OrganizationID),
))
}
return mods
},
},
}
}