// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models import ( "context" "encoding/json" "fmt" "io" "time" "github.com/aarondl/opt/null" "github.com/aarondl/opt/omit" "github.com/aarondl/opt/omitnull" "github.com/google/uuid" "github.com/stephenafamo/bob" "github.com/stephenafamo/bob/dialect/psql" "github.com/stephenafamo/bob/dialect/psql/dialect" "github.com/stephenafamo/bob/dialect/psql/dm" "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" ) // FieldseekerTreatment is an object representing the database table. type FieldseekerTreatment struct { Objectid int64 `db:"objectid,pk" ` // Original attribute from ArcGIS API is ACTIVITY Activity null.Val[string] `db:"activity" ` // Original attribute from ArcGIS API is TREATAREA Treatarea null.Val[float64] `db:"treatarea" ` // Original attribute from ArcGIS API is AREAUNIT Areaunit null.Val[string] `db:"areaunit" ` // Original attribute from ArcGIS API is PRODUCT Product null.Val[string] `db:"product" ` // Original attribute from ArcGIS API is QTY Qty null.Val[float64] `db:"qty" ` // Original attribute from ArcGIS API is QTYUNIT Qtyunit null.Val[string] `db:"qtyunit" ` // Original attribute from ArcGIS API is METHOD Method null.Val[string] `db:"method" ` // Original attribute from ArcGIS API is EQUIPTYPE Equiptype null.Val[string] `db:"equiptype" ` // Original attribute from ArcGIS API is COMMENTS Comments null.Val[string] `db:"comments" ` // Original attribute from ArcGIS API is AVETEMP Avetemp null.Val[float64] `db:"avetemp" ` // Original attribute from ArcGIS API is WINDSPEED Windspeed null.Val[float64] `db:"windspeed" ` // Original attribute from ArcGIS API is WINDDIR Winddir null.Val[string] `db:"winddir" ` // Original attribute from ArcGIS API is RAINGAUGE Raingauge null.Val[float64] `db:"raingauge" ` // Original attribute from ArcGIS API is STARTDATETIME Startdatetime null.Val[time.Time] `db:"startdatetime" ` // Original attribute from ArcGIS API is ENDDATETIME Enddatetime null.Val[time.Time] `db:"enddatetime" ` // Original attribute from ArcGIS API is INSP_ID InspID null.Val[uuid.UUID] `db:"insp_id" ` // Original attribute from ArcGIS API is REVIEWED Reviewed null.Val[int16] `db:"reviewed" ` // Original attribute from ArcGIS API is REVIEWEDBY Reviewedby null.Val[string] `db:"reviewedby" ` // Original attribute from ArcGIS API is REVIEWEDDATE Revieweddate null.Val[time.Time] `db:"revieweddate" ` // Original attribute from ArcGIS API is LOCATIONNAME Locationname null.Val[string] `db:"locationname" ` // Original attribute from ArcGIS API is ZONE Zone null.Val[string] `db:"zone" ` // Original attribute from ArcGIS API is WARNINGOVERRIDE Warningoverride null.Val[int16] `db:"warningoverride" ` // Original attribute from ArcGIS API is RECORDSTATUS Recordstatus null.Val[int16] `db:"recordstatus" ` // Original attribute from ArcGIS API is ZONE2 Zone2 null.Val[string] `db:"zone2" ` // Original attribute from ArcGIS API is TREATACRES Treatacres null.Val[float64] `db:"treatacres" ` // Original attribute from ArcGIS API is TIRECOUNT Tirecount null.Val[int16] `db:"tirecount" ` // Original attribute from ArcGIS API is CBCOUNT Cbcount null.Val[int16] `db:"cbcount" ` // Original attribute from ArcGIS API is CONTAINERCOUNT Containercount null.Val[int16] `db:"containercount" ` // Original attribute from ArcGIS API is GlobalID Globalid uuid.UUID `db:"globalid" ` // Original attribute from ArcGIS API is TREATMENTLENGTH Treatmentlength null.Val[float64] `db:"treatmentlength" ` // Original attribute from ArcGIS API is TREATMENTHOURS Treatmenthours null.Val[float64] `db:"treatmenthours" ` // Original attribute from ArcGIS API is TREATMENTLENGTHUNITS Treatmentlengthunits null.Val[string] `db:"treatmentlengthunits" ` // Original attribute from ArcGIS API is LINELOCID Linelocid null.Val[uuid.UUID] `db:"linelocid" ` // Original attribute from ArcGIS API is POINTLOCID Pointlocid null.Val[uuid.UUID] `db:"pointlocid" ` // Original attribute from ArcGIS API is POLYGONLOCID Polygonlocid null.Val[uuid.UUID] `db:"polygonlocid" ` // Original attribute from ArcGIS API is SRID Srid null.Val[uuid.UUID] `db:"srid" ` // Original attribute from ArcGIS API is SDID Sdid null.Val[uuid.UUID] `db:"sdid" ` // Original attribute from ArcGIS API is BARRIERROUTEID Barrierrouteid null.Val[uuid.UUID] `db:"barrierrouteid" ` // Original attribute from ArcGIS API is ULVROUTEID Ulvrouteid null.Val[uuid.UUID] `db:"ulvrouteid" ` // Original attribute from ArcGIS API is FIELDTECH Fieldtech null.Val[string] `db:"fieldtech" ` // Original attribute from ArcGIS API is PTAID Ptaid null.Val[uuid.UUID] `db:"ptaid" ` // Original attribute from ArcGIS API is FLOWRATE Flowrate null.Val[float64] `db:"flowrate" ` // Original attribute from ArcGIS API is HABITAT Habitat null.Val[string] `db:"habitat" ` // Original attribute from ArcGIS API is TREATHECTARES Treathectares null.Val[float64] `db:"treathectares" ` // Original attribute from ArcGIS API is INVLOC Invloc null.Val[string] `db:"invloc" ` // Original attribute from ArcGIS API is temp_SITECOND TempSitecond null.Val[string] `db:"temp_sitecond" ` // Original attribute from ArcGIS API is SITECOND Sitecond null.Val[string] `db:"sitecond" ` // Original attribute from ArcGIS API is TotalCostProdcut Totalcostprodcut null.Val[float64] `db:"totalcostprodcut" ` // 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" ` // Original attribute from ArcGIS API is TARGETSPECIES Targetspecies null.Val[string] `db:"targetspecies" ` Geometry types.JSON[json.RawMessage] `db:"geometry" ` Geospatial null.Val[string] `db:"geospatial" ` Version int32 `db:"version,pk" ` OrganizationID int32 `db:"organization_id" ` H3cell null.Val[string] `db:"h3cell,generated" ` R fieldseekerTreatmentR `db:"-" ` } // FieldseekerTreatmentSlice is an alias for a slice of pointers to FieldseekerTreatment. // This should almost always be used instead of []*FieldseekerTreatment. type FieldseekerTreatmentSlice []*FieldseekerTreatment // FieldseekerTreatments contains methods to work with the treatment table var FieldseekerTreatments = psql.NewTablex[*FieldseekerTreatment, FieldseekerTreatmentSlice, *FieldseekerTreatmentSetter]("fieldseeker", "treatment", buildFieldseekerTreatmentColumns("fieldseeker.treatment")) // FieldseekerTreatmentsQuery is a query on the treatment table type FieldseekerTreatmentsQuery = *psql.ViewQuery[*FieldseekerTreatment, FieldseekerTreatmentSlice] // fieldseekerTreatmentR is where relationships are stored. type fieldseekerTreatmentR struct { Organization *Organization // fieldseeker.treatment.treatment_organization_id_fkey } func buildFieldseekerTreatmentColumns(alias string) fieldseekerTreatmentColumns { return fieldseekerTreatmentColumns{ ColumnsExpr: expr.NewColumnsExpr( "objectid", "activity", "treatarea", "areaunit", "product", "qty", "qtyunit", "method", "equiptype", "comments", "avetemp", "windspeed", "winddir", "raingauge", "startdatetime", "enddatetime", "insp_id", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "warningoverride", "recordstatus", "zone2", "treatacres", "tirecount", "cbcount", "containercount", "globalid", "treatmentlength", "treatmenthours", "treatmentlengthunits", "linelocid", "pointlocid", "polygonlocid", "srid", "sdid", "barrierrouteid", "ulvrouteid", "fieldtech", "ptaid", "flowrate", "habitat", "treathectares", "invloc", "temp_sitecond", "sitecond", "totalcostprodcut", "creationdate", "creator", "editdate", "editor", "targetspecies", "geometry", "geospatial", "version", "organization_id", "h3cell", ).WithParent("fieldseeker.treatment"), tableAlias: alias, Objectid: psql.Quote(alias, "objectid"), Activity: psql.Quote(alias, "activity"), Treatarea: psql.Quote(alias, "treatarea"), Areaunit: psql.Quote(alias, "areaunit"), Product: psql.Quote(alias, "product"), Qty: psql.Quote(alias, "qty"), Qtyunit: psql.Quote(alias, "qtyunit"), Method: psql.Quote(alias, "method"), Equiptype: psql.Quote(alias, "equiptype"), Comments: psql.Quote(alias, "comments"), Avetemp: psql.Quote(alias, "avetemp"), Windspeed: psql.Quote(alias, "windspeed"), Winddir: psql.Quote(alias, "winddir"), Raingauge: psql.Quote(alias, "raingauge"), Startdatetime: psql.Quote(alias, "startdatetime"), Enddatetime: psql.Quote(alias, "enddatetime"), InspID: psql.Quote(alias, "insp_id"), Reviewed: psql.Quote(alias, "reviewed"), Reviewedby: psql.Quote(alias, "reviewedby"), Revieweddate: psql.Quote(alias, "revieweddate"), Locationname: psql.Quote(alias, "locationname"), Zone: psql.Quote(alias, "zone"), Warningoverride: psql.Quote(alias, "warningoverride"), Recordstatus: psql.Quote(alias, "recordstatus"), Zone2: psql.Quote(alias, "zone2"), Treatacres: psql.Quote(alias, "treatacres"), Tirecount: psql.Quote(alias, "tirecount"), Cbcount: psql.Quote(alias, "cbcount"), Containercount: psql.Quote(alias, "containercount"), Globalid: psql.Quote(alias, "globalid"), Treatmentlength: psql.Quote(alias, "treatmentlength"), Treatmenthours: psql.Quote(alias, "treatmenthours"), Treatmentlengthunits: psql.Quote(alias, "treatmentlengthunits"), Linelocid: psql.Quote(alias, "linelocid"), Pointlocid: psql.Quote(alias, "pointlocid"), Polygonlocid: psql.Quote(alias, "polygonlocid"), Srid: psql.Quote(alias, "srid"), Sdid: psql.Quote(alias, "sdid"), Barrierrouteid: psql.Quote(alias, "barrierrouteid"), Ulvrouteid: psql.Quote(alias, "ulvrouteid"), Fieldtech: psql.Quote(alias, "fieldtech"), Ptaid: psql.Quote(alias, "ptaid"), Flowrate: psql.Quote(alias, "flowrate"), Habitat: psql.Quote(alias, "habitat"), Treathectares: psql.Quote(alias, "treathectares"), Invloc: psql.Quote(alias, "invloc"), TempSitecond: psql.Quote(alias, "temp_sitecond"), Sitecond: psql.Quote(alias, "sitecond"), Totalcostprodcut: psql.Quote(alias, "totalcostprodcut"), Creationdate: psql.Quote(alias, "creationdate"), Creator: psql.Quote(alias, "creator"), Editdate: psql.Quote(alias, "editdate"), Editor: psql.Quote(alias, "editor"), Targetspecies: psql.Quote(alias, "targetspecies"), Geometry: psql.Quote(alias, "geometry"), Geospatial: psql.Quote(alias, "geospatial"), Version: psql.Quote(alias, "version"), OrganizationID: psql.Quote(alias, "organization_id"), H3cell: psql.Quote(alias, "h3cell"), } } type fieldseekerTreatmentColumns struct { expr.ColumnsExpr tableAlias string Objectid psql.Expression Activity psql.Expression Treatarea psql.Expression Areaunit psql.Expression Product psql.Expression Qty psql.Expression Qtyunit psql.Expression Method psql.Expression Equiptype psql.Expression Comments psql.Expression Avetemp psql.Expression Windspeed psql.Expression Winddir psql.Expression Raingauge psql.Expression Startdatetime psql.Expression Enddatetime psql.Expression InspID psql.Expression Reviewed psql.Expression Reviewedby psql.Expression Revieweddate psql.Expression Locationname psql.Expression Zone psql.Expression Warningoverride psql.Expression Recordstatus psql.Expression Zone2 psql.Expression Treatacres psql.Expression Tirecount psql.Expression Cbcount psql.Expression Containercount psql.Expression Globalid psql.Expression Treatmentlength psql.Expression Treatmenthours psql.Expression Treatmentlengthunits psql.Expression Linelocid psql.Expression Pointlocid psql.Expression Polygonlocid psql.Expression Srid psql.Expression Sdid psql.Expression Barrierrouteid psql.Expression Ulvrouteid psql.Expression Fieldtech psql.Expression Ptaid psql.Expression Flowrate psql.Expression Habitat psql.Expression Treathectares psql.Expression Invloc psql.Expression TempSitecond psql.Expression Sitecond psql.Expression Totalcostprodcut psql.Expression Creationdate psql.Expression Creator psql.Expression Editdate psql.Expression Editor psql.Expression Targetspecies psql.Expression Geometry psql.Expression Geospatial psql.Expression Version psql.Expression OrganizationID psql.Expression H3cell psql.Expression } func (c fieldseekerTreatmentColumns) Alias() string { return c.tableAlias } func (fieldseekerTreatmentColumns) AliasedAs(alias string) fieldseekerTreatmentColumns { return buildFieldseekerTreatmentColumns(alias) } // FieldseekerTreatmentSetter is used for insert/upsert/update operations // All values are optional, and do not have to be set // Generated columns are not included type FieldseekerTreatmentSetter struct { Objectid omit.Val[int64] `db:"objectid,pk" ` Activity omitnull.Val[string] `db:"activity" ` Treatarea omitnull.Val[float64] `db:"treatarea" ` Areaunit omitnull.Val[string] `db:"areaunit" ` Product omitnull.Val[string] `db:"product" ` Qty omitnull.Val[float64] `db:"qty" ` Qtyunit omitnull.Val[string] `db:"qtyunit" ` Method omitnull.Val[string] `db:"method" ` Equiptype omitnull.Val[string] `db:"equiptype" ` Comments omitnull.Val[string] `db:"comments" ` Avetemp omitnull.Val[float64] `db:"avetemp" ` Windspeed omitnull.Val[float64] `db:"windspeed" ` Winddir omitnull.Val[string] `db:"winddir" ` Raingauge omitnull.Val[float64] `db:"raingauge" ` Startdatetime omitnull.Val[time.Time] `db:"startdatetime" ` Enddatetime omitnull.Val[time.Time] `db:"enddatetime" ` InspID omitnull.Val[uuid.UUID] `db:"insp_id" ` Reviewed omitnull.Val[int16] `db:"reviewed" ` Reviewedby omitnull.Val[string] `db:"reviewedby" ` Revieweddate omitnull.Val[time.Time] `db:"revieweddate" ` Locationname omitnull.Val[string] `db:"locationname" ` Zone omitnull.Val[string] `db:"zone" ` Warningoverride omitnull.Val[int16] `db:"warningoverride" ` Recordstatus omitnull.Val[int16] `db:"recordstatus" ` Zone2 omitnull.Val[string] `db:"zone2" ` Treatacres omitnull.Val[float64] `db:"treatacres" ` Tirecount omitnull.Val[int16] `db:"tirecount" ` Cbcount omitnull.Val[int16] `db:"cbcount" ` Containercount omitnull.Val[int16] `db:"containercount" ` Globalid omit.Val[uuid.UUID] `db:"globalid" ` Treatmentlength omitnull.Val[float64] `db:"treatmentlength" ` Treatmenthours omitnull.Val[float64] `db:"treatmenthours" ` Treatmentlengthunits omitnull.Val[string] `db:"treatmentlengthunits" ` Linelocid omitnull.Val[uuid.UUID] `db:"linelocid" ` Pointlocid omitnull.Val[uuid.UUID] `db:"pointlocid" ` Polygonlocid omitnull.Val[uuid.UUID] `db:"polygonlocid" ` Srid omitnull.Val[uuid.UUID] `db:"srid" ` Sdid omitnull.Val[uuid.UUID] `db:"sdid" ` Barrierrouteid omitnull.Val[uuid.UUID] `db:"barrierrouteid" ` Ulvrouteid omitnull.Val[uuid.UUID] `db:"ulvrouteid" ` Fieldtech omitnull.Val[string] `db:"fieldtech" ` Ptaid omitnull.Val[uuid.UUID] `db:"ptaid" ` Flowrate omitnull.Val[float64] `db:"flowrate" ` Habitat omitnull.Val[string] `db:"habitat" ` Treathectares omitnull.Val[float64] `db:"treathectares" ` Invloc omitnull.Val[string] `db:"invloc" ` TempSitecond omitnull.Val[string] `db:"temp_sitecond" ` Sitecond omitnull.Val[string] `db:"sitecond" ` Totalcostprodcut omitnull.Val[float64] `db:"totalcostprodcut" ` 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" ` Targetspecies omitnull.Val[string] `db:"targetspecies" ` 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 FieldseekerTreatmentSetter) SetColumns() []string { vals := make([]string, 0, 58) if s.Objectid.IsValue() { vals = append(vals, "objectid") } if !s.Activity.IsUnset() { vals = append(vals, "activity") } if !s.Treatarea.IsUnset() { vals = append(vals, "treatarea") } if !s.Areaunit.IsUnset() { vals = append(vals, "areaunit") } if !s.Product.IsUnset() { vals = append(vals, "product") } if !s.Qty.IsUnset() { vals = append(vals, "qty") } if !s.Qtyunit.IsUnset() { vals = append(vals, "qtyunit") } if !s.Method.IsUnset() { vals = append(vals, "method") } if !s.Equiptype.IsUnset() { vals = append(vals, "equiptype") } if !s.Comments.IsUnset() { vals = append(vals, "comments") } if !s.Avetemp.IsUnset() { vals = append(vals, "avetemp") } if !s.Windspeed.IsUnset() { vals = append(vals, "windspeed") } if !s.Winddir.IsUnset() { vals = append(vals, "winddir") } if !s.Raingauge.IsUnset() { vals = append(vals, "raingauge") } if !s.Startdatetime.IsUnset() { vals = append(vals, "startdatetime") } if !s.Enddatetime.IsUnset() { vals = append(vals, "enddatetime") } if !s.InspID.IsUnset() { vals = append(vals, "insp_id") } if !s.Reviewed.IsUnset() { vals = append(vals, "reviewed") } if !s.Reviewedby.IsUnset() { vals = append(vals, "reviewedby") } if !s.Revieweddate.IsUnset() { vals = append(vals, "revieweddate") } if !s.Locationname.IsUnset() { vals = append(vals, "locationname") } if !s.Zone.IsUnset() { vals = append(vals, "zone") } if !s.Warningoverride.IsUnset() { vals = append(vals, "warningoverride") } if !s.Recordstatus.IsUnset() { vals = append(vals, "recordstatus") } if !s.Zone2.IsUnset() { vals = append(vals, "zone2") } if !s.Treatacres.IsUnset() { vals = append(vals, "treatacres") } if !s.Tirecount.IsUnset() { vals = append(vals, "tirecount") } if !s.Cbcount.IsUnset() { vals = append(vals, "cbcount") } if !s.Containercount.IsUnset() { vals = append(vals, "containercount") } if s.Globalid.IsValue() { vals = append(vals, "globalid") } if !s.Treatmentlength.IsUnset() { vals = append(vals, "treatmentlength") } if !s.Treatmenthours.IsUnset() { vals = append(vals, "treatmenthours") } if !s.Treatmentlengthunits.IsUnset() { vals = append(vals, "treatmentlengthunits") } if !s.Linelocid.IsUnset() { vals = append(vals, "linelocid") } if !s.Pointlocid.IsUnset() { vals = append(vals, "pointlocid") } if !s.Polygonlocid.IsUnset() { vals = append(vals, "polygonlocid") } if !s.Srid.IsUnset() { vals = append(vals, "srid") } if !s.Sdid.IsUnset() { vals = append(vals, "sdid") } if !s.Barrierrouteid.IsUnset() { vals = append(vals, "barrierrouteid") } if !s.Ulvrouteid.IsUnset() { vals = append(vals, "ulvrouteid") } if !s.Fieldtech.IsUnset() { vals = append(vals, "fieldtech") } if !s.Ptaid.IsUnset() { vals = append(vals, "ptaid") } if !s.Flowrate.IsUnset() { vals = append(vals, "flowrate") } if !s.Habitat.IsUnset() { vals = append(vals, "habitat") } if !s.Treathectares.IsUnset() { vals = append(vals, "treathectares") } if !s.Invloc.IsUnset() { vals = append(vals, "invloc") } if !s.TempSitecond.IsUnset() { vals = append(vals, "temp_sitecond") } if !s.Sitecond.IsUnset() { vals = append(vals, "sitecond") } if !s.Totalcostprodcut.IsUnset() { vals = append(vals, "totalcostprodcut") } if !s.Creationdate.IsUnset() { vals = append(vals, "creationdate") } if !s.Creator.IsUnset() { vals = append(vals, "creator") } if !s.Editdate.IsUnset() { vals = append(vals, "editdate") } if !s.Editor.IsUnset() { vals = append(vals, "editor") } if !s.Targetspecies.IsUnset() { vals = append(vals, "targetspecies") } 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 } func (s FieldseekerTreatmentSetter) Overwrite(t *FieldseekerTreatment) { if s.Objectid.IsValue() { t.Objectid = s.Objectid.MustGet() } if !s.Activity.IsUnset() { t.Activity = s.Activity.MustGetNull() } if !s.Treatarea.IsUnset() { t.Treatarea = s.Treatarea.MustGetNull() } if !s.Areaunit.IsUnset() { t.Areaunit = s.Areaunit.MustGetNull() } if !s.Product.IsUnset() { t.Product = s.Product.MustGetNull() } if !s.Qty.IsUnset() { t.Qty = s.Qty.MustGetNull() } if !s.Qtyunit.IsUnset() { t.Qtyunit = s.Qtyunit.MustGetNull() } if !s.Method.IsUnset() { t.Method = s.Method.MustGetNull() } if !s.Equiptype.IsUnset() { t.Equiptype = s.Equiptype.MustGetNull() } if !s.Comments.IsUnset() { t.Comments = s.Comments.MustGetNull() } if !s.Avetemp.IsUnset() { t.Avetemp = s.Avetemp.MustGetNull() } if !s.Windspeed.IsUnset() { t.Windspeed = s.Windspeed.MustGetNull() } if !s.Winddir.IsUnset() { t.Winddir = s.Winddir.MustGetNull() } if !s.Raingauge.IsUnset() { t.Raingauge = s.Raingauge.MustGetNull() } if !s.Startdatetime.IsUnset() { t.Startdatetime = s.Startdatetime.MustGetNull() } if !s.Enddatetime.IsUnset() { t.Enddatetime = s.Enddatetime.MustGetNull() } if !s.InspID.IsUnset() { t.InspID = s.InspID.MustGetNull() } if !s.Reviewed.IsUnset() { t.Reviewed = s.Reviewed.MustGetNull() } if !s.Reviewedby.IsUnset() { t.Reviewedby = s.Reviewedby.MustGetNull() } if !s.Revieweddate.IsUnset() { t.Revieweddate = s.Revieweddate.MustGetNull() } if !s.Locationname.IsUnset() { t.Locationname = s.Locationname.MustGetNull() } if !s.Zone.IsUnset() { t.Zone = s.Zone.MustGetNull() } if !s.Warningoverride.IsUnset() { t.Warningoverride = s.Warningoverride.MustGetNull() } if !s.Recordstatus.IsUnset() { t.Recordstatus = s.Recordstatus.MustGetNull() } if !s.Zone2.IsUnset() { t.Zone2 = s.Zone2.MustGetNull() } if !s.Treatacres.IsUnset() { t.Treatacres = s.Treatacres.MustGetNull() } if !s.Tirecount.IsUnset() { t.Tirecount = s.Tirecount.MustGetNull() } if !s.Cbcount.IsUnset() { t.Cbcount = s.Cbcount.MustGetNull() } if !s.Containercount.IsUnset() { t.Containercount = s.Containercount.MustGetNull() } if s.Globalid.IsValue() { t.Globalid = s.Globalid.MustGet() } if !s.Treatmentlength.IsUnset() { t.Treatmentlength = s.Treatmentlength.MustGetNull() } if !s.Treatmenthours.IsUnset() { t.Treatmenthours = s.Treatmenthours.MustGetNull() } if !s.Treatmentlengthunits.IsUnset() { t.Treatmentlengthunits = s.Treatmentlengthunits.MustGetNull() } if !s.Linelocid.IsUnset() { t.Linelocid = s.Linelocid.MustGetNull() } if !s.Pointlocid.IsUnset() { t.Pointlocid = s.Pointlocid.MustGetNull() } if !s.Polygonlocid.IsUnset() { t.Polygonlocid = s.Polygonlocid.MustGetNull() } if !s.Srid.IsUnset() { t.Srid = s.Srid.MustGetNull() } if !s.Sdid.IsUnset() { t.Sdid = s.Sdid.MustGetNull() } if !s.Barrierrouteid.IsUnset() { t.Barrierrouteid = s.Barrierrouteid.MustGetNull() } if !s.Ulvrouteid.IsUnset() { t.Ulvrouteid = s.Ulvrouteid.MustGetNull() } if !s.Fieldtech.IsUnset() { t.Fieldtech = s.Fieldtech.MustGetNull() } if !s.Ptaid.IsUnset() { t.Ptaid = s.Ptaid.MustGetNull() } if !s.Flowrate.IsUnset() { t.Flowrate = s.Flowrate.MustGetNull() } if !s.Habitat.IsUnset() { t.Habitat = s.Habitat.MustGetNull() } if !s.Treathectares.IsUnset() { t.Treathectares = s.Treathectares.MustGetNull() } if !s.Invloc.IsUnset() { t.Invloc = s.Invloc.MustGetNull() } if !s.TempSitecond.IsUnset() { t.TempSitecond = s.TempSitecond.MustGetNull() } if !s.Sitecond.IsUnset() { t.Sitecond = s.Sitecond.MustGetNull() } if !s.Totalcostprodcut.IsUnset() { t.Totalcostprodcut = s.Totalcostprodcut.MustGetNull() } if !s.Creationdate.IsUnset() { t.Creationdate = s.Creationdate.MustGetNull() } if !s.Creator.IsUnset() { t.Creator = s.Creator.MustGetNull() } if !s.Editdate.IsUnset() { t.Editdate = s.Editdate.MustGetNull() } if !s.Editor.IsUnset() { t.Editor = s.Editor.MustGetNull() } if !s.Targetspecies.IsUnset() { t.Targetspecies = s.Targetspecies.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 *FieldseekerTreatmentSetter) Apply(q *dialect.InsertQuery) { q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { return FieldseekerTreatments.BeforeInsertHooks.RunHooks(ctx, exec, s) }) q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { vals := make([]bob.Expression, 58) if s.Objectid.IsValue() { vals[0] = psql.Arg(s.Objectid.MustGet()) } else { vals[0] = psql.Raw("DEFAULT") } if !s.Activity.IsUnset() { vals[1] = psql.Arg(s.Activity.MustGetNull()) } else { vals[1] = psql.Raw("DEFAULT") } if !s.Treatarea.IsUnset() { vals[2] = psql.Arg(s.Treatarea.MustGetNull()) } else { vals[2] = psql.Raw("DEFAULT") } if !s.Areaunit.IsUnset() { vals[3] = psql.Arg(s.Areaunit.MustGetNull()) } else { vals[3] = psql.Raw("DEFAULT") } if !s.Product.IsUnset() { vals[4] = psql.Arg(s.Product.MustGetNull()) } else { vals[4] = psql.Raw("DEFAULT") } if !s.Qty.IsUnset() { vals[5] = psql.Arg(s.Qty.MustGetNull()) } else { vals[5] = psql.Raw("DEFAULT") } if !s.Qtyunit.IsUnset() { vals[6] = psql.Arg(s.Qtyunit.MustGetNull()) } else { vals[6] = psql.Raw("DEFAULT") } if !s.Method.IsUnset() { vals[7] = psql.Arg(s.Method.MustGetNull()) } else { vals[7] = psql.Raw("DEFAULT") } if !s.Equiptype.IsUnset() { vals[8] = psql.Arg(s.Equiptype.MustGetNull()) } else { vals[8] = psql.Raw("DEFAULT") } if !s.Comments.IsUnset() { vals[9] = psql.Arg(s.Comments.MustGetNull()) } else { vals[9] = psql.Raw("DEFAULT") } if !s.Avetemp.IsUnset() { vals[10] = psql.Arg(s.Avetemp.MustGetNull()) } else { vals[10] = psql.Raw("DEFAULT") } if !s.Windspeed.IsUnset() { vals[11] = psql.Arg(s.Windspeed.MustGetNull()) } else { vals[11] = psql.Raw("DEFAULT") } if !s.Winddir.IsUnset() { vals[12] = psql.Arg(s.Winddir.MustGetNull()) } else { vals[12] = psql.Raw("DEFAULT") } if !s.Raingauge.IsUnset() { vals[13] = psql.Arg(s.Raingauge.MustGetNull()) } else { vals[13] = psql.Raw("DEFAULT") } if !s.Startdatetime.IsUnset() { vals[14] = psql.Arg(s.Startdatetime.MustGetNull()) } else { vals[14] = psql.Raw("DEFAULT") } if !s.Enddatetime.IsUnset() { vals[15] = psql.Arg(s.Enddatetime.MustGetNull()) } else { vals[15] = psql.Raw("DEFAULT") } if !s.InspID.IsUnset() { vals[16] = psql.Arg(s.InspID.MustGetNull()) } else { vals[16] = psql.Raw("DEFAULT") } if !s.Reviewed.IsUnset() { vals[17] = psql.Arg(s.Reviewed.MustGetNull()) } else { vals[17] = psql.Raw("DEFAULT") } if !s.Reviewedby.IsUnset() { vals[18] = psql.Arg(s.Reviewedby.MustGetNull()) } else { vals[18] = psql.Raw("DEFAULT") } if !s.Revieweddate.IsUnset() { vals[19] = psql.Arg(s.Revieweddate.MustGetNull()) } else { vals[19] = psql.Raw("DEFAULT") } if !s.Locationname.IsUnset() { vals[20] = psql.Arg(s.Locationname.MustGetNull()) } else { vals[20] = psql.Raw("DEFAULT") } if !s.Zone.IsUnset() { vals[21] = psql.Arg(s.Zone.MustGetNull()) } else { vals[21] = psql.Raw("DEFAULT") } if !s.Warningoverride.IsUnset() { vals[22] = psql.Arg(s.Warningoverride.MustGetNull()) } else { vals[22] = psql.Raw("DEFAULT") } if !s.Recordstatus.IsUnset() { vals[23] = psql.Arg(s.Recordstatus.MustGetNull()) } else { vals[23] = psql.Raw("DEFAULT") } if !s.Zone2.IsUnset() { vals[24] = psql.Arg(s.Zone2.MustGetNull()) } else { vals[24] = psql.Raw("DEFAULT") } if !s.Treatacres.IsUnset() { vals[25] = psql.Arg(s.Treatacres.MustGetNull()) } else { vals[25] = psql.Raw("DEFAULT") } if !s.Tirecount.IsUnset() { vals[26] = psql.Arg(s.Tirecount.MustGetNull()) } else { vals[26] = psql.Raw("DEFAULT") } if !s.Cbcount.IsUnset() { vals[27] = psql.Arg(s.Cbcount.MustGetNull()) } else { vals[27] = psql.Raw("DEFAULT") } if !s.Containercount.IsUnset() { vals[28] = psql.Arg(s.Containercount.MustGetNull()) } else { vals[28] = psql.Raw("DEFAULT") } if s.Globalid.IsValue() { vals[29] = psql.Arg(s.Globalid.MustGet()) } else { vals[29] = psql.Raw("DEFAULT") } if !s.Treatmentlength.IsUnset() { vals[30] = psql.Arg(s.Treatmentlength.MustGetNull()) } else { vals[30] = psql.Raw("DEFAULT") } if !s.Treatmenthours.IsUnset() { vals[31] = psql.Arg(s.Treatmenthours.MustGetNull()) } else { vals[31] = psql.Raw("DEFAULT") } if !s.Treatmentlengthunits.IsUnset() { vals[32] = psql.Arg(s.Treatmentlengthunits.MustGetNull()) } else { vals[32] = psql.Raw("DEFAULT") } if !s.Linelocid.IsUnset() { vals[33] = psql.Arg(s.Linelocid.MustGetNull()) } else { vals[33] = psql.Raw("DEFAULT") } if !s.Pointlocid.IsUnset() { vals[34] = psql.Arg(s.Pointlocid.MustGetNull()) } else { vals[34] = psql.Raw("DEFAULT") } if !s.Polygonlocid.IsUnset() { vals[35] = psql.Arg(s.Polygonlocid.MustGetNull()) } else { vals[35] = psql.Raw("DEFAULT") } if !s.Srid.IsUnset() { vals[36] = psql.Arg(s.Srid.MustGetNull()) } else { vals[36] = psql.Raw("DEFAULT") } if !s.Sdid.IsUnset() { vals[37] = psql.Arg(s.Sdid.MustGetNull()) } else { vals[37] = psql.Raw("DEFAULT") } if !s.Barrierrouteid.IsUnset() { vals[38] = psql.Arg(s.Barrierrouteid.MustGetNull()) } else { vals[38] = psql.Raw("DEFAULT") } if !s.Ulvrouteid.IsUnset() { vals[39] = psql.Arg(s.Ulvrouteid.MustGetNull()) } else { vals[39] = psql.Raw("DEFAULT") } if !s.Fieldtech.IsUnset() { vals[40] = psql.Arg(s.Fieldtech.MustGetNull()) } else { vals[40] = psql.Raw("DEFAULT") } if !s.Ptaid.IsUnset() { vals[41] = psql.Arg(s.Ptaid.MustGetNull()) } else { vals[41] = psql.Raw("DEFAULT") } if !s.Flowrate.IsUnset() { vals[42] = psql.Arg(s.Flowrate.MustGetNull()) } else { vals[42] = psql.Raw("DEFAULT") } if !s.Habitat.IsUnset() { vals[43] = psql.Arg(s.Habitat.MustGetNull()) } else { vals[43] = psql.Raw("DEFAULT") } if !s.Treathectares.IsUnset() { vals[44] = psql.Arg(s.Treathectares.MustGetNull()) } else { vals[44] = psql.Raw("DEFAULT") } if !s.Invloc.IsUnset() { vals[45] = psql.Arg(s.Invloc.MustGetNull()) } else { vals[45] = psql.Raw("DEFAULT") } if !s.TempSitecond.IsUnset() { vals[46] = psql.Arg(s.TempSitecond.MustGetNull()) } else { vals[46] = psql.Raw("DEFAULT") } if !s.Sitecond.IsUnset() { vals[47] = psql.Arg(s.Sitecond.MustGetNull()) } else { vals[47] = psql.Raw("DEFAULT") } if !s.Totalcostprodcut.IsUnset() { vals[48] = psql.Arg(s.Totalcostprodcut.MustGetNull()) } else { vals[48] = psql.Raw("DEFAULT") } if !s.Creationdate.IsUnset() { vals[49] = psql.Arg(s.Creationdate.MustGetNull()) } else { vals[49] = psql.Raw("DEFAULT") } if !s.Creator.IsUnset() { vals[50] = psql.Arg(s.Creator.MustGetNull()) } else { vals[50] = psql.Raw("DEFAULT") } if !s.Editdate.IsUnset() { vals[51] = psql.Arg(s.Editdate.MustGetNull()) } else { vals[51] = psql.Raw("DEFAULT") } if !s.Editor.IsUnset() { vals[52] = psql.Arg(s.Editor.MustGetNull()) } else { vals[52] = psql.Raw("DEFAULT") } if !s.Targetspecies.IsUnset() { vals[53] = psql.Arg(s.Targetspecies.MustGetNull()) } else { vals[53] = psql.Raw("DEFAULT") } if s.Geometry.IsValue() { vals[54] = psql.Arg(s.Geometry.MustGet()) } else { vals[54] = psql.Raw("DEFAULT") } if !s.Geospatial.IsUnset() { vals[55] = psql.Arg(s.Geospatial.MustGetNull()) } else { vals[55] = psql.Raw("DEFAULT") } if s.Version.IsValue() { vals[56] = psql.Arg(s.Version.MustGet()) } else { vals[56] = psql.Raw("DEFAULT") } if s.OrganizationID.IsValue() { vals[57] = psql.Arg(s.OrganizationID.MustGet()) } else { vals[57] = psql.Raw("DEFAULT") } return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } func (s FieldseekerTreatmentSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { return um.Set(s.Expressions()...) } func (s FieldseekerTreatmentSetter) Expressions(prefix ...string) []bob.Expression { exprs := make([]bob.Expression, 0, 58) if s.Objectid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "objectid")...), psql.Arg(s.Objectid), }}) } if !s.Activity.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "activity")...), psql.Arg(s.Activity), }}) } if !s.Treatarea.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "treatarea")...), psql.Arg(s.Treatarea), }}) } if !s.Areaunit.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "areaunit")...), psql.Arg(s.Areaunit), }}) } if !s.Product.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "product")...), psql.Arg(s.Product), }}) } if !s.Qty.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "qty")...), psql.Arg(s.Qty), }}) } if !s.Qtyunit.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "qtyunit")...), psql.Arg(s.Qtyunit), }}) } if !s.Method.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "method")...), psql.Arg(s.Method), }}) } if !s.Equiptype.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "equiptype")...), psql.Arg(s.Equiptype), }}) } if !s.Comments.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "comments")...), psql.Arg(s.Comments), }}) } if !s.Avetemp.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "avetemp")...), psql.Arg(s.Avetemp), }}) } if !s.Windspeed.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "windspeed")...), psql.Arg(s.Windspeed), }}) } if !s.Winddir.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "winddir")...), psql.Arg(s.Winddir), }}) } if !s.Raingauge.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "raingauge")...), psql.Arg(s.Raingauge), }}) } if !s.Startdatetime.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "startdatetime")...), psql.Arg(s.Startdatetime), }}) } if !s.Enddatetime.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "enddatetime")...), psql.Arg(s.Enddatetime), }}) } if !s.InspID.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "insp_id")...), psql.Arg(s.InspID), }}) } if !s.Reviewed.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "reviewed")...), psql.Arg(s.Reviewed), }}) } if !s.Reviewedby.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "reviewedby")...), psql.Arg(s.Reviewedby), }}) } if !s.Revieweddate.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "revieweddate")...), psql.Arg(s.Revieweddate), }}) } if !s.Locationname.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "locationname")...), psql.Arg(s.Locationname), }}) } if !s.Zone.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "zone")...), psql.Arg(s.Zone), }}) } if !s.Warningoverride.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "warningoverride")...), psql.Arg(s.Warningoverride), }}) } if !s.Recordstatus.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "recordstatus")...), psql.Arg(s.Recordstatus), }}) } if !s.Zone2.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "zone2")...), psql.Arg(s.Zone2), }}) } if !s.Treatacres.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "treatacres")...), psql.Arg(s.Treatacres), }}) } if !s.Tirecount.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "tirecount")...), psql.Arg(s.Tirecount), }}) } if !s.Cbcount.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "cbcount")...), psql.Arg(s.Cbcount), }}) } if !s.Containercount.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "containercount")...), psql.Arg(s.Containercount), }}) } if s.Globalid.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "globalid")...), psql.Arg(s.Globalid), }}) } if !s.Treatmentlength.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "treatmentlength")...), psql.Arg(s.Treatmentlength), }}) } if !s.Treatmenthours.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "treatmenthours")...), psql.Arg(s.Treatmenthours), }}) } if !s.Treatmentlengthunits.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "treatmentlengthunits")...), psql.Arg(s.Treatmentlengthunits), }}) } if !s.Linelocid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "linelocid")...), psql.Arg(s.Linelocid), }}) } if !s.Pointlocid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "pointlocid")...), psql.Arg(s.Pointlocid), }}) } if !s.Polygonlocid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "polygonlocid")...), psql.Arg(s.Polygonlocid), }}) } if !s.Srid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "srid")...), psql.Arg(s.Srid), }}) } if !s.Sdid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "sdid")...), psql.Arg(s.Sdid), }}) } if !s.Barrierrouteid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "barrierrouteid")...), psql.Arg(s.Barrierrouteid), }}) } if !s.Ulvrouteid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "ulvrouteid")...), psql.Arg(s.Ulvrouteid), }}) } if !s.Fieldtech.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "fieldtech")...), psql.Arg(s.Fieldtech), }}) } if !s.Ptaid.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "ptaid")...), psql.Arg(s.Ptaid), }}) } if !s.Flowrate.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "flowrate")...), psql.Arg(s.Flowrate), }}) } if !s.Habitat.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "habitat")...), psql.Arg(s.Habitat), }}) } if !s.Treathectares.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "treathectares")...), psql.Arg(s.Treathectares), }}) } if !s.Invloc.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "invloc")...), psql.Arg(s.Invloc), }}) } if !s.TempSitecond.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "temp_sitecond")...), psql.Arg(s.TempSitecond), }}) } if !s.Sitecond.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "sitecond")...), psql.Arg(s.Sitecond), }}) } if !s.Totalcostprodcut.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "totalcostprodcut")...), psql.Arg(s.Totalcostprodcut), }}) } if !s.Creationdate.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "creationdate")...), psql.Arg(s.Creationdate), }}) } if !s.Creator.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "creator")...), psql.Arg(s.Creator), }}) } if !s.Editdate.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "editdate")...), psql.Arg(s.Editdate), }}) } if !s.Editor.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "editor")...), psql.Arg(s.Editor), }}) } if !s.Targetspecies.IsUnset() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ psql.Quote(append(prefix, "targetspecies")...), psql.Arg(s.Targetspecies), }}) } 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")...), psql.Arg(s.Version), }}) } 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 } // FindFieldseekerTreatment retrieves a single record by primary key // If cols is empty Find will return all columns. func FindFieldseekerTreatment(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerTreatment, error) { if len(cols) == 0 { return FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(VersionPK))), ).One(ctx, exec) } return FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(VersionPK))), sm.Columns(FieldseekerTreatments.Columns.Only(cols...)), ).One(ctx, exec) } // FieldseekerTreatmentExists checks the presence of a single record by primary key func FieldseekerTreatmentExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) { return FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(ObjectidPK))), sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(VersionPK))), ).Exists(ctx, exec) } // AfterQueryHook is called after FieldseekerTreatment is retrieved from the database func (o *FieldseekerTreatment) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { var err error switch queryType { case bob.QueryTypeSelect: ctx, err = FieldseekerTreatments.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerTreatmentSlice{o}) case bob.QueryTypeInsert: ctx, err = FieldseekerTreatments.AfterInsertHooks.RunHooks(ctx, exec, FieldseekerTreatmentSlice{o}) case bob.QueryTypeUpdate: ctx, err = FieldseekerTreatments.AfterUpdateHooks.RunHooks(ctx, exec, FieldseekerTreatmentSlice{o}) case bob.QueryTypeDelete: ctx, err = FieldseekerTreatments.AfterDeleteHooks.RunHooks(ctx, exec, FieldseekerTreatmentSlice{o}) } return err } // primaryKeyVals returns the primary key values of the FieldseekerTreatment func (o *FieldseekerTreatment) primaryKeyVals() bob.Expression { return psql.ArgGroup( o.Objectid, o.Version, ) } func (o *FieldseekerTreatment) pkEQ() dialect.Expression { return psql.Group(psql.Quote("fieldseeker.treatment", "objectid"), psql.Quote("fieldseeker.treatment", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { return o.primaryKeyVals().WriteSQL(ctx, w, d, start) })) } // Update uses an executor to update the FieldseekerTreatment func (o *FieldseekerTreatment) Update(ctx context.Context, exec bob.Executor, s *FieldseekerTreatmentSetter) error { v, err := FieldseekerTreatments.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec) if err != nil { return err } o.R = v.R *o = *v return nil } // Delete deletes a single FieldseekerTreatment record with an executor func (o *FieldseekerTreatment) Delete(ctx context.Context, exec bob.Executor) error { _, err := FieldseekerTreatments.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec) return err } // Reload refreshes the FieldseekerTreatment using the executor func (o *FieldseekerTreatment) Reload(ctx context.Context, exec bob.Executor) error { o2, err := FieldseekerTreatments.Query( sm.Where(FieldseekerTreatments.Columns.Objectid.EQ(psql.Arg(o.Objectid))), sm.Where(FieldseekerTreatments.Columns.Version.EQ(psql.Arg(o.Version))), ).One(ctx, exec) if err != nil { return err } o2.R = o.R *o = *o2 return nil } // AfterQueryHook is called after FieldseekerTreatmentSlice is retrieved from the database func (o FieldseekerTreatmentSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { var err error switch queryType { case bob.QueryTypeSelect: ctx, err = FieldseekerTreatments.AfterSelectHooks.RunHooks(ctx, exec, o) case bob.QueryTypeInsert: ctx, err = FieldseekerTreatments.AfterInsertHooks.RunHooks(ctx, exec, o) case bob.QueryTypeUpdate: ctx, err = FieldseekerTreatments.AfterUpdateHooks.RunHooks(ctx, exec, o) case bob.QueryTypeDelete: ctx, err = FieldseekerTreatments.AfterDeleteHooks.RunHooks(ctx, exec, o) } return err } func (o FieldseekerTreatmentSlice) pkIN() dialect.Expression { if len(o) == 0 { return psql.Raw("NULL") } return psql.Group(psql.Quote("fieldseeker.treatment", "objectid"), psql.Quote("fieldseeker.treatment", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { pkPairs := make([]bob.Expression, len(o)) for i, row := range o { pkPairs[i] = row.primaryKeyVals() } return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "") })) } // copyMatchingRows finds models in the given slice that have the same primary key // then it first copies the existing relationships from the old model to the new model // and then replaces the old model in the slice with the new model func (o FieldseekerTreatmentSlice) copyMatchingRows(from ...*FieldseekerTreatment) { for i, old := range o { for _, new := range from { if new.Objectid != old.Objectid { continue } if new.Version != old.Version { continue } new.R = old.R o[i] = new break } } } // UpdateMod modifies an update query with "WHERE primary_key IN (o...)" func (o FieldseekerTreatmentSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] { return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) { q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { return FieldseekerTreatments.BeforeUpdateHooks.RunHooks(ctx, exec, o) }) q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { var err error switch retrieved := retrieved.(type) { case *FieldseekerTreatment: o.copyMatchingRows(retrieved) case []*FieldseekerTreatment: o.copyMatchingRows(retrieved...) case FieldseekerTreatmentSlice: o.copyMatchingRows(retrieved...) default: // If the retrieved value is not a FieldseekerTreatment or a slice of FieldseekerTreatment // then run the AfterUpdateHooks on the slice _, err = FieldseekerTreatments.AfterUpdateHooks.RunHooks(ctx, exec, o) } return err })) q.AppendWhere(o.pkIN()) }) } // DeleteMod modifies an delete query with "WHERE primary_key IN (o...)" func (o FieldseekerTreatmentSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] { return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) { q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { return FieldseekerTreatments.BeforeDeleteHooks.RunHooks(ctx, exec, o) }) q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { var err error switch retrieved := retrieved.(type) { case *FieldseekerTreatment: o.copyMatchingRows(retrieved) case []*FieldseekerTreatment: o.copyMatchingRows(retrieved...) case FieldseekerTreatmentSlice: o.copyMatchingRows(retrieved...) default: // If the retrieved value is not a FieldseekerTreatment or a slice of FieldseekerTreatment // then run the AfterDeleteHooks on the slice _, err = FieldseekerTreatments.AfterDeleteHooks.RunHooks(ctx, exec, o) } return err })) q.AppendWhere(o.pkIN()) }) } func (o FieldseekerTreatmentSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals FieldseekerTreatmentSetter) error { if len(o) == 0 { return nil } _, err := FieldseekerTreatments.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec) return err } func (o FieldseekerTreatmentSlice) DeleteAll(ctx context.Context, exec bob.Executor) error { if len(o) == 0 { return nil } _, err := FieldseekerTreatments.Delete(o.DeleteMod()).Exec(ctx, exec) return err } func (o FieldseekerTreatmentSlice) ReloadAll(ctx context.Context, exec bob.Executor) error { if len(o) == 0 { return nil } o2, err := FieldseekerTreatments.Query(sm.Where(o.pkIN())).All(ctx, exec) if err != nil { return err } o.copyMatchingRows(o2...) return nil } // Organization starts a query for related objects on organization func (o *FieldseekerTreatment) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery { return Organizations.Query(append(mods, sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))), )...) } func (os FieldseekerTreatmentSlice) 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 attachFieldseekerTreatmentOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerTreatment0 *FieldseekerTreatment, organization1 *Organization) (*FieldseekerTreatment, error) { setter := &FieldseekerTreatmentSetter{ OrganizationID: omit.From(organization1.ID), } err := fieldseekerTreatment0.Update(ctx, exec, setter) if err != nil { return nil, fmt.Errorf("attachFieldseekerTreatmentOrganization0: %w", err) } return fieldseekerTreatment0, nil } func (fieldseekerTreatment0 *FieldseekerTreatment) 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 = attachFieldseekerTreatmentOrganization0(ctx, exec, 1, fieldseekerTreatment0, organization1) if err != nil { return err } fieldseekerTreatment0.R.Organization = organization1 organization1.R.Treatments = append(organization1.R.Treatments, fieldseekerTreatment0) return nil } func (fieldseekerTreatment0 *FieldseekerTreatment) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error { var err error _, err = attachFieldseekerTreatmentOrganization0(ctx, exec, 1, fieldseekerTreatment0, organization1) if err != nil { return err } fieldseekerTreatment0.R.Organization = organization1 organization1.R.Treatments = append(organization1.R.Treatments, fieldseekerTreatment0) return nil } type fieldseekerTreatmentWhere[Q psql.Filterable] struct { Objectid psql.WhereMod[Q, int64] Activity psql.WhereNullMod[Q, string] Treatarea psql.WhereNullMod[Q, float64] Areaunit psql.WhereNullMod[Q, string] Product psql.WhereNullMod[Q, string] Qty psql.WhereNullMod[Q, float64] Qtyunit psql.WhereNullMod[Q, string] Method psql.WhereNullMod[Q, string] Equiptype psql.WhereNullMod[Q, string] Comments psql.WhereNullMod[Q, string] Avetemp psql.WhereNullMod[Q, float64] Windspeed psql.WhereNullMod[Q, float64] Winddir psql.WhereNullMod[Q, string] Raingauge psql.WhereNullMod[Q, float64] Startdatetime psql.WhereNullMod[Q, time.Time] Enddatetime psql.WhereNullMod[Q, time.Time] InspID psql.WhereNullMod[Q, uuid.UUID] Reviewed psql.WhereNullMod[Q, int16] Reviewedby psql.WhereNullMod[Q, string] Revieweddate psql.WhereNullMod[Q, time.Time] Locationname psql.WhereNullMod[Q, string] Zone psql.WhereNullMod[Q, string] Warningoverride psql.WhereNullMod[Q, int16] Recordstatus psql.WhereNullMod[Q, int16] Zone2 psql.WhereNullMod[Q, string] Treatacres psql.WhereNullMod[Q, float64] Tirecount psql.WhereNullMod[Q, int16] Cbcount psql.WhereNullMod[Q, int16] Containercount psql.WhereNullMod[Q, int16] Globalid psql.WhereMod[Q, uuid.UUID] Treatmentlength psql.WhereNullMod[Q, float64] Treatmenthours psql.WhereNullMod[Q, float64] Treatmentlengthunits psql.WhereNullMod[Q, string] Linelocid psql.WhereNullMod[Q, uuid.UUID] Pointlocid psql.WhereNullMod[Q, uuid.UUID] Polygonlocid psql.WhereNullMod[Q, uuid.UUID] Srid psql.WhereNullMod[Q, uuid.UUID] Sdid psql.WhereNullMod[Q, uuid.UUID] Barrierrouteid psql.WhereNullMod[Q, uuid.UUID] Ulvrouteid psql.WhereNullMod[Q, uuid.UUID] Fieldtech psql.WhereNullMod[Q, string] Ptaid psql.WhereNullMod[Q, uuid.UUID] Flowrate psql.WhereNullMod[Q, float64] Habitat psql.WhereNullMod[Q, string] Treathectares psql.WhereNullMod[Q, float64] Invloc psql.WhereNullMod[Q, string] TempSitecond psql.WhereNullMod[Q, string] Sitecond psql.WhereNullMod[Q, string] Totalcostprodcut psql.WhereNullMod[Q, float64] Creationdate psql.WhereNullMod[Q, time.Time] Creator psql.WhereNullMod[Q, string] Editdate psql.WhereNullMod[Q, time.Time] Editor psql.WhereNullMod[Q, string] Targetspecies 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] H3cell psql.WhereNullMod[Q, string] } func (fieldseekerTreatmentWhere[Q]) AliasedAs(alias string) fieldseekerTreatmentWhere[Q] { return buildFieldseekerTreatmentWhere[Q](buildFieldseekerTreatmentColumns(alias)) } func buildFieldseekerTreatmentWhere[Q psql.Filterable](cols fieldseekerTreatmentColumns) fieldseekerTreatmentWhere[Q] { return fieldseekerTreatmentWhere[Q]{ Objectid: psql.Where[Q, int64](cols.Objectid), Activity: psql.WhereNull[Q, string](cols.Activity), Treatarea: psql.WhereNull[Q, float64](cols.Treatarea), Areaunit: psql.WhereNull[Q, string](cols.Areaunit), Product: psql.WhereNull[Q, string](cols.Product), Qty: psql.WhereNull[Q, float64](cols.Qty), Qtyunit: psql.WhereNull[Q, string](cols.Qtyunit), Method: psql.WhereNull[Q, string](cols.Method), Equiptype: psql.WhereNull[Q, string](cols.Equiptype), Comments: psql.WhereNull[Q, string](cols.Comments), Avetemp: psql.WhereNull[Q, float64](cols.Avetemp), Windspeed: psql.WhereNull[Q, float64](cols.Windspeed), Winddir: psql.WhereNull[Q, string](cols.Winddir), Raingauge: psql.WhereNull[Q, float64](cols.Raingauge), Startdatetime: psql.WhereNull[Q, time.Time](cols.Startdatetime), Enddatetime: psql.WhereNull[Q, time.Time](cols.Enddatetime), InspID: psql.WhereNull[Q, uuid.UUID](cols.InspID), Reviewed: psql.WhereNull[Q, int16](cols.Reviewed), Reviewedby: psql.WhereNull[Q, string](cols.Reviewedby), Revieweddate: psql.WhereNull[Q, time.Time](cols.Revieweddate), Locationname: psql.WhereNull[Q, string](cols.Locationname), Zone: psql.WhereNull[Q, string](cols.Zone), Warningoverride: psql.WhereNull[Q, int16](cols.Warningoverride), Recordstatus: psql.WhereNull[Q, int16](cols.Recordstatus), Zone2: psql.WhereNull[Q, string](cols.Zone2), Treatacres: psql.WhereNull[Q, float64](cols.Treatacres), Tirecount: psql.WhereNull[Q, int16](cols.Tirecount), Cbcount: psql.WhereNull[Q, int16](cols.Cbcount), Containercount: psql.WhereNull[Q, int16](cols.Containercount), Globalid: psql.Where[Q, uuid.UUID](cols.Globalid), Treatmentlength: psql.WhereNull[Q, float64](cols.Treatmentlength), Treatmenthours: psql.WhereNull[Q, float64](cols.Treatmenthours), Treatmentlengthunits: psql.WhereNull[Q, string](cols.Treatmentlengthunits), Linelocid: psql.WhereNull[Q, uuid.UUID](cols.Linelocid), Pointlocid: psql.WhereNull[Q, uuid.UUID](cols.Pointlocid), Polygonlocid: psql.WhereNull[Q, uuid.UUID](cols.Polygonlocid), Srid: psql.WhereNull[Q, uuid.UUID](cols.Srid), Sdid: psql.WhereNull[Q, uuid.UUID](cols.Sdid), Barrierrouteid: psql.WhereNull[Q, uuid.UUID](cols.Barrierrouteid), Ulvrouteid: psql.WhereNull[Q, uuid.UUID](cols.Ulvrouteid), Fieldtech: psql.WhereNull[Q, string](cols.Fieldtech), Ptaid: psql.WhereNull[Q, uuid.UUID](cols.Ptaid), Flowrate: psql.WhereNull[Q, float64](cols.Flowrate), Habitat: psql.WhereNull[Q, string](cols.Habitat), Treathectares: psql.WhereNull[Q, float64](cols.Treathectares), Invloc: psql.WhereNull[Q, string](cols.Invloc), TempSitecond: psql.WhereNull[Q, string](cols.TempSitecond), Sitecond: psql.WhereNull[Q, string](cols.Sitecond), Totalcostprodcut: psql.WhereNull[Q, float64](cols.Totalcostprodcut), Creationdate: psql.WhereNull[Q, time.Time](cols.Creationdate), Creator: psql.WhereNull[Q, string](cols.Creator), Editdate: psql.WhereNull[Q, time.Time](cols.Editdate), Editor: psql.WhereNull[Q, string](cols.Editor), Targetspecies: psql.WhereNull[Q, string](cols.Targetspecies), 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), H3cell: psql.WhereNull[Q, string](cols.H3cell), } } func (o *FieldseekerTreatment) Preload(name string, retrieved any) error { if o == nil { return nil } switch name { case "Organization": rel, ok := retrieved.(*Organization) if !ok { return fmt.Errorf("fieldseekerTreatment cannot load %T as %q", retrieved, name) } o.R.Organization = rel if rel != nil { rel.R.Treatments = FieldseekerTreatmentSlice{o} } return nil default: return fmt.Errorf("fieldseekerTreatment has no relationship %q", name) } } type fieldseekerTreatmentPreloader struct { Organization func(...psql.PreloadOption) psql.Preloader } func buildFieldseekerTreatmentPreloader() fieldseekerTreatmentPreloader { return fieldseekerTreatmentPreloader{ Organization: func(opts ...psql.PreloadOption) psql.Preloader { return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{ Name: "Organization", Sides: []psql.PreloadSide{ { From: FieldseekerTreatments, To: Organizations, FromColumns: []string{"organization_id"}, ToColumns: []string{"id"}, }, }, }, Organizations.Columns.Names(), opts...) }, } } type fieldseekerTreatmentThenLoader[Q orm.Loadable] struct { Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] } func buildFieldseekerTreatmentThenLoader[Q orm.Loadable]() fieldseekerTreatmentThenLoader[Q] { type OrganizationLoadInterface interface { LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error } return fieldseekerTreatmentThenLoader[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 fieldseekerTreatment's Organization into the .R struct func (o *FieldseekerTreatment) 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.Treatments = FieldseekerTreatmentSlice{o} o.R.Organization = related return nil } // LoadOrganization loads the fieldseekerTreatment's Organization into the .R struct func (os FieldseekerTreatmentSlice) 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.Treatments = append(rel.R.Treatments, o) o.R.Organization = rel break } } return nil } type fieldseekerTreatmentJoins[Q dialect.Joinable] struct { typ string Organization modAs[Q, organizationColumns] } func (j fieldseekerTreatmentJoins[Q]) aliasedAs(alias string) fieldseekerTreatmentJoins[Q] { return buildFieldseekerTreatmentJoins[Q](buildFieldseekerTreatmentColumns(alias), j.typ) } func buildFieldseekerTreatmentJoins[Q dialect.Joinable](cols fieldseekerTreatmentColumns, typ string) fieldseekerTreatmentJoins[Q] { return fieldseekerTreatmentJoins[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 }, }, } }