// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.

package models

import (
	"context"
	"encoding/json"
	"fmt"
	"io"
	"time"

	"github.com/Gleipnir-Technology/bob"
	"github.com/Gleipnir-Technology/bob/dialect/psql"
	"github.com/Gleipnir-Technology/bob/dialect/psql/dialect"
	"github.com/Gleipnir-Technology/bob/dialect/psql/dm"
	"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
	"github.com/Gleipnir-Technology/bob/dialect/psql/um"
	"github.com/Gleipnir-Technology/bob/expr"
	"github.com/Gleipnir-Technology/bob/orm"
	"github.com/Gleipnir-Technology/bob/types"
	"github.com/Gleipnir-Technology/bob/types/pgtypes"
	"github.com/aarondl/opt/null"
	"github.com/aarondl/opt/omit"
	"github.com/aarondl/opt/omitnull"
	"github.com/google/uuid"
)

// FieldseekerMosquitoinspection is an object representing the database table.
type FieldseekerMosquitoinspection struct {
	Objectid int64 `db:"objectid" `
	// Original attribute from ArcGIS API is NUMDIPS
	Numdips null.Val[int16] `db:"numdips" `
	// Original attribute from ArcGIS API is ACTIVITY
	Activity null.Val[string] `db:"activity" `
	// Original attribute from ArcGIS API is BREEDING
	Breeding null.Val[string] `db:"breeding" `
	// Original attribute from ArcGIS API is TOTLARVAE
	Totlarvae null.Val[int16] `db:"totlarvae" `
	// Original attribute from ArcGIS API is TOTPUPAE
	Totpupae null.Val[int16] `db:"totpupae" `
	// Original attribute from ArcGIS API is EGGS
	Eggs null.Val[int16] `db:"eggs" `
	// Original attribute from ArcGIS API is POSDIPS
	Posdips null.Val[int16] `db:"posdips" `
	// Original attribute from ArcGIS API is ADULTACT
	Adultact null.Val[string] `db:"adultact" `
	// Original attribute from ArcGIS API is LSTAGES
	Lstages null.Val[string] `db:"lstages" `
	// Original attribute from ArcGIS API is DOMSTAGE
	Domstage null.Val[string] `db:"domstage" `
	// Original attribute from ArcGIS API is ACTIONTAKEN
	Actiontaken null.Val[string] `db:"actiontaken" `
	// 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 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 WINDDIR
	Winddir null.Val[string] `db:"winddir" `
	// Original attribute from ArcGIS API is AVGLARVAE
	Avglarvae null.Val[float64] `db:"avglarvae" `
	// Original attribute from ArcGIS API is AVGPUPAE
	Avgpupae null.Val[float64] `db:"avgpupae" `
	// 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 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 PERSONALCONTACT
	Personalcontact null.Val[int16] `db:"personalcontact" `
	// 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 FIELDSPECIES
	Fieldspecies null.Val[string] `db:"fieldspecies" `
	// Original attribute from ArcGIS API is GlobalID
	Globalid uuid.UUID `db:"globalid,pk" `
	// 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" `
	// 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 FIELDTECH
	Fieldtech null.Val[string] `db:"fieldtech" `
	// Original attribute from ArcGIS API is LARVAEPRESENT
	Larvaepresent null.Val[int16] `db:"larvaepresent" `
	// Original attribute from ArcGIS API is PUPAEPRESENT
	Pupaepresent null.Val[int16] `db:"pupaepresent" `
	// Original attribute from ArcGIS API is SDID
	Sdid null.Val[uuid.UUID] `db:"sdid" `
	// Original attribute from ArcGIS API is SITECOND
	Sitecond null.Val[string] `db:"sitecond" `
	// Original attribute from ArcGIS API is POSITIVECONTAINERCOUNT
	Positivecontainercount null.Val[int16] `db:"positivecontainercount" `
	// 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 JURISDICTION
	Jurisdiction null.Val[string] `db:"jurisdiction" `
	// Original attribute from ArcGIS API is VISUALMONITORING
	Visualmonitoring null.Val[int16] `db:"visualmonitoring" `
	// Original attribute from ArcGIS API is VMCOMMENTS
	Vmcomments null.Val[string] `db:"vmcomments" `
	// Original attribute from ArcGIS API is adminAction
	Adminaction null.Val[string] `db:"adminaction" `
	// Original attribute from ArcGIS API is PTAID
	Ptaid          null.Val[uuid.UUID]         `db:"ptaid" `
	Geometry       types.JSON[json.RawMessage] `db:"geometry" `
	Geospatial     null.Val[string]            `db:"geospatial" `
	Version        int32                       `db:"version,pk" `
	OrganizationID int32                       `db:"organization_id" `

	R fieldseekerMosquitoinspectionR `db:"-" `
}

// FieldseekerMosquitoinspectionSlice is an alias for a slice of pointers to FieldseekerMosquitoinspection.
// This should almost always be used instead of []*FieldseekerMosquitoinspection.
type FieldseekerMosquitoinspectionSlice []*FieldseekerMosquitoinspection

// FieldseekerMosquitoinspections contains methods to work with the mosquitoinspection table
var FieldseekerMosquitoinspections = psql.NewTablex[*FieldseekerMosquitoinspection, FieldseekerMosquitoinspectionSlice, *FieldseekerMosquitoinspectionSetter]("fieldseeker", "mosquitoinspection", buildFieldseekerMosquitoinspectionColumns("fieldseeker.mosquitoinspection"))

// FieldseekerMosquitoinspectionsQuery is a query on the mosquitoinspection table
type FieldseekerMosquitoinspectionsQuery = *psql.ViewQuery[*FieldseekerMosquitoinspection, FieldseekerMosquitoinspectionSlice]

// fieldseekerMosquitoinspectionR is where relationships are stored.
type fieldseekerMosquitoinspectionR struct {
	Organization *Organization // fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey
}

func buildFieldseekerMosquitoinspectionColumns(alias string) fieldseekerMosquitoinspectionColumns {
	return fieldseekerMosquitoinspectionColumns{
		ColumnsExpr: expr.NewColumnsExpr(
			"objectid", "numdips", "activity", "breeding", "totlarvae", "totpupae", "eggs", "posdips", "adultact", "lstages", "domstage", "actiontaken", "comments", "avetemp", "windspeed", "raingauge", "startdatetime", "enddatetime", "winddir", "avglarvae", "avgpupae", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "personalcontact", "tirecount", "cbcount", "containercount", "fieldspecies", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "linelocid", "pointlocid", "polygonlocid", "srid", "fieldtech", "larvaepresent", "pupaepresent", "sdid", "sitecond", "positivecontainercount", "creationdate", "creator", "editdate", "editor", "jurisdiction", "visualmonitoring", "vmcomments", "adminaction", "ptaid", "geometry", "geospatial", "version", "organization_id",
		).WithParent("fieldseeker.mosquitoinspection"),
		tableAlias:             alias,
		Objectid:               psql.Quote(alias, "objectid"),
		Numdips:                psql.Quote(alias, "numdips"),
		Activity:               psql.Quote(alias, "activity"),
		Breeding:               psql.Quote(alias, "breeding"),
		Totlarvae:              psql.Quote(alias, "totlarvae"),
		Totpupae:               psql.Quote(alias, "totpupae"),
		Eggs:                   psql.Quote(alias, "eggs"),
		Posdips:                psql.Quote(alias, "posdips"),
		Adultact:               psql.Quote(alias, "adultact"),
		Lstages:                psql.Quote(alias, "lstages"),
		Domstage:               psql.Quote(alias, "domstage"),
		Actiontaken:            psql.Quote(alias, "actiontaken"),
		Comments:               psql.Quote(alias, "comments"),
		Avetemp:                psql.Quote(alias, "avetemp"),
		Windspeed:              psql.Quote(alias, "windspeed"),
		Raingauge:              psql.Quote(alias, "raingauge"),
		Startdatetime:          psql.Quote(alias, "startdatetime"),
		Enddatetime:            psql.Quote(alias, "enddatetime"),
		Winddir:                psql.Quote(alias, "winddir"),
		Avglarvae:              psql.Quote(alias, "avglarvae"),
		Avgpupae:               psql.Quote(alias, "avgpupae"),
		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"),
		Recordstatus:           psql.Quote(alias, "recordstatus"),
		Zone2:                  psql.Quote(alias, "zone2"),
		Personalcontact:        psql.Quote(alias, "personalcontact"),
		Tirecount:              psql.Quote(alias, "tirecount"),
		Cbcount:                psql.Quote(alias, "cbcount"),
		Containercount:         psql.Quote(alias, "containercount"),
		Fieldspecies:           psql.Quote(alias, "fieldspecies"),
		Globalid:               psql.Quote(alias, "globalid"),
		CreatedUser:            psql.Quote(alias, "created_user"),
		CreatedDate:            psql.Quote(alias, "created_date"),
		LastEditedUser:         psql.Quote(alias, "last_edited_user"),
		LastEditedDate:         psql.Quote(alias, "last_edited_date"),
		Linelocid:              psql.Quote(alias, "linelocid"),
		Pointlocid:             psql.Quote(alias, "pointlocid"),
		Polygonlocid:           psql.Quote(alias, "polygonlocid"),
		Srid:                   psql.Quote(alias, "srid"),
		Fieldtech:              psql.Quote(alias, "fieldtech"),
		Larvaepresent:          psql.Quote(alias, "larvaepresent"),
		Pupaepresent:           psql.Quote(alias, "pupaepresent"),
		Sdid:                   psql.Quote(alias, "sdid"),
		Sitecond:               psql.Quote(alias, "sitecond"),
		Positivecontainercount: psql.Quote(alias, "positivecontainercount"),
		Creationdate:           psql.Quote(alias, "creationdate"),
		Creator:                psql.Quote(alias, "creator"),
		Editdate:               psql.Quote(alias, "editdate"),
		Editor:                 psql.Quote(alias, "editor"),
		Jurisdiction:           psql.Quote(alias, "jurisdiction"),
		Visualmonitoring:       psql.Quote(alias, "visualmonitoring"),
		Vmcomments:             psql.Quote(alias, "vmcomments"),
		Adminaction:            psql.Quote(alias, "adminaction"),
		Ptaid:                  psql.Quote(alias, "ptaid"),
		Geometry:               psql.Quote(alias, "geometry"),
		Geospatial:             psql.Quote(alias, "geospatial"),
		Version:                psql.Quote(alias, "version"),
		OrganizationID:         psql.Quote(alias, "organization_id"),
	}
}

type fieldseekerMosquitoinspectionColumns struct {
	expr.ColumnsExpr
	tableAlias             string
	Objectid               psql.Expression
	Numdips                psql.Expression
	Activity               psql.Expression
	Breeding               psql.Expression
	Totlarvae              psql.Expression
	Totpupae               psql.Expression
	Eggs                   psql.Expression
	Posdips                psql.Expression
	Adultact               psql.Expression
	Lstages                psql.Expression
	Domstage               psql.Expression
	Actiontaken            psql.Expression
	Comments               psql.Expression
	Avetemp                psql.Expression
	Windspeed              psql.Expression
	Raingauge              psql.Expression
	Startdatetime          psql.Expression
	Enddatetime            psql.Expression
	Winddir                psql.Expression
	Avglarvae              psql.Expression
	Avgpupae               psql.Expression
	Reviewed               psql.Expression
	Reviewedby             psql.Expression
	Revieweddate           psql.Expression
	Locationname           psql.Expression
	Zone                   psql.Expression
	Recordstatus           psql.Expression
	Zone2                  psql.Expression
	Personalcontact        psql.Expression
	Tirecount              psql.Expression
	Cbcount                psql.Expression
	Containercount         psql.Expression
	Fieldspecies           psql.Expression
	Globalid               psql.Expression
	CreatedUser            psql.Expression
	CreatedDate            psql.Expression
	LastEditedUser         psql.Expression
	LastEditedDate         psql.Expression
	Linelocid              psql.Expression
	Pointlocid             psql.Expression
	Polygonlocid           psql.Expression
	Srid                   psql.Expression
	Fieldtech              psql.Expression
	Larvaepresent          psql.Expression
	Pupaepresent           psql.Expression
	Sdid                   psql.Expression
	Sitecond               psql.Expression
	Positivecontainercount psql.Expression
	Creationdate           psql.Expression
	Creator                psql.Expression
	Editdate               psql.Expression
	Editor                 psql.Expression
	Jurisdiction           psql.Expression
	Visualmonitoring       psql.Expression
	Vmcomments             psql.Expression
	Adminaction            psql.Expression
	Ptaid                  psql.Expression
	Geometry               psql.Expression
	Geospatial             psql.Expression
	Version                psql.Expression
	OrganizationID         psql.Expression
}

func (c fieldseekerMosquitoinspectionColumns) Alias() string {
	return c.tableAlias
}

func (fieldseekerMosquitoinspectionColumns) AliasedAs(alias string) fieldseekerMosquitoinspectionColumns {
	return buildFieldseekerMosquitoinspectionColumns(alias)
}

// FieldseekerMosquitoinspectionSetter is used for insert/upsert/update operations
// All values are optional, and do not have to be set
// Generated columns are not included
type FieldseekerMosquitoinspectionSetter struct {
	Objectid               omit.Val[int64]                       `db:"objectid" `
	Numdips                omitnull.Val[int16]                   `db:"numdips" `
	Activity               omitnull.Val[string]                  `db:"activity" `
	Breeding               omitnull.Val[string]                  `db:"breeding" `
	Totlarvae              omitnull.Val[int16]                   `db:"totlarvae" `
	Totpupae               omitnull.Val[int16]                   `db:"totpupae" `
	Eggs                   omitnull.Val[int16]                   `db:"eggs" `
	Posdips                omitnull.Val[int16]                   `db:"posdips" `
	Adultact               omitnull.Val[string]                  `db:"adultact" `
	Lstages                omitnull.Val[string]                  `db:"lstages" `
	Domstage               omitnull.Val[string]                  `db:"domstage" `
	Actiontaken            omitnull.Val[string]                  `db:"actiontaken" `
	Comments               omitnull.Val[string]                  `db:"comments" `
	Avetemp                omitnull.Val[float64]                 `db:"avetemp" `
	Windspeed              omitnull.Val[float64]                 `db:"windspeed" `
	Raingauge              omitnull.Val[float64]                 `db:"raingauge" `
	Startdatetime          omitnull.Val[time.Time]               `db:"startdatetime" `
	Enddatetime            omitnull.Val[time.Time]               `db:"enddatetime" `
	Winddir                omitnull.Val[string]                  `db:"winddir" `
	Avglarvae              omitnull.Val[float64]                 `db:"avglarvae" `
	Avgpupae               omitnull.Val[float64]                 `db:"avgpupae" `
	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" `
	Recordstatus           omitnull.Val[int16]                   `db:"recordstatus" `
	Zone2                  omitnull.Val[string]                  `db:"zone2" `
	Personalcontact        omitnull.Val[int16]                   `db:"personalcontact" `
	Tirecount              omitnull.Val[int16]                   `db:"tirecount" `
	Cbcount                omitnull.Val[int16]                   `db:"cbcount" `
	Containercount         omitnull.Val[int16]                   `db:"containercount" `
	Fieldspecies           omitnull.Val[string]                  `db:"fieldspecies" `
	Globalid               omit.Val[uuid.UUID]                   `db:"globalid,pk" `
	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" `
	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" `
	Fieldtech              omitnull.Val[string]                  `db:"fieldtech" `
	Larvaepresent          omitnull.Val[int16]                   `db:"larvaepresent" `
	Pupaepresent           omitnull.Val[int16]                   `db:"pupaepresent" `
	Sdid                   omitnull.Val[uuid.UUID]               `db:"sdid" `
	Sitecond               omitnull.Val[string]                  `db:"sitecond" `
	Positivecontainercount omitnull.Val[int16]                   `db:"positivecontainercount" `
	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" `
	Jurisdiction           omitnull.Val[string]                  `db:"jurisdiction" `
	Visualmonitoring       omitnull.Val[int16]                   `db:"visualmonitoring" `
	Vmcomments             omitnull.Val[string]                  `db:"vmcomments" `
	Adminaction            omitnull.Val[string]                  `db:"adminaction" `
	Ptaid                  omitnull.Val[uuid.UUID]               `db:"ptaid" `
	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 FieldseekerMosquitoinspectionSetter) SetColumns() []string {
	vals := make([]string, 0, 61)
	if s.Objectid.IsValue() {
		vals = append(vals, "objectid")
	}
	if !s.Numdips.IsUnset() {
		vals = append(vals, "numdips")
	}
	if !s.Activity.IsUnset() {
		vals = append(vals, "activity")
	}
	if !s.Breeding.IsUnset() {
		vals = append(vals, "breeding")
	}
	if !s.Totlarvae.IsUnset() {
		vals = append(vals, "totlarvae")
	}
	if !s.Totpupae.IsUnset() {
		vals = append(vals, "totpupae")
	}
	if !s.Eggs.IsUnset() {
		vals = append(vals, "eggs")
	}
	if !s.Posdips.IsUnset() {
		vals = append(vals, "posdips")
	}
	if !s.Adultact.IsUnset() {
		vals = append(vals, "adultact")
	}
	if !s.Lstages.IsUnset() {
		vals = append(vals, "lstages")
	}
	if !s.Domstage.IsUnset() {
		vals = append(vals, "domstage")
	}
	if !s.Actiontaken.IsUnset() {
		vals = append(vals, "actiontaken")
	}
	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.Raingauge.IsUnset() {
		vals = append(vals, "raingauge")
	}
	if !s.Startdatetime.IsUnset() {
		vals = append(vals, "startdatetime")
	}
	if !s.Enddatetime.IsUnset() {
		vals = append(vals, "enddatetime")
	}
	if !s.Winddir.IsUnset() {
		vals = append(vals, "winddir")
	}
	if !s.Avglarvae.IsUnset() {
		vals = append(vals, "avglarvae")
	}
	if !s.Avgpupae.IsUnset() {
		vals = append(vals, "avgpupae")
	}
	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.Recordstatus.IsUnset() {
		vals = append(vals, "recordstatus")
	}
	if !s.Zone2.IsUnset() {
		vals = append(vals, "zone2")
	}
	if !s.Personalcontact.IsUnset() {
		vals = append(vals, "personalcontact")
	}
	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.Fieldspecies.IsUnset() {
		vals = append(vals, "fieldspecies")
	}
	if s.Globalid.IsValue() {
		vals = append(vals, "globalid")
	}
	if !s.CreatedUser.IsUnset() {
		vals = append(vals, "created_user")
	}
	if !s.CreatedDate.IsUnset() {
		vals = append(vals, "created_date")
	}
	if !s.LastEditedUser.IsUnset() {
		vals = append(vals, "last_edited_user")
	}
	if !s.LastEditedDate.IsUnset() {
		vals = append(vals, "last_edited_date")
	}
	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.Fieldtech.IsUnset() {
		vals = append(vals, "fieldtech")
	}
	if !s.Larvaepresent.IsUnset() {
		vals = append(vals, "larvaepresent")
	}
	if !s.Pupaepresent.IsUnset() {
		vals = append(vals, "pupaepresent")
	}
	if !s.Sdid.IsUnset() {
		vals = append(vals, "sdid")
	}
	if !s.Sitecond.IsUnset() {
		vals = append(vals, "sitecond")
	}
	if !s.Positivecontainercount.IsUnset() {
		vals = append(vals, "positivecontainercount")
	}
	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.Jurisdiction.IsUnset() {
		vals = append(vals, "jurisdiction")
	}
	if !s.Visualmonitoring.IsUnset() {
		vals = append(vals, "visualmonitoring")
	}
	if !s.Vmcomments.IsUnset() {
		vals = append(vals, "vmcomments")
	}
	if !s.Adminaction.IsUnset() {
		vals = append(vals, "adminaction")
	}
	if !s.Ptaid.IsUnset() {
		vals = append(vals, "ptaid")
	}
	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 FieldseekerMosquitoinspectionSetter) Overwrite(t *FieldseekerMosquitoinspection) {
	if s.Objectid.IsValue() {
		t.Objectid = s.Objectid.MustGet()
	}
	if !s.Numdips.IsUnset() {
		t.Numdips = s.Numdips.MustGetNull()
	}
	if !s.Activity.IsUnset() {
		t.Activity = s.Activity.MustGetNull()
	}
	if !s.Breeding.IsUnset() {
		t.Breeding = s.Breeding.MustGetNull()
	}
	if !s.Totlarvae.IsUnset() {
		t.Totlarvae = s.Totlarvae.MustGetNull()
	}
	if !s.Totpupae.IsUnset() {
		t.Totpupae = s.Totpupae.MustGetNull()
	}
	if !s.Eggs.IsUnset() {
		t.Eggs = s.Eggs.MustGetNull()
	}
	if !s.Posdips.IsUnset() {
		t.Posdips = s.Posdips.MustGetNull()
	}
	if !s.Adultact.IsUnset() {
		t.Adultact = s.Adultact.MustGetNull()
	}
	if !s.Lstages.IsUnset() {
		t.Lstages = s.Lstages.MustGetNull()
	}
	if !s.Domstage.IsUnset() {
		t.Domstage = s.Domstage.MustGetNull()
	}
	if !s.Actiontaken.IsUnset() {
		t.Actiontaken = s.Actiontaken.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.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.Winddir.IsUnset() {
		t.Winddir = s.Winddir.MustGetNull()
	}
	if !s.Avglarvae.IsUnset() {
		t.Avglarvae = s.Avglarvae.MustGetNull()
	}
	if !s.Avgpupae.IsUnset() {
		t.Avgpupae = s.Avgpupae.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.Recordstatus.IsUnset() {
		t.Recordstatus = s.Recordstatus.MustGetNull()
	}
	if !s.Zone2.IsUnset() {
		t.Zone2 = s.Zone2.MustGetNull()
	}
	if !s.Personalcontact.IsUnset() {
		t.Personalcontact = s.Personalcontact.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.Fieldspecies.IsUnset() {
		t.Fieldspecies = s.Fieldspecies.MustGetNull()
	}
	if s.Globalid.IsValue() {
		t.Globalid = s.Globalid.MustGet()
	}
	if !s.CreatedUser.IsUnset() {
		t.CreatedUser = s.CreatedUser.MustGetNull()
	}
	if !s.CreatedDate.IsUnset() {
		t.CreatedDate = s.CreatedDate.MustGetNull()
	}
	if !s.LastEditedUser.IsUnset() {
		t.LastEditedUser = s.LastEditedUser.MustGetNull()
	}
	if !s.LastEditedDate.IsUnset() {
		t.LastEditedDate = s.LastEditedDate.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.Fieldtech.IsUnset() {
		t.Fieldtech = s.Fieldtech.MustGetNull()
	}
	if !s.Larvaepresent.IsUnset() {
		t.Larvaepresent = s.Larvaepresent.MustGetNull()
	}
	if !s.Pupaepresent.IsUnset() {
		t.Pupaepresent = s.Pupaepresent.MustGetNull()
	}
	if !s.Sdid.IsUnset() {
		t.Sdid = s.Sdid.MustGetNull()
	}
	if !s.Sitecond.IsUnset() {
		t.Sitecond = s.Sitecond.MustGetNull()
	}
	if !s.Positivecontainercount.IsUnset() {
		t.Positivecontainercount = s.Positivecontainercount.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.Jurisdiction.IsUnset() {
		t.Jurisdiction = s.Jurisdiction.MustGetNull()
	}
	if !s.Visualmonitoring.IsUnset() {
		t.Visualmonitoring = s.Visualmonitoring.MustGetNull()
	}
	if !s.Vmcomments.IsUnset() {
		t.Vmcomments = s.Vmcomments.MustGetNull()
	}
	if !s.Adminaction.IsUnset() {
		t.Adminaction = s.Adminaction.MustGetNull()
	}
	if !s.Ptaid.IsUnset() {
		t.Ptaid = s.Ptaid.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 *FieldseekerMosquitoinspectionSetter) Apply(q *dialect.InsertQuery) {
	q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
		return FieldseekerMosquitoinspections.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, 61)
		if s.Objectid.IsValue() {
			vals[0] = psql.Arg(s.Objectid.MustGet())
		} else {
			vals[0] = psql.Raw("DEFAULT")
		}

		if !s.Numdips.IsUnset() {
			vals[1] = psql.Arg(s.Numdips.MustGetNull())
		} else {
			vals[1] = psql.Raw("DEFAULT")
		}

		if !s.Activity.IsUnset() {
			vals[2] = psql.Arg(s.Activity.MustGetNull())
		} else {
			vals[2] = psql.Raw("DEFAULT")
		}

		if !s.Breeding.IsUnset() {
			vals[3] = psql.Arg(s.Breeding.MustGetNull())
		} else {
			vals[3] = psql.Raw("DEFAULT")
		}

		if !s.Totlarvae.IsUnset() {
			vals[4] = psql.Arg(s.Totlarvae.MustGetNull())
		} else {
			vals[4] = psql.Raw("DEFAULT")
		}

		if !s.Totpupae.IsUnset() {
			vals[5] = psql.Arg(s.Totpupae.MustGetNull())
		} else {
			vals[5] = psql.Raw("DEFAULT")
		}

		if !s.Eggs.IsUnset() {
			vals[6] = psql.Arg(s.Eggs.MustGetNull())
		} else {
			vals[6] = psql.Raw("DEFAULT")
		}

		if !s.Posdips.IsUnset() {
			vals[7] = psql.Arg(s.Posdips.MustGetNull())
		} else {
			vals[7] = psql.Raw("DEFAULT")
		}

		if !s.Adultact.IsUnset() {
			vals[8] = psql.Arg(s.Adultact.MustGetNull())
		} else {
			vals[8] = psql.Raw("DEFAULT")
		}

		if !s.Lstages.IsUnset() {
			vals[9] = psql.Arg(s.Lstages.MustGetNull())
		} else {
			vals[9] = psql.Raw("DEFAULT")
		}

		if !s.Domstage.IsUnset() {
			vals[10] = psql.Arg(s.Domstage.MustGetNull())
		} else {
			vals[10] = psql.Raw("DEFAULT")
		}

		if !s.Actiontaken.IsUnset() {
			vals[11] = psql.Arg(s.Actiontaken.MustGetNull())
		} else {
			vals[11] = psql.Raw("DEFAULT")
		}

		if !s.Comments.IsUnset() {
			vals[12] = psql.Arg(s.Comments.MustGetNull())
		} else {
			vals[12] = psql.Raw("DEFAULT")
		}

		if !s.Avetemp.IsUnset() {
			vals[13] = psql.Arg(s.Avetemp.MustGetNull())
		} else {
			vals[13] = psql.Raw("DEFAULT")
		}

		if !s.Windspeed.IsUnset() {
			vals[14] = psql.Arg(s.Windspeed.MustGetNull())
		} else {
			vals[14] = psql.Raw("DEFAULT")
		}

		if !s.Raingauge.IsUnset() {
			vals[15] = psql.Arg(s.Raingauge.MustGetNull())
		} else {
			vals[15] = psql.Raw("DEFAULT")
		}

		if !s.Startdatetime.IsUnset() {
			vals[16] = psql.Arg(s.Startdatetime.MustGetNull())
		} else {
			vals[16] = psql.Raw("DEFAULT")
		}

		if !s.Enddatetime.IsUnset() {
			vals[17] = psql.Arg(s.Enddatetime.MustGetNull())
		} else {
			vals[17] = psql.Raw("DEFAULT")
		}

		if !s.Winddir.IsUnset() {
			vals[18] = psql.Arg(s.Winddir.MustGetNull())
		} else {
			vals[18] = psql.Raw("DEFAULT")
		}

		if !s.Avglarvae.IsUnset() {
			vals[19] = psql.Arg(s.Avglarvae.MustGetNull())
		} else {
			vals[19] = psql.Raw("DEFAULT")
		}

		if !s.Avgpupae.IsUnset() {
			vals[20] = psql.Arg(s.Avgpupae.MustGetNull())
		} else {
			vals[20] = psql.Raw("DEFAULT")
		}

		if !s.Reviewed.IsUnset() {
			vals[21] = psql.Arg(s.Reviewed.MustGetNull())
		} else {
			vals[21] = psql.Raw("DEFAULT")
		}

		if !s.Reviewedby.IsUnset() {
			vals[22] = psql.Arg(s.Reviewedby.MustGetNull())
		} else {
			vals[22] = psql.Raw("DEFAULT")
		}

		if !s.Revieweddate.IsUnset() {
			vals[23] = psql.Arg(s.Revieweddate.MustGetNull())
		} else {
			vals[23] = psql.Raw("DEFAULT")
		}

		if !s.Locationname.IsUnset() {
			vals[24] = psql.Arg(s.Locationname.MustGetNull())
		} else {
			vals[24] = psql.Raw("DEFAULT")
		}

		if !s.Zone.IsUnset() {
			vals[25] = psql.Arg(s.Zone.MustGetNull())
		} else {
			vals[25] = psql.Raw("DEFAULT")
		}

		if !s.Recordstatus.IsUnset() {
			vals[26] = psql.Arg(s.Recordstatus.MustGetNull())
		} else {
			vals[26] = psql.Raw("DEFAULT")
		}

		if !s.Zone2.IsUnset() {
			vals[27] = psql.Arg(s.Zone2.MustGetNull())
		} else {
			vals[27] = psql.Raw("DEFAULT")
		}

		if !s.Personalcontact.IsUnset() {
			vals[28] = psql.Arg(s.Personalcontact.MustGetNull())
		} else {
			vals[28] = psql.Raw("DEFAULT")
		}

		if !s.Tirecount.IsUnset() {
			vals[29] = psql.Arg(s.Tirecount.MustGetNull())
		} else {
			vals[29] = psql.Raw("DEFAULT")
		}

		if !s.Cbcount.IsUnset() {
			vals[30] = psql.Arg(s.Cbcount.MustGetNull())
		} else {
			vals[30] = psql.Raw("DEFAULT")
		}

		if !s.Containercount.IsUnset() {
			vals[31] = psql.Arg(s.Containercount.MustGetNull())
		} else {
			vals[31] = psql.Raw("DEFAULT")
		}

		if !s.Fieldspecies.IsUnset() {
			vals[32] = psql.Arg(s.Fieldspecies.MustGetNull())
		} else {
			vals[32] = psql.Raw("DEFAULT")
		}

		if s.Globalid.IsValue() {
			vals[33] = psql.Arg(s.Globalid.MustGet())
		} else {
			vals[33] = psql.Raw("DEFAULT")
		}

		if !s.CreatedUser.IsUnset() {
			vals[34] = psql.Arg(s.CreatedUser.MustGetNull())
		} else {
			vals[34] = psql.Raw("DEFAULT")
		}

		if !s.CreatedDate.IsUnset() {
			vals[35] = psql.Arg(s.CreatedDate.MustGetNull())
		} else {
			vals[35] = psql.Raw("DEFAULT")
		}

		if !s.LastEditedUser.IsUnset() {
			vals[36] = psql.Arg(s.LastEditedUser.MustGetNull())
		} else {
			vals[36] = psql.Raw("DEFAULT")
		}

		if !s.LastEditedDate.IsUnset() {
			vals[37] = psql.Arg(s.LastEditedDate.MustGetNull())
		} else {
			vals[37] = psql.Raw("DEFAULT")
		}

		if !s.Linelocid.IsUnset() {
			vals[38] = psql.Arg(s.Linelocid.MustGetNull())
		} else {
			vals[38] = psql.Raw("DEFAULT")
		}

		if !s.Pointlocid.IsUnset() {
			vals[39] = psql.Arg(s.Pointlocid.MustGetNull())
		} else {
			vals[39] = psql.Raw("DEFAULT")
		}

		if !s.Polygonlocid.IsUnset() {
			vals[40] = psql.Arg(s.Polygonlocid.MustGetNull())
		} else {
			vals[40] = psql.Raw("DEFAULT")
		}

		if !s.Srid.IsUnset() {
			vals[41] = psql.Arg(s.Srid.MustGetNull())
		} else {
			vals[41] = psql.Raw("DEFAULT")
		}

		if !s.Fieldtech.IsUnset() {
			vals[42] = psql.Arg(s.Fieldtech.MustGetNull())
		} else {
			vals[42] = psql.Raw("DEFAULT")
		}

		if !s.Larvaepresent.IsUnset() {
			vals[43] = psql.Arg(s.Larvaepresent.MustGetNull())
		} else {
			vals[43] = psql.Raw("DEFAULT")
		}

		if !s.Pupaepresent.IsUnset() {
			vals[44] = psql.Arg(s.Pupaepresent.MustGetNull())
		} else {
			vals[44] = psql.Raw("DEFAULT")
		}

		if !s.Sdid.IsUnset() {
			vals[45] = psql.Arg(s.Sdid.MustGetNull())
		} else {
			vals[45] = psql.Raw("DEFAULT")
		}

		if !s.Sitecond.IsUnset() {
			vals[46] = psql.Arg(s.Sitecond.MustGetNull())
		} else {
			vals[46] = psql.Raw("DEFAULT")
		}

		if !s.Positivecontainercount.IsUnset() {
			vals[47] = psql.Arg(s.Positivecontainercount.MustGetNull())
		} else {
			vals[47] = psql.Raw("DEFAULT")
		}

		if !s.Creationdate.IsUnset() {
			vals[48] = psql.Arg(s.Creationdate.MustGetNull())
		} else {
			vals[48] = psql.Raw("DEFAULT")
		}

		if !s.Creator.IsUnset() {
			vals[49] = psql.Arg(s.Creator.MustGetNull())
		} else {
			vals[49] = psql.Raw("DEFAULT")
		}

		if !s.Editdate.IsUnset() {
			vals[50] = psql.Arg(s.Editdate.MustGetNull())
		} else {
			vals[50] = psql.Raw("DEFAULT")
		}

		if !s.Editor.IsUnset() {
			vals[51] = psql.Arg(s.Editor.MustGetNull())
		} else {
			vals[51] = psql.Raw("DEFAULT")
		}

		if !s.Jurisdiction.IsUnset() {
			vals[52] = psql.Arg(s.Jurisdiction.MustGetNull())
		} else {
			vals[52] = psql.Raw("DEFAULT")
		}

		if !s.Visualmonitoring.IsUnset() {
			vals[53] = psql.Arg(s.Visualmonitoring.MustGetNull())
		} else {
			vals[53] = psql.Raw("DEFAULT")
		}

		if !s.Vmcomments.IsUnset() {
			vals[54] = psql.Arg(s.Vmcomments.MustGetNull())
		} else {
			vals[54] = psql.Raw("DEFAULT")
		}

		if !s.Adminaction.IsUnset() {
			vals[55] = psql.Arg(s.Adminaction.MustGetNull())
		} else {
			vals[55] = psql.Raw("DEFAULT")
		}

		if !s.Ptaid.IsUnset() {
			vals[56] = psql.Arg(s.Ptaid.MustGetNull())
		} else {
			vals[56] = psql.Raw("DEFAULT")
		}

		if s.Geometry.IsValue() {
			vals[57] = psql.Arg(s.Geometry.MustGet())
		} else {
			vals[57] = psql.Raw("DEFAULT")
		}

		if !s.Geospatial.IsUnset() {
			vals[58] = psql.Arg(s.Geospatial.MustGetNull())
		} else {
			vals[58] = psql.Raw("DEFAULT")
		}

		if s.Version.IsValue() {
			vals[59] = psql.Arg(s.Version.MustGet())
		} else {
			vals[59] = psql.Raw("DEFAULT")
		}

		if s.OrganizationID.IsValue() {
			vals[60] = psql.Arg(s.OrganizationID.MustGet())
		} else {
			vals[60] = psql.Raw("DEFAULT")
		}

		return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
	}))
}

func (s FieldseekerMosquitoinspectionSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
	return um.Set(s.Expressions()...)
}

func (s FieldseekerMosquitoinspectionSetter) Expressions(prefix ...string) []bob.Expression {
	exprs := make([]bob.Expression, 0, 61)

	if s.Objectid.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "objectid")...),
			psql.Arg(s.Objectid),
		}})
	}

	if !s.Numdips.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "numdips")...),
			psql.Arg(s.Numdips),
		}})
	}

	if !s.Activity.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "activity")...),
			psql.Arg(s.Activity),
		}})
	}

	if !s.Breeding.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "breeding")...),
			psql.Arg(s.Breeding),
		}})
	}

	if !s.Totlarvae.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "totlarvae")...),
			psql.Arg(s.Totlarvae),
		}})
	}

	if !s.Totpupae.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "totpupae")...),
			psql.Arg(s.Totpupae),
		}})
	}

	if !s.Eggs.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "eggs")...),
			psql.Arg(s.Eggs),
		}})
	}

	if !s.Posdips.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "posdips")...),
			psql.Arg(s.Posdips),
		}})
	}

	if !s.Adultact.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "adultact")...),
			psql.Arg(s.Adultact),
		}})
	}

	if !s.Lstages.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "lstages")...),
			psql.Arg(s.Lstages),
		}})
	}

	if !s.Domstage.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "domstage")...),
			psql.Arg(s.Domstage),
		}})
	}

	if !s.Actiontaken.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "actiontaken")...),
			psql.Arg(s.Actiontaken),
		}})
	}

	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.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.Winddir.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "winddir")...),
			psql.Arg(s.Winddir),
		}})
	}

	if !s.Avglarvae.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "avglarvae")...),
			psql.Arg(s.Avglarvae),
		}})
	}

	if !s.Avgpupae.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "avgpupae")...),
			psql.Arg(s.Avgpupae),
		}})
	}

	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.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.Personalcontact.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "personalcontact")...),
			psql.Arg(s.Personalcontact),
		}})
	}

	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.Fieldspecies.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "fieldspecies")...),
			psql.Arg(s.Fieldspecies),
		}})
	}

	if s.Globalid.IsValue() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "globalid")...),
			psql.Arg(s.Globalid),
		}})
	}

	if !s.CreatedUser.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "created_user")...),
			psql.Arg(s.CreatedUser),
		}})
	}

	if !s.CreatedDate.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "created_date")...),
			psql.Arg(s.CreatedDate),
		}})
	}

	if !s.LastEditedUser.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "last_edited_user")...),
			psql.Arg(s.LastEditedUser),
		}})
	}

	if !s.LastEditedDate.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "last_edited_date")...),
			psql.Arg(s.LastEditedDate),
		}})
	}

	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.Fieldtech.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "fieldtech")...),
			psql.Arg(s.Fieldtech),
		}})
	}

	if !s.Larvaepresent.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "larvaepresent")...),
			psql.Arg(s.Larvaepresent),
		}})
	}

	if !s.Pupaepresent.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "pupaepresent")...),
			psql.Arg(s.Pupaepresent),
		}})
	}

	if !s.Sdid.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "sdid")...),
			psql.Arg(s.Sdid),
		}})
	}

	if !s.Sitecond.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "sitecond")...),
			psql.Arg(s.Sitecond),
		}})
	}

	if !s.Positivecontainercount.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "positivecontainercount")...),
			psql.Arg(s.Positivecontainercount),
		}})
	}

	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.Jurisdiction.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "jurisdiction")...),
			psql.Arg(s.Jurisdiction),
		}})
	}

	if !s.Visualmonitoring.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "visualmonitoring")...),
			psql.Arg(s.Visualmonitoring),
		}})
	}

	if !s.Vmcomments.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "vmcomments")...),
			psql.Arg(s.Vmcomments),
		}})
	}

	if !s.Adminaction.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "adminaction")...),
			psql.Arg(s.Adminaction),
		}})
	}

	if !s.Ptaid.IsUnset() {
		exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
			psql.Quote(append(prefix, "ptaid")...),
			psql.Arg(s.Ptaid),
		}})
	}

	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
}

// FindFieldseekerMosquitoinspection retrieves a single record by primary key
// If cols is empty Find will return all columns.
func FindFieldseekerMosquitoinspection(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32, cols ...string) (*FieldseekerMosquitoinspection, error) {
	if len(cols) == 0 {
		return FieldseekerMosquitoinspections.Query(
			sm.Where(FieldseekerMosquitoinspections.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
			sm.Where(FieldseekerMosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))),
		).One(ctx, exec)
	}

	return FieldseekerMosquitoinspections.Query(
		sm.Where(FieldseekerMosquitoinspections.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
		sm.Where(FieldseekerMosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))),
		sm.Columns(FieldseekerMosquitoinspections.Columns.Only(cols...)),
	).One(ctx, exec)
}

// FieldseekerMosquitoinspectionExists checks the presence of a single record by primary key
func FieldseekerMosquitoinspectionExists(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32) (bool, error) {
	return FieldseekerMosquitoinspections.Query(
		sm.Where(FieldseekerMosquitoinspections.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
		sm.Where(FieldseekerMosquitoinspections.Columns.Version.EQ(psql.Arg(VersionPK))),
	).Exists(ctx, exec)
}

// AfterQueryHook is called after FieldseekerMosquitoinspection is retrieved from the database
func (o *FieldseekerMosquitoinspection) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
	var err error

	switch queryType {
	case bob.QueryTypeSelect:
		ctx, err = FieldseekerMosquitoinspections.AfterSelectHooks.RunHooks(ctx, exec, FieldseekerMosquitoinspectionSlice{o})
	case bob.QueryTypeInsert:
		ctx, err = FieldseekerMosquitoinspections.AfterInsertHooks.RunHooks(ctx, exec, FieldseekerMosquitoinspectionSlice{o})
	case bob.QueryTypeUpdate:
		ctx, err = FieldseekerMosquitoinspections.AfterUpdateHooks.RunHooks(ctx, exec, FieldseekerMosquitoinspectionSlice{o})
	case bob.QueryTypeDelete:
		ctx, err = FieldseekerMosquitoinspections.AfterDeleteHooks.RunHooks(ctx, exec, FieldseekerMosquitoinspectionSlice{o})
	}

	return err
}

// primaryKeyVals returns the primary key values of the FieldseekerMosquitoinspection
func (o *FieldseekerMosquitoinspection) primaryKeyVals() bob.Expression {
	return psql.ArgGroup(
		o.Globalid,
		o.Version,
	)
}

func (o *FieldseekerMosquitoinspection) pkEQ() dialect.Expression {
	return psql.Group(psql.Quote("fieldseeker.mosquitoinspection", "globalid"), psql.Quote("fieldseeker.mosquitoinspection", "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 FieldseekerMosquitoinspection
func (o *FieldseekerMosquitoinspection) Update(ctx context.Context, exec bob.Executor, s *FieldseekerMosquitoinspectionSetter) error {
	v, err := FieldseekerMosquitoinspections.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 FieldseekerMosquitoinspection record with an executor
func (o *FieldseekerMosquitoinspection) Delete(ctx context.Context, exec bob.Executor) error {
	_, err := FieldseekerMosquitoinspections.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
	return err
}

// Reload refreshes the FieldseekerMosquitoinspection using the executor
func (o *FieldseekerMosquitoinspection) Reload(ctx context.Context, exec bob.Executor) error {
	o2, err := FieldseekerMosquitoinspections.Query(
		sm.Where(FieldseekerMosquitoinspections.Columns.Globalid.EQ(psql.Arg(o.Globalid))),
		sm.Where(FieldseekerMosquitoinspections.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 FieldseekerMosquitoinspectionSlice is retrieved from the database
func (o FieldseekerMosquitoinspectionSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
	var err error

	switch queryType {
	case bob.QueryTypeSelect:
		ctx, err = FieldseekerMosquitoinspections.AfterSelectHooks.RunHooks(ctx, exec, o)
	case bob.QueryTypeInsert:
		ctx, err = FieldseekerMosquitoinspections.AfterInsertHooks.RunHooks(ctx, exec, o)
	case bob.QueryTypeUpdate:
		ctx, err = FieldseekerMosquitoinspections.AfterUpdateHooks.RunHooks(ctx, exec, o)
	case bob.QueryTypeDelete:
		ctx, err = FieldseekerMosquitoinspections.AfterDeleteHooks.RunHooks(ctx, exec, o)
	}

	return err
}

func (o FieldseekerMosquitoinspectionSlice) pkIN() dialect.Expression {
	if len(o) == 0 {
		return psql.Raw("NULL")
	}

	return psql.Group(psql.Quote("fieldseeker.mosquitoinspection", "globalid"), psql.Quote("fieldseeker.mosquitoinspection", "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 FieldseekerMosquitoinspectionSlice) copyMatchingRows(from ...*FieldseekerMosquitoinspection) {
	for i, old := range o {
		for _, new := range from {
			if new.Globalid != old.Globalid {
				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 FieldseekerMosquitoinspectionSlice) 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 FieldseekerMosquitoinspections.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 *FieldseekerMosquitoinspection:
				o.copyMatchingRows(retrieved)
			case []*FieldseekerMosquitoinspection:
				o.copyMatchingRows(retrieved...)
			case FieldseekerMosquitoinspectionSlice:
				o.copyMatchingRows(retrieved...)
			default:
				// If the retrieved value is not a FieldseekerMosquitoinspection or a slice of FieldseekerMosquitoinspection
				// then run the AfterUpdateHooks on the slice
				_, err = FieldseekerMosquitoinspections.AfterUpdateHooks.RunHooks(ctx, exec, o)
			}

			return err
		}))

		q.AppendWhere(o.pkIN())
	})
}

// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
func (o FieldseekerMosquitoinspectionSlice) 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 FieldseekerMosquitoinspections.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 *FieldseekerMosquitoinspection:
				o.copyMatchingRows(retrieved)
			case []*FieldseekerMosquitoinspection:
				o.copyMatchingRows(retrieved...)
			case FieldseekerMosquitoinspectionSlice:
				o.copyMatchingRows(retrieved...)
			default:
				// If the retrieved value is not a FieldseekerMosquitoinspection or a slice of FieldseekerMosquitoinspection
				// then run the AfterDeleteHooks on the slice
				_, err = FieldseekerMosquitoinspections.AfterDeleteHooks.RunHooks(ctx, exec, o)
			}

			return err
		}))

		q.AppendWhere(o.pkIN())
	})
}

func (o FieldseekerMosquitoinspectionSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals FieldseekerMosquitoinspectionSetter) error {
	if len(o) == 0 {
		return nil
	}

	_, err := FieldseekerMosquitoinspections.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
	return err
}

func (o FieldseekerMosquitoinspectionSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
	if len(o) == 0 {
		return nil
	}

	_, err := FieldseekerMosquitoinspections.Delete(o.DeleteMod()).Exec(ctx, exec)
	return err
}

func (o FieldseekerMosquitoinspectionSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
	if len(o) == 0 {
		return nil
	}

	o2, err := FieldseekerMosquitoinspections.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 *FieldseekerMosquitoinspection) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
	return Organizations.Query(append(mods,
		sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
	)...)
}

func (os FieldseekerMosquitoinspectionSlice) 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 attachFieldseekerMosquitoinspectionOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerMosquitoinspection0 *FieldseekerMosquitoinspection, organization1 *Organization) (*FieldseekerMosquitoinspection, error) {
	setter := &FieldseekerMosquitoinspectionSetter{
		OrganizationID: omit.From(organization1.ID),
	}

	err := fieldseekerMosquitoinspection0.Update(ctx, exec, setter)
	if err != nil {
		return nil, fmt.Errorf("attachFieldseekerMosquitoinspectionOrganization0: %w", err)
	}

	return fieldseekerMosquitoinspection0, nil
}

func (fieldseekerMosquitoinspection0 *FieldseekerMosquitoinspection) 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 = attachFieldseekerMosquitoinspectionOrganization0(ctx, exec, 1, fieldseekerMosquitoinspection0, organization1)
	if err != nil {
		return err
	}

	fieldseekerMosquitoinspection0.R.Organization = organization1

	organization1.R.Mosquitoinspections = append(organization1.R.Mosquitoinspections, fieldseekerMosquitoinspection0)

	return nil
}

func (fieldseekerMosquitoinspection0 *FieldseekerMosquitoinspection) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
	var err error

	_, err = attachFieldseekerMosquitoinspectionOrganization0(ctx, exec, 1, fieldseekerMosquitoinspection0, organization1)
	if err != nil {
		return err
	}

	fieldseekerMosquitoinspection0.R.Organization = organization1

	organization1.R.Mosquitoinspections = append(organization1.R.Mosquitoinspections, fieldseekerMosquitoinspection0)

	return nil
}

type fieldseekerMosquitoinspectionWhere[Q psql.Filterable] struct {
	Objectid               psql.WhereMod[Q, int64]
	Numdips                psql.WhereNullMod[Q, int16]
	Activity               psql.WhereNullMod[Q, string]
	Breeding               psql.WhereNullMod[Q, string]
	Totlarvae              psql.WhereNullMod[Q, int16]
	Totpupae               psql.WhereNullMod[Q, int16]
	Eggs                   psql.WhereNullMod[Q, int16]
	Posdips                psql.WhereNullMod[Q, int16]
	Adultact               psql.WhereNullMod[Q, string]
	Lstages                psql.WhereNullMod[Q, string]
	Domstage               psql.WhereNullMod[Q, string]
	Actiontaken            psql.WhereNullMod[Q, string]
	Comments               psql.WhereNullMod[Q, string]
	Avetemp                psql.WhereNullMod[Q, float64]
	Windspeed              psql.WhereNullMod[Q, float64]
	Raingauge              psql.WhereNullMod[Q, float64]
	Startdatetime          psql.WhereNullMod[Q, time.Time]
	Enddatetime            psql.WhereNullMod[Q, time.Time]
	Winddir                psql.WhereNullMod[Q, string]
	Avglarvae              psql.WhereNullMod[Q, float64]
	Avgpupae               psql.WhereNullMod[Q, float64]
	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]
	Recordstatus           psql.WhereNullMod[Q, int16]
	Zone2                  psql.WhereNullMod[Q, string]
	Personalcontact        psql.WhereNullMod[Q, int16]
	Tirecount              psql.WhereNullMod[Q, int16]
	Cbcount                psql.WhereNullMod[Q, int16]
	Containercount         psql.WhereNullMod[Q, int16]
	Fieldspecies           psql.WhereNullMod[Q, string]
	Globalid               psql.WhereMod[Q, uuid.UUID]
	CreatedUser            psql.WhereNullMod[Q, string]
	CreatedDate            psql.WhereNullMod[Q, time.Time]
	LastEditedUser         psql.WhereNullMod[Q, string]
	LastEditedDate         psql.WhereNullMod[Q, time.Time]
	Linelocid              psql.WhereNullMod[Q, uuid.UUID]
	Pointlocid             psql.WhereNullMod[Q, uuid.UUID]
	Polygonlocid           psql.WhereNullMod[Q, uuid.UUID]
	Srid                   psql.WhereNullMod[Q, uuid.UUID]
	Fieldtech              psql.WhereNullMod[Q, string]
	Larvaepresent          psql.WhereNullMod[Q, int16]
	Pupaepresent           psql.WhereNullMod[Q, int16]
	Sdid                   psql.WhereNullMod[Q, uuid.UUID]
	Sitecond               psql.WhereNullMod[Q, string]
	Positivecontainercount psql.WhereNullMod[Q, int16]
	Creationdate           psql.WhereNullMod[Q, time.Time]
	Creator                psql.WhereNullMod[Q, string]
	Editdate               psql.WhereNullMod[Q, time.Time]
	Editor                 psql.WhereNullMod[Q, string]
	Jurisdiction           psql.WhereNullMod[Q, string]
	Visualmonitoring       psql.WhereNullMod[Q, int16]
	Vmcomments             psql.WhereNullMod[Q, string]
	Adminaction            psql.WhereNullMod[Q, string]
	Ptaid                  psql.WhereNullMod[Q, uuid.UUID]
	Geometry               psql.WhereMod[Q, types.JSON[json.RawMessage]]
	Geospatial             psql.WhereNullMod[Q, string]
	Version                psql.WhereMod[Q, int32]
	OrganizationID         psql.WhereMod[Q, int32]
}

func (fieldseekerMosquitoinspectionWhere[Q]) AliasedAs(alias string) fieldseekerMosquitoinspectionWhere[Q] {
	return buildFieldseekerMosquitoinspectionWhere[Q](buildFieldseekerMosquitoinspectionColumns(alias))
}

func buildFieldseekerMosquitoinspectionWhere[Q psql.Filterable](cols fieldseekerMosquitoinspectionColumns) fieldseekerMosquitoinspectionWhere[Q] {
	return fieldseekerMosquitoinspectionWhere[Q]{
		Objectid:               psql.Where[Q, int64](cols.Objectid),
		Numdips:                psql.WhereNull[Q, int16](cols.Numdips),
		Activity:               psql.WhereNull[Q, string](cols.Activity),
		Breeding:               psql.WhereNull[Q, string](cols.Breeding),
		Totlarvae:              psql.WhereNull[Q, int16](cols.Totlarvae),
		Totpupae:               psql.WhereNull[Q, int16](cols.Totpupae),
		Eggs:                   psql.WhereNull[Q, int16](cols.Eggs),
		Posdips:                psql.WhereNull[Q, int16](cols.Posdips),
		Adultact:               psql.WhereNull[Q, string](cols.Adultact),
		Lstages:                psql.WhereNull[Q, string](cols.Lstages),
		Domstage:               psql.WhereNull[Q, string](cols.Domstage),
		Actiontaken:            psql.WhereNull[Q, string](cols.Actiontaken),
		Comments:               psql.WhereNull[Q, string](cols.Comments),
		Avetemp:                psql.WhereNull[Q, float64](cols.Avetemp),
		Windspeed:              psql.WhereNull[Q, float64](cols.Windspeed),
		Raingauge:              psql.WhereNull[Q, float64](cols.Raingauge),
		Startdatetime:          psql.WhereNull[Q, time.Time](cols.Startdatetime),
		Enddatetime:            psql.WhereNull[Q, time.Time](cols.Enddatetime),
		Winddir:                psql.WhereNull[Q, string](cols.Winddir),
		Avglarvae:              psql.WhereNull[Q, float64](cols.Avglarvae),
		Avgpupae:               psql.WhereNull[Q, float64](cols.Avgpupae),
		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),
		Recordstatus:           psql.WhereNull[Q, int16](cols.Recordstatus),
		Zone2:                  psql.WhereNull[Q, string](cols.Zone2),
		Personalcontact:        psql.WhereNull[Q, int16](cols.Personalcontact),
		Tirecount:              psql.WhereNull[Q, int16](cols.Tirecount),
		Cbcount:                psql.WhereNull[Q, int16](cols.Cbcount),
		Containercount:         psql.WhereNull[Q, int16](cols.Containercount),
		Fieldspecies:           psql.WhereNull[Q, string](cols.Fieldspecies),
		Globalid:               psql.Where[Q, uuid.UUID](cols.Globalid),
		CreatedUser:            psql.WhereNull[Q, string](cols.CreatedUser),
		CreatedDate:            psql.WhereNull[Q, time.Time](cols.CreatedDate),
		LastEditedUser:         psql.WhereNull[Q, string](cols.LastEditedUser),
		LastEditedDate:         psql.WhereNull[Q, time.Time](cols.LastEditedDate),
		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),
		Fieldtech:              psql.WhereNull[Q, string](cols.Fieldtech),
		Larvaepresent:          psql.WhereNull[Q, int16](cols.Larvaepresent),
		Pupaepresent:           psql.WhereNull[Q, int16](cols.Pupaepresent),
		Sdid:                   psql.WhereNull[Q, uuid.UUID](cols.Sdid),
		Sitecond:               psql.WhereNull[Q, string](cols.Sitecond),
		Positivecontainercount: psql.WhereNull[Q, int16](cols.Positivecontainercount),
		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),
		Jurisdiction:           psql.WhereNull[Q, string](cols.Jurisdiction),
		Visualmonitoring:       psql.WhereNull[Q, int16](cols.Visualmonitoring),
		Vmcomments:             psql.WhereNull[Q, string](cols.Vmcomments),
		Adminaction:            psql.WhereNull[Q, string](cols.Adminaction),
		Ptaid:                  psql.WhereNull[Q, uuid.UUID](cols.Ptaid),
		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 *FieldseekerMosquitoinspection) Preload(name string, retrieved any) error {
	if o == nil {
		return nil
	}

	switch name {
	case "Organization":
		rel, ok := retrieved.(*Organization)
		if !ok {
			return fmt.Errorf("fieldseekerMosquitoinspection cannot load %T as %q", retrieved, name)
		}

		o.R.Organization = rel

		if rel != nil {
			rel.R.Mosquitoinspections = FieldseekerMosquitoinspectionSlice{o}
		}
		return nil
	default:
		return fmt.Errorf("fieldseekerMosquitoinspection has no relationship %q", name)
	}
}

type fieldseekerMosquitoinspectionPreloader struct {
	Organization func(...psql.PreloadOption) psql.Preloader
}

func buildFieldseekerMosquitoinspectionPreloader() fieldseekerMosquitoinspectionPreloader {
	return fieldseekerMosquitoinspectionPreloader{
		Organization: func(opts ...psql.PreloadOption) psql.Preloader {
			return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
				Name: "Organization",
				Sides: []psql.PreloadSide{
					{
						From:        FieldseekerMosquitoinspections,
						To:          Organizations,
						FromColumns: []string{"organization_id"},
						ToColumns:   []string{"id"},
					},
				},
			}, Organizations.Columns.Names(), opts...)
		},
	}
}

type fieldseekerMosquitoinspectionThenLoader[Q orm.Loadable] struct {
	Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}

func buildFieldseekerMosquitoinspectionThenLoader[Q orm.Loadable]() fieldseekerMosquitoinspectionThenLoader[Q] {
	type OrganizationLoadInterface interface {
		LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
	}

	return fieldseekerMosquitoinspectionThenLoader[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 fieldseekerMosquitoinspection's Organization into the .R struct
func (o *FieldseekerMosquitoinspection) 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.Mosquitoinspections = FieldseekerMosquitoinspectionSlice{o}

	o.R.Organization = related
	return nil
}

// LoadOrganization loads the fieldseekerMosquitoinspection's Organization into the .R struct
func (os FieldseekerMosquitoinspectionSlice) 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.Mosquitoinspections = append(rel.R.Mosquitoinspections, o)

			o.R.Organization = rel
			break
		}
	}

	return nil
}
