// 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"
)

// FieldseekerQamosquitoinspection is an object representing the database table.
type FieldseekerQamosquitoinspection struct {
	Objectid int64 `db:"objectid" `
	// Original attribute from ArcGIS API is POSDIPS
	Posdips null.Val[int16] `db:"posdips" `
	// 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 GlobalID
	Globalid uuid.UUID `db:"globalid,pk" `
	// 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 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 LR
	LR null.Val[int16] `db:"lr" `
	// Original attribute from ArcGIS API is NEGDIPS
	Negdips null.Val[int16] `db:"negdips" `
	// Original attribute from ArcGIS API is TOTALACRES
	Totalacres null.Val[float64] `db:"totalacres" `
	// Original attribute from ArcGIS API is ACRESBREEDING
	Acresbreeding null.Val[float64] `db:"acresbreeding" `
	// Original attribute from ArcGIS API is FISH
	Fish null.Val[int16] `db:"fish" `
	// Original attribute from ArcGIS API is SITETYPE
	Sitetype null.Val[string] `db:"sitetype" `
	// Original attribute from ArcGIS API is BREEDINGPOTENTIAL
	Breedingpotential null.Val[string] `db:"breedingpotential" `
	// Original attribute from ArcGIS API is MOVINGWATER
	Movingwater null.Val[int16] `db:"movingwater" `
	// Original attribute from ArcGIS API is NOWATEREVER
	Nowaterever null.Val[int16] `db:"nowaterever" `
	// Original attribute from ArcGIS API is MOSQUITOHABITAT
	Mosquitohabitat null.Val[string] `db:"mosquitohabitat" `
	// Original attribute from ArcGIS API is HABVALUE1
	Habvalue1 null.Val[int16] `db:"habvalue1" `
	// Original attribute from ArcGIS API is HABVALUE1PERCENT
	Habvalue1percent null.Val[int16] `db:"habvalue1percent" `
	// Original attribute from ArcGIS API is HABVALUE2
	Habvalue2 null.Val[int16] `db:"habvalue2" `
	// Original attribute from ArcGIS API is HABVALUE2PERCENT
	Habvalue2percent null.Val[int16] `db:"habvalue2percent" `
	// Original attribute from ArcGIS API is POTENTIAL
	Potential null.Val[int16] `db:"potential" `
	// Original attribute from ArcGIS API is LARVAEPRESENT
	Larvaepresent null.Val[int16] `db:"larvaepresent" `
	// Original attribute from ArcGIS API is LARVAEINSIDETREATEDAREA
	Larvaeinsidetreatedarea null.Val[int16] `db:"larvaeinsidetreatedarea" `
	// Original attribute from ArcGIS API is LARVAEOUTSIDETREATEDAREA
	Larvaeoutsidetreatedarea null.Val[int16] `db:"larvaeoutsidetreatedarea" `
	// Original attribute from ArcGIS API is LARVAEREASON
	Larvaereason null.Val[string] `db:"larvaereason" `
	// Original attribute from ArcGIS API is AQUATICORGANISMS
	Aquaticorganisms null.Val[string] `db:"aquaticorganisms" `
	// Original attribute from ArcGIS API is VEGETATION
	Vegetation null.Val[string] `db:"vegetation" `
	// Original attribute from ArcGIS API is SOURCEREDUCTION
	Sourcereduction null.Val[string] `db:"sourcereduction" `
	// Original attribute from ArcGIS API is WATERPRESENT
	Waterpresent null.Val[int16] `db:"waterpresent" `
	// Original attribute from ArcGIS API is WATERMOVEMENT1
	Watermovement1 null.Val[string] `db:"watermovement1" `
	// Original attribute from ArcGIS API is WATERMOVEMENT1PERCENT
	Watermovement1percent null.Val[int16] `db:"watermovement1percent" `
	// Original attribute from ArcGIS API is WATERMOVEMENT2
	Watermovement2 null.Val[string] `db:"watermovement2" `
	// Original attribute from ArcGIS API is WATERMOVEMENT2PERCENT
	Watermovement2percent null.Val[int16] `db:"watermovement2percent" `
	// Original attribute from ArcGIS API is SOILCONDITIONS
	Soilconditions null.Val[string] `db:"soilconditions" `
	// Original attribute from ArcGIS API is WATERDURATION
	Waterduration null.Val[string] `db:"waterduration" `
	// Original attribute from ArcGIS API is WATERSOURCE
	Watersource null.Val[string] `db:"watersource" `
	// Original attribute from ArcGIS API is WATERCONDITIONS
	Waterconditions null.Val[string] `db:"waterconditions" `
	// Original attribute from ArcGIS API is ADULTACTIVITY
	Adultactivity null.Val[int16] `db:"adultactivity" `
	// 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 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 FIELDTECH
	Fieldtech null.Val[string] `db:"fieldtech" `
	// Original attribute from ArcGIS API is CreationDate
	Creationdate null.Val[time.Time] `db:"creationdate" `
	// Original attribute from ArcGIS API is Creator
	Creator null.Val[string] `db:"creator" `
	// Original attribute from ArcGIS API is EditDate
	Editdate null.Val[time.Time] `db:"editdate" `
	// Original attribute from ArcGIS API is Editor
	Editor         null.Val[string]            `db:"editor" `
	Geometry       types.JSON[json.RawMessage] `db:"geometry" `
	Geospatial     null.Val[string]            `db:"geospatial" `
	Version        int32                       `db:"version,pk" `
	OrganizationID int32                       `db:"organization_id" `

	R fieldseekerQamosquitoinspectionR `db:"-" `
}

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

// FieldseekerQamosquitoinspections contains methods to work with the qamosquitoinspection table
var FieldseekerQamosquitoinspections = psql.NewTablex[*FieldseekerQamosquitoinspection, FieldseekerQamosquitoinspectionSlice, *FieldseekerQamosquitoinspectionSetter]("fieldseeker", "qamosquitoinspection", buildFieldseekerQamosquitoinspectionColumns("fieldseeker.qamosquitoinspection"))

// FieldseekerQamosquitoinspectionsQuery is a query on the qamosquitoinspection table
type FieldseekerQamosquitoinspectionsQuery = *psql.ViewQuery[*FieldseekerQamosquitoinspection, FieldseekerQamosquitoinspectionSlice]

// fieldseekerQamosquitoinspectionR is where relationships are stored.
type fieldseekerQamosquitoinspectionR struct {
	Organization *Organization // fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey
}

func buildFieldseekerQamosquitoinspectionColumns(alias string) fieldseekerQamosquitoinspectionColumns {
	return fieldseekerQamosquitoinspectionColumns{
		ColumnsExpr: expr.NewColumnsExpr(
			"objectid", "posdips", "actiontaken", "comments", "avetemp", "windspeed", "raingauge", "globalid", "startdatetime", "enddatetime", "winddir", "reviewed", "reviewedby", "revieweddate", "locationname", "zone", "recordstatus", "zone2", "lr", "negdips", "totalacres", "acresbreeding", "fish", "sitetype", "breedingpotential", "movingwater", "nowaterever", "mosquitohabitat", "habvalue1", "habvalue1percent", "habvalue2", "habvalue2percent", "potential", "larvaepresent", "larvaeinsidetreatedarea", "larvaeoutsidetreatedarea", "larvaereason", "aquaticorganisms", "vegetation", "sourcereduction", "waterpresent", "watermovement1", "watermovement1percent", "watermovement2", "watermovement2percent", "soilconditions", "waterduration", "watersource", "waterconditions", "adultactivity", "linelocid", "pointlocid", "polygonlocid", "created_user", "created_date", "last_edited_user", "last_edited_date", "fieldtech", "creationdate", "creator", "editdate", "editor", "geometry", "geospatial", "version", "organization_id",
		).WithParent("fieldseeker.qamosquitoinspection"),
		tableAlias:               alias,
		Objectid:                 psql.Quote(alias, "objectid"),
		Posdips:                  psql.Quote(alias, "posdips"),
		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"),
		Globalid:                 psql.Quote(alias, "globalid"),
		Startdatetime:            psql.Quote(alias, "startdatetime"),
		Enddatetime:              psql.Quote(alias, "enddatetime"),
		Winddir:                  psql.Quote(alias, "winddir"),
		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"),
		LR:                       psql.Quote(alias, "lr"),
		Negdips:                  psql.Quote(alias, "negdips"),
		Totalacres:               psql.Quote(alias, "totalacres"),
		Acresbreeding:            psql.Quote(alias, "acresbreeding"),
		Fish:                     psql.Quote(alias, "fish"),
		Sitetype:                 psql.Quote(alias, "sitetype"),
		Breedingpotential:        psql.Quote(alias, "breedingpotential"),
		Movingwater:              psql.Quote(alias, "movingwater"),
		Nowaterever:              psql.Quote(alias, "nowaterever"),
		Mosquitohabitat:          psql.Quote(alias, "mosquitohabitat"),
		Habvalue1:                psql.Quote(alias, "habvalue1"),
		Habvalue1percent:         psql.Quote(alias, "habvalue1percent"),
		Habvalue2:                psql.Quote(alias, "habvalue2"),
		Habvalue2percent:         psql.Quote(alias, "habvalue2percent"),
		Potential:                psql.Quote(alias, "potential"),
		Larvaepresent:            psql.Quote(alias, "larvaepresent"),
		Larvaeinsidetreatedarea:  psql.Quote(alias, "larvaeinsidetreatedarea"),
		Larvaeoutsidetreatedarea: psql.Quote(alias, "larvaeoutsidetreatedarea"),
		Larvaereason:             psql.Quote(alias, "larvaereason"),
		Aquaticorganisms:         psql.Quote(alias, "aquaticorganisms"),
		Vegetation:               psql.Quote(alias, "vegetation"),
		Sourcereduction:          psql.Quote(alias, "sourcereduction"),
		Waterpresent:             psql.Quote(alias, "waterpresent"),
		Watermovement1:           psql.Quote(alias, "watermovement1"),
		Watermovement1percent:    psql.Quote(alias, "watermovement1percent"),
		Watermovement2:           psql.Quote(alias, "watermovement2"),
		Watermovement2percent:    psql.Quote(alias, "watermovement2percent"),
		Soilconditions:           psql.Quote(alias, "soilconditions"),
		Waterduration:            psql.Quote(alias, "waterduration"),
		Watersource:              psql.Quote(alias, "watersource"),
		Waterconditions:          psql.Quote(alias, "waterconditions"),
		Adultactivity:            psql.Quote(alias, "adultactivity"),
		Linelocid:                psql.Quote(alias, "linelocid"),
		Pointlocid:               psql.Quote(alias, "pointlocid"),
		Polygonlocid:             psql.Quote(alias, "polygonlocid"),
		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"),
		Fieldtech:                psql.Quote(alias, "fieldtech"),
		Creationdate:             psql.Quote(alias, "creationdate"),
		Creator:                  psql.Quote(alias, "creator"),
		Editdate:                 psql.Quote(alias, "editdate"),
		Editor:                   psql.Quote(alias, "editor"),
		Geometry:                 psql.Quote(alias, "geometry"),
		Geospatial:               psql.Quote(alias, "geospatial"),
		Version:                  psql.Quote(alias, "version"),
		OrganizationID:           psql.Quote(alias, "organization_id"),
	}
}

type fieldseekerQamosquitoinspectionColumns struct {
	expr.ColumnsExpr
	tableAlias               string
	Objectid                 psql.Expression
	Posdips                  psql.Expression
	Actiontaken              psql.Expression
	Comments                 psql.Expression
	Avetemp                  psql.Expression
	Windspeed                psql.Expression
	Raingauge                psql.Expression
	Globalid                 psql.Expression
	Startdatetime            psql.Expression
	Enddatetime              psql.Expression
	Winddir                  psql.Expression
	Reviewed                 psql.Expression
	Reviewedby               psql.Expression
	Revieweddate             psql.Expression
	Locationname             psql.Expression
	Zone                     psql.Expression
	Recordstatus             psql.Expression
	Zone2                    psql.Expression
	LR                       psql.Expression
	Negdips                  psql.Expression
	Totalacres               psql.Expression
	Acresbreeding            psql.Expression
	Fish                     psql.Expression
	Sitetype                 psql.Expression
	Breedingpotential        psql.Expression
	Movingwater              psql.Expression
	Nowaterever              psql.Expression
	Mosquitohabitat          psql.Expression
	Habvalue1                psql.Expression
	Habvalue1percent         psql.Expression
	Habvalue2                psql.Expression
	Habvalue2percent         psql.Expression
	Potential                psql.Expression
	Larvaepresent            psql.Expression
	Larvaeinsidetreatedarea  psql.Expression
	Larvaeoutsidetreatedarea psql.Expression
	Larvaereason             psql.Expression
	Aquaticorganisms         psql.Expression
	Vegetation               psql.Expression
	Sourcereduction          psql.Expression
	Waterpresent             psql.Expression
	Watermovement1           psql.Expression
	Watermovement1percent    psql.Expression
	Watermovement2           psql.Expression
	Watermovement2percent    psql.Expression
	Soilconditions           psql.Expression
	Waterduration            psql.Expression
	Watersource              psql.Expression
	Waterconditions          psql.Expression
	Adultactivity            psql.Expression
	Linelocid                psql.Expression
	Pointlocid               psql.Expression
	Polygonlocid             psql.Expression
	CreatedUser              psql.Expression
	CreatedDate              psql.Expression
	LastEditedUser           psql.Expression
	LastEditedDate           psql.Expression
	Fieldtech                psql.Expression
	Creationdate             psql.Expression
	Creator                  psql.Expression
	Editdate                 psql.Expression
	Editor                   psql.Expression
	Geometry                 psql.Expression
	Geospatial               psql.Expression
	Version                  psql.Expression
	OrganizationID           psql.Expression
}

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

func (fieldseekerQamosquitoinspectionColumns) AliasedAs(alias string) fieldseekerQamosquitoinspectionColumns {
	return buildFieldseekerQamosquitoinspectionColumns(alias)
}

// FieldseekerQamosquitoinspectionSetter is used for insert/upsert/update operations
// All values are optional, and do not have to be set
// Generated columns are not included
type FieldseekerQamosquitoinspectionSetter struct {
	Objectid                 omit.Val[int64]                       `db:"objectid" `
	Posdips                  omitnull.Val[int16]                   `db:"posdips" `
	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" `
	Globalid                 omit.Val[uuid.UUID]                   `db:"globalid,pk" `
	Startdatetime            omitnull.Val[time.Time]               `db:"startdatetime" `
	Enddatetime              omitnull.Val[time.Time]               `db:"enddatetime" `
	Winddir                  omitnull.Val[string]                  `db:"winddir" `
	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" `
	LR                       omitnull.Val[int16]                   `db:"lr" `
	Negdips                  omitnull.Val[int16]                   `db:"negdips" `
	Totalacres               omitnull.Val[float64]                 `db:"totalacres" `
	Acresbreeding            omitnull.Val[float64]                 `db:"acresbreeding" `
	Fish                     omitnull.Val[int16]                   `db:"fish" `
	Sitetype                 omitnull.Val[string]                  `db:"sitetype" `
	Breedingpotential        omitnull.Val[string]                  `db:"breedingpotential" `
	Movingwater              omitnull.Val[int16]                   `db:"movingwater" `
	Nowaterever              omitnull.Val[int16]                   `db:"nowaterever" `
	Mosquitohabitat          omitnull.Val[string]                  `db:"mosquitohabitat" `
	Habvalue1                omitnull.Val[int16]                   `db:"habvalue1" `
	Habvalue1percent         omitnull.Val[int16]                   `db:"habvalue1percent" `
	Habvalue2                omitnull.Val[int16]                   `db:"habvalue2" `
	Habvalue2percent         omitnull.Val[int16]                   `db:"habvalue2percent" `
	Potential                omitnull.Val[int16]                   `db:"potential" `
	Larvaepresent            omitnull.Val[int16]                   `db:"larvaepresent" `
	Larvaeinsidetreatedarea  omitnull.Val[int16]                   `db:"larvaeinsidetreatedarea" `
	Larvaeoutsidetreatedarea omitnull.Val[int16]                   `db:"larvaeoutsidetreatedarea" `
	Larvaereason             omitnull.Val[string]                  `db:"larvaereason" `
	Aquaticorganisms         omitnull.Val[string]                  `db:"aquaticorganisms" `
	Vegetation               omitnull.Val[string]                  `db:"vegetation" `
	Sourcereduction          omitnull.Val[string]                  `db:"sourcereduction" `
	Waterpresent             omitnull.Val[int16]                   `db:"waterpresent" `
	Watermovement1           omitnull.Val[string]                  `db:"watermovement1" `
	Watermovement1percent    omitnull.Val[int16]                   `db:"watermovement1percent" `
	Watermovement2           omitnull.Val[string]                  `db:"watermovement2" `
	Watermovement2percent    omitnull.Val[int16]                   `db:"watermovement2percent" `
	Soilconditions           omitnull.Val[string]                  `db:"soilconditions" `
	Waterduration            omitnull.Val[string]                  `db:"waterduration" `
	Watersource              omitnull.Val[string]                  `db:"watersource" `
	Waterconditions          omitnull.Val[string]                  `db:"waterconditions" `
	Adultactivity            omitnull.Val[int16]                   `db:"adultactivity" `
	Linelocid                omitnull.Val[uuid.UUID]               `db:"linelocid" `
	Pointlocid               omitnull.Val[uuid.UUID]               `db:"pointlocid" `
	Polygonlocid             omitnull.Val[uuid.UUID]               `db:"polygonlocid" `
	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" `
	Fieldtech                omitnull.Val[string]                  `db:"fieldtech" `
	Creationdate             omitnull.Val[time.Time]               `db:"creationdate" `
	Creator                  omitnull.Val[string]                  `db:"creator" `
	Editdate                 omitnull.Val[time.Time]               `db:"editdate" `
	Editor                   omitnull.Val[string]                  `db:"editor" `
	Geometry                 omit.Val[types.JSON[json.RawMessage]] `db:"geometry" `
	Geospatial               omitnull.Val[string]                  `db:"geospatial" `
	Version                  omit.Val[int32]                       `db:"version,pk" `
	OrganizationID           omit.Val[int32]                       `db:"organization_id" `
}

func (s FieldseekerQamosquitoinspectionSetter) SetColumns() []string {
	vals := make([]string, 0, 66)
	if s.Objectid.IsValue() {
		vals = append(vals, "objectid")
	}
	if !s.Posdips.IsUnset() {
		vals = append(vals, "posdips")
	}
	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.Globalid.IsValue() {
		vals = append(vals, "globalid")
	}
	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.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.LR.IsUnset() {
		vals = append(vals, "lr")
	}
	if !s.Negdips.IsUnset() {
		vals = append(vals, "negdips")
	}
	if !s.Totalacres.IsUnset() {
		vals = append(vals, "totalacres")
	}
	if !s.Acresbreeding.IsUnset() {
		vals = append(vals, "acresbreeding")
	}
	if !s.Fish.IsUnset() {
		vals = append(vals, "fish")
	}
	if !s.Sitetype.IsUnset() {
		vals = append(vals, "sitetype")
	}
	if !s.Breedingpotential.IsUnset() {
		vals = append(vals, "breedingpotential")
	}
	if !s.Movingwater.IsUnset() {
		vals = append(vals, "movingwater")
	}
	if !s.Nowaterever.IsUnset() {
		vals = append(vals, "nowaterever")
	}
	if !s.Mosquitohabitat.IsUnset() {
		vals = append(vals, "mosquitohabitat")
	}
	if !s.Habvalue1.IsUnset() {
		vals = append(vals, "habvalue1")
	}
	if !s.Habvalue1percent.IsUnset() {
		vals = append(vals, "habvalue1percent")
	}
	if !s.Habvalue2.IsUnset() {
		vals = append(vals, "habvalue2")
	}
	if !s.Habvalue2percent.IsUnset() {
		vals = append(vals, "habvalue2percent")
	}
	if !s.Potential.IsUnset() {
		vals = append(vals, "potential")
	}
	if !s.Larvaepresent.IsUnset() {
		vals = append(vals, "larvaepresent")
	}
	if !s.Larvaeinsidetreatedarea.IsUnset() {
		vals = append(vals, "larvaeinsidetreatedarea")
	}
	if !s.Larvaeoutsidetreatedarea.IsUnset() {
		vals = append(vals, "larvaeoutsidetreatedarea")
	}
	if !s.Larvaereason.IsUnset() {
		vals = append(vals, "larvaereason")
	}
	if !s.Aquaticorganisms.IsUnset() {
		vals = append(vals, "aquaticorganisms")
	}
	if !s.Vegetation.IsUnset() {
		vals = append(vals, "vegetation")
	}
	if !s.Sourcereduction.IsUnset() {
		vals = append(vals, "sourcereduction")
	}
	if !s.Waterpresent.IsUnset() {
		vals = append(vals, "waterpresent")
	}
	if !s.Watermovement1.IsUnset() {
		vals = append(vals, "watermovement1")
	}
	if !s.Watermovement1percent.IsUnset() {
		vals = append(vals, "watermovement1percent")
	}
	if !s.Watermovement2.IsUnset() {
		vals = append(vals, "watermovement2")
	}
	if !s.Watermovement2percent.IsUnset() {
		vals = append(vals, "watermovement2percent")
	}
	if !s.Soilconditions.IsUnset() {
		vals = append(vals, "soilconditions")
	}
	if !s.Waterduration.IsUnset() {
		vals = append(vals, "waterduration")
	}
	if !s.Watersource.IsUnset() {
		vals = append(vals, "watersource")
	}
	if !s.Waterconditions.IsUnset() {
		vals = append(vals, "waterconditions")
	}
	if !s.Adultactivity.IsUnset() {
		vals = append(vals, "adultactivity")
	}
	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.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.Fieldtech.IsUnset() {
		vals = append(vals, "fieldtech")
	}
	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.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 FieldseekerQamosquitoinspectionSetter) Overwrite(t *FieldseekerQamosquitoinspection) {
	if s.Objectid.IsValue() {
		t.Objectid = s.Objectid.MustGet()
	}
	if !s.Posdips.IsUnset() {
		t.Posdips = s.Posdips.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.Globalid.IsValue() {
		t.Globalid = s.Globalid.MustGet()
	}
	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.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.LR.IsUnset() {
		t.LR = s.LR.MustGetNull()
	}
	if !s.Negdips.IsUnset() {
		t.Negdips = s.Negdips.MustGetNull()
	}
	if !s.Totalacres.IsUnset() {
		t.Totalacres = s.Totalacres.MustGetNull()
	}
	if !s.Acresbreeding.IsUnset() {
		t.Acresbreeding = s.Acresbreeding.MustGetNull()
	}
	if !s.Fish.IsUnset() {
		t.Fish = s.Fish.MustGetNull()
	}
	if !s.Sitetype.IsUnset() {
		t.Sitetype = s.Sitetype.MustGetNull()
	}
	if !s.Breedingpotential.IsUnset() {
		t.Breedingpotential = s.Breedingpotential.MustGetNull()
	}
	if !s.Movingwater.IsUnset() {
		t.Movingwater = s.Movingwater.MustGetNull()
	}
	if !s.Nowaterever.IsUnset() {
		t.Nowaterever = s.Nowaterever.MustGetNull()
	}
	if !s.Mosquitohabitat.IsUnset() {
		t.Mosquitohabitat = s.Mosquitohabitat.MustGetNull()
	}
	if !s.Habvalue1.IsUnset() {
		t.Habvalue1 = s.Habvalue1.MustGetNull()
	}
	if !s.Habvalue1percent.IsUnset() {
		t.Habvalue1percent = s.Habvalue1percent.MustGetNull()
	}
	if !s.Habvalue2.IsUnset() {
		t.Habvalue2 = s.Habvalue2.MustGetNull()
	}
	if !s.Habvalue2percent.IsUnset() {
		t.Habvalue2percent = s.Habvalue2percent.MustGetNull()
	}
	if !s.Potential.IsUnset() {
		t.Potential = s.Potential.MustGetNull()
	}
	if !s.Larvaepresent.IsUnset() {
		t.Larvaepresent = s.Larvaepresent.MustGetNull()
	}
	if !s.Larvaeinsidetreatedarea.IsUnset() {
		t.Larvaeinsidetreatedarea = s.Larvaeinsidetreatedarea.MustGetNull()
	}
	if !s.Larvaeoutsidetreatedarea.IsUnset() {
		t.Larvaeoutsidetreatedarea = s.Larvaeoutsidetreatedarea.MustGetNull()
	}
	if !s.Larvaereason.IsUnset() {
		t.Larvaereason = s.Larvaereason.MustGetNull()
	}
	if !s.Aquaticorganisms.IsUnset() {
		t.Aquaticorganisms = s.Aquaticorganisms.MustGetNull()
	}
	if !s.Vegetation.IsUnset() {
		t.Vegetation = s.Vegetation.MustGetNull()
	}
	if !s.Sourcereduction.IsUnset() {
		t.Sourcereduction = s.Sourcereduction.MustGetNull()
	}
	if !s.Waterpresent.IsUnset() {
		t.Waterpresent = s.Waterpresent.MustGetNull()
	}
	if !s.Watermovement1.IsUnset() {
		t.Watermovement1 = s.Watermovement1.MustGetNull()
	}
	if !s.Watermovement1percent.IsUnset() {
		t.Watermovement1percent = s.Watermovement1percent.MustGetNull()
	}
	if !s.Watermovement2.IsUnset() {
		t.Watermovement2 = s.Watermovement2.MustGetNull()
	}
	if !s.Watermovement2percent.IsUnset() {
		t.Watermovement2percent = s.Watermovement2percent.MustGetNull()
	}
	if !s.Soilconditions.IsUnset() {
		t.Soilconditions = s.Soilconditions.MustGetNull()
	}
	if !s.Waterduration.IsUnset() {
		t.Waterduration = s.Waterduration.MustGetNull()
	}
	if !s.Watersource.IsUnset() {
		t.Watersource = s.Watersource.MustGetNull()
	}
	if !s.Waterconditions.IsUnset() {
		t.Waterconditions = s.Waterconditions.MustGetNull()
	}
	if !s.Adultactivity.IsUnset() {
		t.Adultactivity = s.Adultactivity.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.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.Fieldtech.IsUnset() {
		t.Fieldtech = s.Fieldtech.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.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 *FieldseekerQamosquitoinspectionSetter) Apply(q *dialect.InsertQuery) {
	q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
		return FieldseekerQamosquitoinspections.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, 66)
		if s.Objectid.IsValue() {
			vals[0] = psql.Arg(s.Objectid.MustGet())
		} else {
			vals[0] = psql.Raw("DEFAULT")
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	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.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
}

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

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

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

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

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

	return err
}

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

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

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

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

	return err
}

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

	return psql.Group(psql.Quote("fieldseeker.qamosquitoinspection", "globalid"), psql.Quote("fieldseeker.qamosquitoinspection", "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 FieldseekerQamosquitoinspectionSlice) copyMatchingRows(from ...*FieldseekerQamosquitoinspection) {
	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 FieldseekerQamosquitoinspectionSlice) 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 FieldseekerQamosquitoinspections.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 *FieldseekerQamosquitoinspection:
				o.copyMatchingRows(retrieved)
			case []*FieldseekerQamosquitoinspection:
				o.copyMatchingRows(retrieved...)
			case FieldseekerQamosquitoinspectionSlice:
				o.copyMatchingRows(retrieved...)
			default:
				// If the retrieved value is not a FieldseekerQamosquitoinspection or a slice of FieldseekerQamosquitoinspection
				// then run the AfterUpdateHooks on the slice
				_, err = FieldseekerQamosquitoinspections.AfterUpdateHooks.RunHooks(ctx, exec, o)
			}

			return err
		}))

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

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

			return err
		}))

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

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

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

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

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

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

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

func (os FieldseekerQamosquitoinspectionSlice) 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 attachFieldseekerQamosquitoinspectionOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerQamosquitoinspection0 *FieldseekerQamosquitoinspection, organization1 *Organization) (*FieldseekerQamosquitoinspection, error) {
	setter := &FieldseekerQamosquitoinspectionSetter{
		OrganizationID: omit.From(organization1.ID),
	}

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

	return fieldseekerQamosquitoinspection0, nil
}

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

	fieldseekerQamosquitoinspection0.R.Organization = organization1

	organization1.R.Qamosquitoinspections = append(organization1.R.Qamosquitoinspections, fieldseekerQamosquitoinspection0)

	return nil
}

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

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

	fieldseekerQamosquitoinspection0.R.Organization = organization1

	organization1.R.Qamosquitoinspections = append(organization1.R.Qamosquitoinspections, fieldseekerQamosquitoinspection0)

	return nil
}

type fieldseekerQamosquitoinspectionWhere[Q psql.Filterable] struct {
	Objectid                 psql.WhereMod[Q, int64]
	Posdips                  psql.WhereNullMod[Q, int16]
	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]
	Globalid                 psql.WhereMod[Q, uuid.UUID]
	Startdatetime            psql.WhereNullMod[Q, time.Time]
	Enddatetime              psql.WhereNullMod[Q, time.Time]
	Winddir                  psql.WhereNullMod[Q, string]
	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]
	LR                       psql.WhereNullMod[Q, int16]
	Negdips                  psql.WhereNullMod[Q, int16]
	Totalacres               psql.WhereNullMod[Q, float64]
	Acresbreeding            psql.WhereNullMod[Q, float64]
	Fish                     psql.WhereNullMod[Q, int16]
	Sitetype                 psql.WhereNullMod[Q, string]
	Breedingpotential        psql.WhereNullMod[Q, string]
	Movingwater              psql.WhereNullMod[Q, int16]
	Nowaterever              psql.WhereNullMod[Q, int16]
	Mosquitohabitat          psql.WhereNullMod[Q, string]
	Habvalue1                psql.WhereNullMod[Q, int16]
	Habvalue1percent         psql.WhereNullMod[Q, int16]
	Habvalue2                psql.WhereNullMod[Q, int16]
	Habvalue2percent         psql.WhereNullMod[Q, int16]
	Potential                psql.WhereNullMod[Q, int16]
	Larvaepresent            psql.WhereNullMod[Q, int16]
	Larvaeinsidetreatedarea  psql.WhereNullMod[Q, int16]
	Larvaeoutsidetreatedarea psql.WhereNullMod[Q, int16]
	Larvaereason             psql.WhereNullMod[Q, string]
	Aquaticorganisms         psql.WhereNullMod[Q, string]
	Vegetation               psql.WhereNullMod[Q, string]
	Sourcereduction          psql.WhereNullMod[Q, string]
	Waterpresent             psql.WhereNullMod[Q, int16]
	Watermovement1           psql.WhereNullMod[Q, string]
	Watermovement1percent    psql.WhereNullMod[Q, int16]
	Watermovement2           psql.WhereNullMod[Q, string]
	Watermovement2percent    psql.WhereNullMod[Q, int16]
	Soilconditions           psql.WhereNullMod[Q, string]
	Waterduration            psql.WhereNullMod[Q, string]
	Watersource              psql.WhereNullMod[Q, string]
	Waterconditions          psql.WhereNullMod[Q, string]
	Adultactivity            psql.WhereNullMod[Q, int16]
	Linelocid                psql.WhereNullMod[Q, uuid.UUID]
	Pointlocid               psql.WhereNullMod[Q, uuid.UUID]
	Polygonlocid             psql.WhereNullMod[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]
	Fieldtech                psql.WhereNullMod[Q, string]
	Creationdate             psql.WhereNullMod[Q, time.Time]
	Creator                  psql.WhereNullMod[Q, string]
	Editdate                 psql.WhereNullMod[Q, time.Time]
	Editor                   psql.WhereNullMod[Q, string]
	Geometry                 psql.WhereMod[Q, types.JSON[json.RawMessage]]
	Geospatial               psql.WhereNullMod[Q, string]
	Version                  psql.WhereMod[Q, int32]
	OrganizationID           psql.WhereMod[Q, int32]
}

func (fieldseekerQamosquitoinspectionWhere[Q]) AliasedAs(alias string) fieldseekerQamosquitoinspectionWhere[Q] {
	return buildFieldseekerQamosquitoinspectionWhere[Q](buildFieldseekerQamosquitoinspectionColumns(alias))
}

func buildFieldseekerQamosquitoinspectionWhere[Q psql.Filterable](cols fieldseekerQamosquitoinspectionColumns) fieldseekerQamosquitoinspectionWhere[Q] {
	return fieldseekerQamosquitoinspectionWhere[Q]{
		Objectid:                 psql.Where[Q, int64](cols.Objectid),
		Posdips:                  psql.WhereNull[Q, int16](cols.Posdips),
		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),
		Globalid:                 psql.Where[Q, uuid.UUID](cols.Globalid),
		Startdatetime:            psql.WhereNull[Q, time.Time](cols.Startdatetime),
		Enddatetime:              psql.WhereNull[Q, time.Time](cols.Enddatetime),
		Winddir:                  psql.WhereNull[Q, string](cols.Winddir),
		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),
		LR:                       psql.WhereNull[Q, int16](cols.LR),
		Negdips:                  psql.WhereNull[Q, int16](cols.Negdips),
		Totalacres:               psql.WhereNull[Q, float64](cols.Totalacres),
		Acresbreeding:            psql.WhereNull[Q, float64](cols.Acresbreeding),
		Fish:                     psql.WhereNull[Q, int16](cols.Fish),
		Sitetype:                 psql.WhereNull[Q, string](cols.Sitetype),
		Breedingpotential:        psql.WhereNull[Q, string](cols.Breedingpotential),
		Movingwater:              psql.WhereNull[Q, int16](cols.Movingwater),
		Nowaterever:              psql.WhereNull[Q, int16](cols.Nowaterever),
		Mosquitohabitat:          psql.WhereNull[Q, string](cols.Mosquitohabitat),
		Habvalue1:                psql.WhereNull[Q, int16](cols.Habvalue1),
		Habvalue1percent:         psql.WhereNull[Q, int16](cols.Habvalue1percent),
		Habvalue2:                psql.WhereNull[Q, int16](cols.Habvalue2),
		Habvalue2percent:         psql.WhereNull[Q, int16](cols.Habvalue2percent),
		Potential:                psql.WhereNull[Q, int16](cols.Potential),
		Larvaepresent:            psql.WhereNull[Q, int16](cols.Larvaepresent),
		Larvaeinsidetreatedarea:  psql.WhereNull[Q, int16](cols.Larvaeinsidetreatedarea),
		Larvaeoutsidetreatedarea: psql.WhereNull[Q, int16](cols.Larvaeoutsidetreatedarea),
		Larvaereason:             psql.WhereNull[Q, string](cols.Larvaereason),
		Aquaticorganisms:         psql.WhereNull[Q, string](cols.Aquaticorganisms),
		Vegetation:               psql.WhereNull[Q, string](cols.Vegetation),
		Sourcereduction:          psql.WhereNull[Q, string](cols.Sourcereduction),
		Waterpresent:             psql.WhereNull[Q, int16](cols.Waterpresent),
		Watermovement1:           psql.WhereNull[Q, string](cols.Watermovement1),
		Watermovement1percent:    psql.WhereNull[Q, int16](cols.Watermovement1percent),
		Watermovement2:           psql.WhereNull[Q, string](cols.Watermovement2),
		Watermovement2percent:    psql.WhereNull[Q, int16](cols.Watermovement2percent),
		Soilconditions:           psql.WhereNull[Q, string](cols.Soilconditions),
		Waterduration:            psql.WhereNull[Q, string](cols.Waterduration),
		Watersource:              psql.WhereNull[Q, string](cols.Watersource),
		Waterconditions:          psql.WhereNull[Q, string](cols.Waterconditions),
		Adultactivity:            psql.WhereNull[Q, int16](cols.Adultactivity),
		Linelocid:                psql.WhereNull[Q, uuid.UUID](cols.Linelocid),
		Pointlocid:               psql.WhereNull[Q, uuid.UUID](cols.Pointlocid),
		Polygonlocid:             psql.WhereNull[Q, uuid.UUID](cols.Polygonlocid),
		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),
		Fieldtech:                psql.WhereNull[Q, string](cols.Fieldtech),
		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),
		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 *FieldseekerQamosquitoinspection) Preload(name string, retrieved any) error {
	if o == nil {
		return nil
	}

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

		o.R.Organization = rel

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

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

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

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

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

	return fieldseekerQamosquitoinspectionThenLoader[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 fieldseekerQamosquitoinspection's Organization into the .R struct
func (o *FieldseekerQamosquitoinspection) 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.Qamosquitoinspections = FieldseekerQamosquitoinspectionSlice{o}

	o.R.Organization = related
	return nil
}

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

			o.R.Organization = rel
			break
		}
	}

	return nil
}
