Remove old FieldSeeker tables, use v2 generated tables.

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

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

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

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

View file

@ -1,18 +1,19 @@
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
// Code generated by BobGen psql v0.0.4-0.20251216163753-8e325b7c773a+dirty. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
import (
"context"
"encoding/json"
"fmt"
"io"
"time"
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/aarondl/opt/null"
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"github.com/stephenafamo/bob"
"github.com/stephenafamo/bob/dialect/psql"
"github.com/stephenafamo/bob/dialect/psql/dialect"
@ -20,89 +21,107 @@ import (
"github.com/stephenafamo/bob/dialect/psql/sm"
"github.com/stephenafamo/bob/dialect/psql/um"
"github.com/stephenafamo/bob/expr"
"github.com/stephenafamo/bob/mods"
"github.com/stephenafamo/bob/orm"
"github.com/stephenafamo/bob/types"
"github.com/stephenafamo/bob/types/pgtypes"
)
// FieldseekerPointlocation is an object representing the database table.
type FieldseekerPointlocation struct {
Objectid int64 `db:"objectid,pk" `
// Name
// Original attribute from ArcGIS API is NAME
Name null.Val[string] `db:"name" `
// Zone
// Original attribute from ArcGIS API is ZONE
Zone null.Val[string] `db:"zone" `
// Habitat
Habitat null.Val[enums.FieldseekerPointlocationPointlocationHabitatB4d8135a497949C88BB367e] `db:"habitat" `
// Priority
Priority null.Val[enums.FieldseekerPointlocationLocationpriorityEnum] `db:"priority" `
// Use Type
Usetype null.Val[enums.FieldseekerPointlocationPointlocationUsetype58d62d18ef4f47fc8cb9874df86] `db:"usetype" `
// Active
Active null.Val[enums.FieldseekerPointlocationNotinuitFEnum] `db:"active" `
// Description
// Original attribute from ArcGIS API is HABITAT
Habitat null.Val[string] `db:"habitat" `
// Original attribute from ArcGIS API is PRIORITY
Priority null.Val[string] `db:"priority" `
// Original attribute from ArcGIS API is USETYPE
Usetype null.Val[string] `db:"usetype" `
// Original attribute from ArcGIS API is ACTIVE
Active null.Val[int16] `db:"active" `
// Original attribute from ArcGIS API is DESCRIPTION
Description null.Val[string] `db:"description" `
// Access Description
// Original attribute from ArcGIS API is ACCESSDESC
Accessdesc null.Val[string] `db:"accessdesc" `
// Comments
// Original attribute from ArcGIS API is COMMENTS
Comments null.Val[string] `db:"comments" `
// Symbology
Symbology null.Val[enums.FieldseekerPointlocationLocationsymbologyEnum] `db:"symbology" `
// External ID
// Original attribute from ArcGIS API is SYMBOLOGY
Symbology null.Val[string] `db:"symbology" `
// Original attribute from ArcGIS API is EXTERNALID
Externalid null.Val[string] `db:"externalid" `
// Next Scheduled Action
// Original attribute from ArcGIS API is NEXTACTIONDATESCHEDULED
Nextactiondatescheduled null.Val[time.Time] `db:"nextactiondatescheduled" `
// Larval Inspection Interval
// Original attribute from ArcGIS API is LARVINSPECTINTERVAL
Larvinspectinterval null.Val[int16] `db:"larvinspectinterval" `
// Zone2
Zone2 null.Val[string] `db:"zone2" `
Locationnumber null.Val[int32] `db:"locationnumber" `
Globalid null.Val[uuid.UUID] `db:"globalid" `
// SourceType
// Original attribute from ArcGIS API is ZONE2
Zone2 null.Val[string] `db:"zone2" `
// Original attribute from ArcGIS API is LOCATIONNUMBER
Locationnumber null.Val[int32] `db:"locationnumber" `
// Original attribute from ArcGIS API is GlobalID
Globalid null.Val[uuid.UUID] `db:"globalid" `
// Original attribute from ArcGIS API is STYPE
Stype null.Val[string] `db:"stype" `
// Last Inspection Date
// Original attribute from ArcGIS API is LASTINSPECTDATE
Lastinspectdate null.Val[time.Time] `db:"lastinspectdate" `
// Last Inspection Breeding
// Original attribute from ArcGIS API is LASTINSPECTBREEDING
Lastinspectbreeding null.Val[string] `db:"lastinspectbreeding" `
// Last Inspection Average Larvae
// Original attribute from ArcGIS API is LASTINSPECTAVGLARVAE
Lastinspectavglarvae null.Val[float64] `db:"lastinspectavglarvae" `
// Last Inspection Average Pupae
// Original attribute from ArcGIS API is LASTINSPECTAVGPUPAE
Lastinspectavgpupae null.Val[float64] `db:"lastinspectavgpupae" `
// Last Inspection Larval Stages
// Original attribute from ArcGIS API is LASTINSPECTLSTAGES
Lastinspectlstages null.Val[string] `db:"lastinspectlstages" `
// Last Inspection Action
// Original attribute from ArcGIS API is LASTINSPECTACTIONTAKEN
Lastinspectactiontaken null.Val[string] `db:"lastinspectactiontaken" `
// Last Inspection Field Species
// Original attribute from ArcGIS API is LASTINSPECTFIELDSPECIES
Lastinspectfieldspecies null.Val[string] `db:"lastinspectfieldspecies" `
// Last Treatment Date
// Original attribute from ArcGIS API is LASTTREATDATE
Lasttreatdate null.Val[time.Time] `db:"lasttreatdate" `
// Last Treatment Product
// Original attribute from ArcGIS API is LASTTREATPRODUCT
Lasttreatproduct null.Val[string] `db:"lasttreatproduct" `
// Last Treatment Quantity
// Original attribute from ArcGIS API is LASTTREATQTY
Lasttreatqty null.Val[float64] `db:"lasttreatqty" `
// Last Treatment Quantity Unit
// Original attribute from ArcGIS API is LASTTREATQTYUNIT
Lasttreatqtyunit null.Val[string] `db:"lasttreatqtyunit" `
// Last Inspection Activity
// Original attribute from ArcGIS API is LASTINSPECTACTIVITY
Lastinspectactivity null.Val[string] `db:"lastinspectactivity" `
// Last Treatment Activity
// Original attribute from ArcGIS API is LASTTREATACTIVITY
Lasttreatactivity null.Val[string] `db:"lasttreatactivity" `
// Last Inspection Conditions
// Original attribute from ArcGIS API is LASTINSPECTCONDITIONS
Lastinspectconditions null.Val[string] `db:"lastinspectconditions" `
// Water Origin
Waterorigin null.Val[enums.FieldseekerPointlocationPointlocationWaterorigin197B22BFF3eb4dad8899] `db:"waterorigin" `
X null.Val[float64] `db:"x" `
Y null.Val[float64] `db:"y" `
// Assigned Tech
Assignedtech null.Val[enums.FieldseekerPointlocationPointlocationAssignedtech9393a1622474429D85B] `db:"assignedtech" `
Creationdate null.Val[time.Time] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Editdate null.Val[time.Time] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
// Jurisdiction
// Original attribute from ArcGIS API is WATERORIGIN
Waterorigin null.Val[string] `db:"waterorigin" `
// Original attribute from ArcGIS API is X
X null.Val[float64] `db:"x" `
// Original attribute from ArcGIS API is Y
Y null.Val[float64] `db:"y" `
// Original attribute from ArcGIS API is ASSIGNEDTECH
Assignedtech null.Val[string] `db:"assignedtech" `
// 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" `
// Reason for Deactivation
DeactivateReason null.Val[enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489] `db:"deactivate_reason" `
Scalarpriority null.Val[int32] `db:"scalarpriority" `
Sourcestatus null.Val[string] `db:"sourcestatus" `
// Tracks version changes to the row. Increases when data is modified.
Version int32 `db:"version,pk" `
// Original attribute from ArcGIS API is deactivate_reason
DeactivateReason null.Val[string] `db:"deactivate_reason" `
// Original attribute from ArcGIS API is scalarPriority
Scalarpriority null.Val[int32] `db:"scalarpriority" `
// Original attribute from ArcGIS API is sourceStatus
Sourcestatus null.Val[string] `db:"sourcestatus" `
Geometry types.JSON[json.RawMessage] `db:"geometry" `
Geospatial null.Val[string] `db:"geospatial" `
Version int32 `db:"version,pk" `
OrganizationID int32 `db:"organization_id" `
R fieldseekerPointlocationR `db:"-" `
}
// FieldseekerPointlocationSlice is an alias for a slice of pointers to FieldseekerPointlocation.
@ -115,10 +134,15 @@ var FieldseekerPointlocations = psql.NewTablex[*FieldseekerPointlocation, Fields
// FieldseekerPointlocationsQuery is a query on the pointlocation table
type FieldseekerPointlocationsQuery = *psql.ViewQuery[*FieldseekerPointlocation, FieldseekerPointlocationSlice]
// fieldseekerPointlocationR is where relationships are stored.
type fieldseekerPointlocationR struct {
Organization *Organization // fieldseeker.pointlocation.pointlocation_organization_id_fkey
}
func buildFieldseekerPointlocationColumns(alias string) fieldseekerPointlocationColumns {
return fieldseekerPointlocationColumns{
ColumnsExpr: expr.NewColumnsExpr(
"objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "stype", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "x", "y", "assignedtech", "creationdate", "creator", "editdate", "editor", "jurisdiction", "deactivate_reason", "scalarpriority", "sourcestatus", "version",
"objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "stype", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "x", "y", "assignedtech", "creationdate", "creator", "editdate", "editor", "jurisdiction", "deactivate_reason", "scalarpriority", "sourcestatus", "geometry", "geospatial", "version", "organization_id",
).WithParent("fieldseeker.pointlocation"),
tableAlias: alias,
Objectid: psql.Quote(alias, "objectid"),
@ -165,7 +189,10 @@ func buildFieldseekerPointlocationColumns(alias string) fieldseekerPointlocation
DeactivateReason: psql.Quote(alias, "deactivate_reason"),
Scalarpriority: psql.Quote(alias, "scalarpriority"),
Sourcestatus: psql.Quote(alias, "sourcestatus"),
Geometry: psql.Quote(alias, "geometry"),
Geospatial: psql.Quote(alias, "geospatial"),
Version: psql.Quote(alias, "version"),
OrganizationID: psql.Quote(alias, "organization_id"),
}
}
@ -216,7 +243,10 @@ type fieldseekerPointlocationColumns struct {
DeactivateReason psql.Expression
Scalarpriority psql.Expression
Sourcestatus psql.Expression
Geometry psql.Expression
Geospatial psql.Expression
Version psql.Expression
OrganizationID psql.Expression
}
func (c fieldseekerPointlocationColumns) Alias() string {
@ -231,55 +261,58 @@ func (fieldseekerPointlocationColumns) AliasedAs(alias string) fieldseekerPointl
// All values are optional, and do not have to be set
// Generated columns are not included
type FieldseekerPointlocationSetter struct {
Objectid omit.Val[int64] `db:"objectid,pk" `
Name omitnull.Val[string] `db:"name" `
Zone omitnull.Val[string] `db:"zone" `
Habitat omitnull.Val[enums.FieldseekerPointlocationPointlocationHabitatB4d8135a497949C88BB367e] `db:"habitat" `
Priority omitnull.Val[enums.FieldseekerPointlocationLocationpriorityEnum] `db:"priority" `
Usetype omitnull.Val[enums.FieldseekerPointlocationPointlocationUsetype58d62d18ef4f47fc8cb9874df86] `db:"usetype" `
Active omitnull.Val[enums.FieldseekerPointlocationNotinuitFEnum] `db:"active" `
Description omitnull.Val[string] `db:"description" `
Accessdesc omitnull.Val[string] `db:"accessdesc" `
Comments omitnull.Val[string] `db:"comments" `
Symbology omitnull.Val[enums.FieldseekerPointlocationLocationsymbologyEnum] `db:"symbology" `
Externalid omitnull.Val[string] `db:"externalid" `
Nextactiondatescheduled omitnull.Val[time.Time] `db:"nextactiondatescheduled" `
Larvinspectinterval omitnull.Val[int16] `db:"larvinspectinterval" `
Zone2 omitnull.Val[string] `db:"zone2" `
Locationnumber omitnull.Val[int32] `db:"locationnumber" `
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
Stype omitnull.Val[string] `db:"stype" `
Lastinspectdate omitnull.Val[time.Time] `db:"lastinspectdate" `
Lastinspectbreeding omitnull.Val[string] `db:"lastinspectbreeding" `
Lastinspectavglarvae omitnull.Val[float64] `db:"lastinspectavglarvae" `
Lastinspectavgpupae omitnull.Val[float64] `db:"lastinspectavgpupae" `
Lastinspectlstages omitnull.Val[string] `db:"lastinspectlstages" `
Lastinspectactiontaken omitnull.Val[string] `db:"lastinspectactiontaken" `
Lastinspectfieldspecies omitnull.Val[string] `db:"lastinspectfieldspecies" `
Lasttreatdate omitnull.Val[time.Time] `db:"lasttreatdate" `
Lasttreatproduct omitnull.Val[string] `db:"lasttreatproduct" `
Lasttreatqty omitnull.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit omitnull.Val[string] `db:"lasttreatqtyunit" `
Lastinspectactivity omitnull.Val[string] `db:"lastinspectactivity" `
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
Lastinspectconditions omitnull.Val[string] `db:"lastinspectconditions" `
Waterorigin omitnull.Val[enums.FieldseekerPointlocationPointlocationWaterorigin197B22BFF3eb4dad8899] `db:"waterorigin" `
X omitnull.Val[float64] `db:"x" `
Y omitnull.Val[float64] `db:"y" `
Assignedtech omitnull.Val[enums.FieldseekerPointlocationPointlocationAssignedtech9393a1622474429D85B] `db:"assignedtech" `
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" `
DeactivateReason omitnull.Val[enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489] `db:"deactivate_reason" `
Scalarpriority omitnull.Val[int32] `db:"scalarpriority" `
Sourcestatus omitnull.Val[string] `db:"sourcestatus" `
Version omit.Val[int32] `db:"version,pk" `
Objectid omit.Val[int64] `db:"objectid,pk" `
Name omitnull.Val[string] `db:"name" `
Zone omitnull.Val[string] `db:"zone" `
Habitat omitnull.Val[string] `db:"habitat" `
Priority omitnull.Val[string] `db:"priority" `
Usetype omitnull.Val[string] `db:"usetype" `
Active omitnull.Val[int16] `db:"active" `
Description omitnull.Val[string] `db:"description" `
Accessdesc omitnull.Val[string] `db:"accessdesc" `
Comments omitnull.Val[string] `db:"comments" `
Symbology omitnull.Val[string] `db:"symbology" `
Externalid omitnull.Val[string] `db:"externalid" `
Nextactiondatescheduled omitnull.Val[time.Time] `db:"nextactiondatescheduled" `
Larvinspectinterval omitnull.Val[int16] `db:"larvinspectinterval" `
Zone2 omitnull.Val[string] `db:"zone2" `
Locationnumber omitnull.Val[int32] `db:"locationnumber" `
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
Stype omitnull.Val[string] `db:"stype" `
Lastinspectdate omitnull.Val[time.Time] `db:"lastinspectdate" `
Lastinspectbreeding omitnull.Val[string] `db:"lastinspectbreeding" `
Lastinspectavglarvae omitnull.Val[float64] `db:"lastinspectavglarvae" `
Lastinspectavgpupae omitnull.Val[float64] `db:"lastinspectavgpupae" `
Lastinspectlstages omitnull.Val[string] `db:"lastinspectlstages" `
Lastinspectactiontaken omitnull.Val[string] `db:"lastinspectactiontaken" `
Lastinspectfieldspecies omitnull.Val[string] `db:"lastinspectfieldspecies" `
Lasttreatdate omitnull.Val[time.Time] `db:"lasttreatdate" `
Lasttreatproduct omitnull.Val[string] `db:"lasttreatproduct" `
Lasttreatqty omitnull.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit omitnull.Val[string] `db:"lasttreatqtyunit" `
Lastinspectactivity omitnull.Val[string] `db:"lastinspectactivity" `
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
Lastinspectconditions omitnull.Val[string] `db:"lastinspectconditions" `
Waterorigin omitnull.Val[string] `db:"waterorigin" `
X omitnull.Val[float64] `db:"x" `
Y omitnull.Val[float64] `db:"y" `
Assignedtech omitnull.Val[string] `db:"assignedtech" `
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" `
DeactivateReason omitnull.Val[string] `db:"deactivate_reason" `
Scalarpriority omitnull.Val[int32] `db:"scalarpriority" `
Sourcestatus omitnull.Val[string] `db:"sourcestatus" `
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 FieldseekerPointlocationSetter) SetColumns() []string {
vals := make([]string, 0, 45)
vals := make([]string, 0, 48)
if s.Objectid.IsValue() {
vals = append(vals, "objectid")
}
@ -412,9 +445,18 @@ func (s FieldseekerPointlocationSetter) SetColumns() []string {
if !s.Sourcestatus.IsUnset() {
vals = append(vals, "sourcestatus")
}
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
}
@ -551,9 +593,18 @@ func (s FieldseekerPointlocationSetter) Overwrite(t *FieldseekerPointlocation) {
if !s.Sourcestatus.IsUnset() {
t.Sourcestatus = s.Sourcestatus.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 *FieldseekerPointlocationSetter) Apply(q *dialect.InsertQuery) {
@ -562,7 +613,7 @@ func (s *FieldseekerPointlocationSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 45)
vals := make([]bob.Expression, 48)
if s.Objectid.IsValue() {
vals[0] = psql.Arg(s.Objectid.MustGet())
} else {
@ -827,12 +878,30 @@ func (s *FieldseekerPointlocationSetter) Apply(q *dialect.InsertQuery) {
vals[43] = psql.Raw("DEFAULT")
}
if s.Version.IsValue() {
vals[44] = psql.Arg(s.Version.MustGet())
if s.Geometry.IsValue() {
vals[44] = psql.Arg(s.Geometry.MustGet())
} else {
vals[44] = psql.Raw("DEFAULT")
}
if !s.Geospatial.IsUnset() {
vals[45] = psql.Arg(s.Geospatial.MustGetNull())
} else {
vals[45] = psql.Raw("DEFAULT")
}
if s.Version.IsValue() {
vals[46] = psql.Arg(s.Version.MustGet())
} else {
vals[46] = psql.Raw("DEFAULT")
}
if s.OrganizationID.IsValue() {
vals[47] = psql.Arg(s.OrganizationID.MustGet())
} else {
vals[47] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -842,7 +911,7 @@ func (s FieldseekerPointlocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery
}
func (s FieldseekerPointlocationSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 45)
exprs := make([]bob.Expression, 0, 48)
if s.Objectid.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -1152,6 +1221,20 @@ func (s FieldseekerPointlocationSetter) Expressions(prefix ...string) []bob.Expr
}})
}
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")...),
@ -1159,6 +1242,13 @@ func (s FieldseekerPointlocationSetter) Expressions(prefix ...string) []bob.Expr
}})
}
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
}
@ -1226,6 +1316,7 @@ func (o *FieldseekerPointlocation) Update(ctx context.Context, exec bob.Executor
return err
}
o.R = v.R
*o = *v
return nil
@ -1246,7 +1337,7 @@ func (o *FieldseekerPointlocation) Reload(ctx context.Context, exec bob.Executor
if err != nil {
return err
}
o2.R = o.R
*o = *o2
return nil
@ -1296,7 +1387,7 @@ func (o FieldseekerPointlocationSlice) copyMatchingRows(from ...*FieldseekerPoin
if new.Version != old.Version {
continue
}
new.R = old.R
o[i] = new
break
}
@ -1394,18 +1485,90 @@ func (o FieldseekerPointlocationSlice) ReloadAll(ctx context.Context, exec bob.E
return nil
}
// Organization starts a query for related objects on organization
func (o *FieldseekerPointlocation) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
return Organizations.Query(append(mods,
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
)...)
}
func (os FieldseekerPointlocationSlice) 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 attachFieldseekerPointlocationOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerPointlocation0 *FieldseekerPointlocation, organization1 *Organization) (*FieldseekerPointlocation, error) {
setter := &FieldseekerPointlocationSetter{
OrganizationID: omit.From(organization1.ID),
}
err := fieldseekerPointlocation0.Update(ctx, exec, setter)
if err != nil {
return nil, fmt.Errorf("attachFieldseekerPointlocationOrganization0: %w", err)
}
return fieldseekerPointlocation0, nil
}
func (fieldseekerPointlocation0 *FieldseekerPointlocation) 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 = attachFieldseekerPointlocationOrganization0(ctx, exec, 1, fieldseekerPointlocation0, organization1)
if err != nil {
return err
}
fieldseekerPointlocation0.R.Organization = organization1
organization1.R.Pointlocations = append(organization1.R.Pointlocations, fieldseekerPointlocation0)
return nil
}
func (fieldseekerPointlocation0 *FieldseekerPointlocation) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
var err error
_, err = attachFieldseekerPointlocationOrganization0(ctx, exec, 1, fieldseekerPointlocation0, organization1)
if err != nil {
return err
}
fieldseekerPointlocation0.R.Organization = organization1
organization1.R.Pointlocations = append(organization1.R.Pointlocations, fieldseekerPointlocation0)
return nil
}
type fieldseekerPointlocationWhere[Q psql.Filterable] struct {
Objectid psql.WhereMod[Q, int64]
Name psql.WhereNullMod[Q, string]
Zone psql.WhereNullMod[Q, string]
Habitat psql.WhereNullMod[Q, enums.FieldseekerPointlocationPointlocationHabitatB4d8135a497949C88BB367e]
Priority psql.WhereNullMod[Q, enums.FieldseekerPointlocationLocationpriorityEnum]
Usetype psql.WhereNullMod[Q, enums.FieldseekerPointlocationPointlocationUsetype58d62d18ef4f47fc8cb9874df86]
Active psql.WhereNullMod[Q, enums.FieldseekerPointlocationNotinuitFEnum]
Habitat psql.WhereNullMod[Q, string]
Priority psql.WhereNullMod[Q, string]
Usetype psql.WhereNullMod[Q, string]
Active psql.WhereNullMod[Q, int16]
Description psql.WhereNullMod[Q, string]
Accessdesc psql.WhereNullMod[Q, string]
Comments psql.WhereNullMod[Q, string]
Symbology psql.WhereNullMod[Q, enums.FieldseekerPointlocationLocationsymbologyEnum]
Symbology psql.WhereNullMod[Q, string]
Externalid psql.WhereNullMod[Q, string]
Nextactiondatescheduled psql.WhereNullMod[Q, time.Time]
Larvinspectinterval psql.WhereNullMod[Q, int16]
@ -1427,19 +1590,22 @@ type fieldseekerPointlocationWhere[Q psql.Filterable] struct {
Lastinspectactivity psql.WhereNullMod[Q, string]
Lasttreatactivity psql.WhereNullMod[Q, string]
Lastinspectconditions psql.WhereNullMod[Q, string]
Waterorigin psql.WhereNullMod[Q, enums.FieldseekerPointlocationPointlocationWaterorigin197B22BFF3eb4dad8899]
Waterorigin psql.WhereNullMod[Q, string]
X psql.WhereNullMod[Q, float64]
Y psql.WhereNullMod[Q, float64]
Assignedtech psql.WhereNullMod[Q, enums.FieldseekerPointlocationPointlocationAssignedtech9393a1622474429D85B]
Assignedtech 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]
Jurisdiction psql.WhereNullMod[Q, string]
DeactivateReason psql.WhereNullMod[Q, enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489]
DeactivateReason psql.WhereNullMod[Q, string]
Scalarpriority psql.WhereNullMod[Q, int32]
Sourcestatus 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 (fieldseekerPointlocationWhere[Q]) AliasedAs(alias string) fieldseekerPointlocationWhere[Q] {
@ -1451,14 +1617,14 @@ func buildFieldseekerPointlocationWhere[Q psql.Filterable](cols fieldseekerPoint
Objectid: psql.Where[Q, int64](cols.Objectid),
Name: psql.WhereNull[Q, string](cols.Name),
Zone: psql.WhereNull[Q, string](cols.Zone),
Habitat: psql.WhereNull[Q, enums.FieldseekerPointlocationPointlocationHabitatB4d8135a497949C88BB367e](cols.Habitat),
Priority: psql.WhereNull[Q, enums.FieldseekerPointlocationLocationpriorityEnum](cols.Priority),
Usetype: psql.WhereNull[Q, enums.FieldseekerPointlocationPointlocationUsetype58d62d18ef4f47fc8cb9874df86](cols.Usetype),
Active: psql.WhereNull[Q, enums.FieldseekerPointlocationNotinuitFEnum](cols.Active),
Habitat: psql.WhereNull[Q, string](cols.Habitat),
Priority: psql.WhereNull[Q, string](cols.Priority),
Usetype: psql.WhereNull[Q, string](cols.Usetype),
Active: psql.WhereNull[Q, int16](cols.Active),
Description: psql.WhereNull[Q, string](cols.Description),
Accessdesc: psql.WhereNull[Q, string](cols.Accessdesc),
Comments: psql.WhereNull[Q, string](cols.Comments),
Symbology: psql.WhereNull[Q, enums.FieldseekerPointlocationLocationsymbologyEnum](cols.Symbology),
Symbology: psql.WhereNull[Q, string](cols.Symbology),
Externalid: psql.WhereNull[Q, string](cols.Externalid),
Nextactiondatescheduled: psql.WhereNull[Q, time.Time](cols.Nextactiondatescheduled),
Larvinspectinterval: psql.WhereNull[Q, int16](cols.Larvinspectinterval),
@ -1480,18 +1646,166 @@ func buildFieldseekerPointlocationWhere[Q psql.Filterable](cols fieldseekerPoint
Lastinspectactivity: psql.WhereNull[Q, string](cols.Lastinspectactivity),
Lasttreatactivity: psql.WhereNull[Q, string](cols.Lasttreatactivity),
Lastinspectconditions: psql.WhereNull[Q, string](cols.Lastinspectconditions),
Waterorigin: psql.WhereNull[Q, enums.FieldseekerPointlocationPointlocationWaterorigin197B22BFF3eb4dad8899](cols.Waterorigin),
Waterorigin: psql.WhereNull[Q, string](cols.Waterorigin),
X: psql.WhereNull[Q, float64](cols.X),
Y: psql.WhereNull[Q, float64](cols.Y),
Assignedtech: psql.WhereNull[Q, enums.FieldseekerPointlocationPointlocationAssignedtech9393a1622474429D85B](cols.Assignedtech),
Assignedtech: psql.WhereNull[Q, string](cols.Assignedtech),
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),
DeactivateReason: psql.WhereNull[Q, enums.FieldseekerPointlocationPointlocationDeactivateReasonDD303085B33C489](cols.DeactivateReason),
DeactivateReason: psql.WhereNull[Q, string](cols.DeactivateReason),
Scalarpriority: psql.WhereNull[Q, int32](cols.Scalarpriority),
Sourcestatus: psql.WhereNull[Q, string](cols.Sourcestatus),
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 *FieldseekerPointlocation) Preload(name string, retrieved any) error {
if o == nil {
return nil
}
switch name {
case "Organization":
rel, ok := retrieved.(*Organization)
if !ok {
return fmt.Errorf("fieldseekerPointlocation cannot load %T as %q", retrieved, name)
}
o.R.Organization = rel
if rel != nil {
rel.R.Pointlocations = FieldseekerPointlocationSlice{o}
}
return nil
default:
return fmt.Errorf("fieldseekerPointlocation has no relationship %q", name)
}
}
type fieldseekerPointlocationPreloader struct {
Organization func(...psql.PreloadOption) psql.Preloader
}
func buildFieldseekerPointlocationPreloader() fieldseekerPointlocationPreloader {
return fieldseekerPointlocationPreloader{
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
Name: "Organization",
Sides: []psql.PreloadSide{
{
From: FieldseekerPointlocations,
To: Organizations,
FromColumns: []string{"organization_id"},
ToColumns: []string{"id"},
},
},
}, Organizations.Columns.Names(), opts...)
},
}
}
type fieldseekerPointlocationThenLoader[Q orm.Loadable] struct {
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildFieldseekerPointlocationThenLoader[Q orm.Loadable]() fieldseekerPointlocationThenLoader[Q] {
type OrganizationLoadInterface interface {
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return fieldseekerPointlocationThenLoader[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 fieldseekerPointlocation's Organization into the .R struct
func (o *FieldseekerPointlocation) 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.Pointlocations = FieldseekerPointlocationSlice{o}
o.R.Organization = related
return nil
}
// LoadOrganization loads the fieldseekerPointlocation's Organization into the .R struct
func (os FieldseekerPointlocationSlice) 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.Pointlocations = append(rel.R.Pointlocations, o)
o.R.Organization = rel
break
}
}
return nil
}
type fieldseekerPointlocationJoins[Q dialect.Joinable] struct {
typ string
Organization modAs[Q, organizationColumns]
}
func (j fieldseekerPointlocationJoins[Q]) aliasedAs(alias string) fieldseekerPointlocationJoins[Q] {
return buildFieldseekerPointlocationJoins[Q](buildFieldseekerPointlocationColumns(alias), j.typ)
}
func buildFieldseekerPointlocationJoins[Q dialect.Joinable](cols fieldseekerPointlocationColumns, typ string) fieldseekerPointlocationJoins[Q] {
return fieldseekerPointlocationJoins[Q]{
typ: typ,
Organization: modAs[Q, organizationColumns]{
c: Organizations.Columns,
f: func(to organizationColumns) bob.Mod[Q] {
mods := make(mods.QueryMods[Q], 0, 1)
{
mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On(
to.ID.EQ(cols.OrganizationID),
))
}
return mods
},
},
}
}