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:
parent
58f5afccc9
commit
1395e3d3ac
445 changed files with 54077 additions and 275856 deletions
|
|
@ -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,86 +21,103 @@ 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"
|
||||
)
|
||||
|
||||
// FieldseekerPolygonlocation is an object representing the database table.
|
||||
type FieldseekerPolygonlocation 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.FieldseekerPolygonlocationPolygonlocationHabitat45e9dde79ac84d959df8b65] `db:"habitat" `
|
||||
// Priority
|
||||
Priority null.Val[enums.FieldseekerPolygonlocationLocationpriorityEnum] `db:"priority" `
|
||||
// Use Type
|
||||
Usetype null.Val[enums.FieldseekerPolygonlocationPolygonlocationUsetypeE546154cb9544b9aa8e7b13] `db:"usetype" `
|
||||
// Active
|
||||
Active null.Val[enums.FieldseekerPolygonlocationNotinuitFEnum] `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.FieldseekerPolygonlocationLocationsymbologyEnum] `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" `
|
||||
// Acres
|
||||
// Original attribute from ArcGIS API is ACRES
|
||||
Acres null.Val[float64] `db:"acres" `
|
||||
// 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" `
|
||||
// Last Inspection Date
|
||||
// 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 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" `
|
||||
// Hectares
|
||||
// Original attribute from ArcGIS API is HECTARES
|
||||
Hectares null.Val[float64] `db:"hectares" `
|
||||
// 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.FieldseekerPolygonlocationPolygonlocationWateroriginE9018e925F474FF9] `db:"waterorigin" `
|
||||
Filter null.Val[string] `db:"filter" `
|
||||
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
|
||||
Jurisdiction null.Val[string] `db:"jurisdiction" `
|
||||
ShapeArea null.Val[float64] `db:"shape__area" `
|
||||
ShapeLength null.Val[float64] `db:"shape__length" `
|
||||
// Tracks version changes to the row. Increases when data is modified.
|
||||
Version int32 `db:"version,pk" `
|
||||
// Original attribute from ArcGIS API is WATERORIGIN
|
||||
Waterorigin null.Val[string] `db:"waterorigin" `
|
||||
// Original attribute from ArcGIS API is Filter
|
||||
Filter null.Val[string] `db:"filter" `
|
||||
// Original attribute from ArcGIS API is CreationDate
|
||||
Creationdate null.Val[time.Time] `db:"creationdate" `
|
||||
// Original attribute from ArcGIS API is Creator
|
||||
Creator null.Val[string] `db:"creator" `
|
||||
// Original attribute from ArcGIS API is EditDate
|
||||
Editdate null.Val[time.Time] `db:"editdate" `
|
||||
// Original attribute from ArcGIS API is Editor
|
||||
Editor null.Val[string] `db:"editor" `
|
||||
// Original attribute from ArcGIS API is JURISDICTION
|
||||
Jurisdiction null.Val[string] `db:"jurisdiction" `
|
||||
// Original attribute from ArcGIS API is Shape__Area
|
||||
ShapeArea null.Val[float64] `db:"shape__area" `
|
||||
// Original attribute from ArcGIS API is Shape__Length
|
||||
ShapeLength null.Val[float64] `db:"shape__length" `
|
||||
Geometry types.JSON[json.RawMessage] `db:"geometry" `
|
||||
Geospatial null.Val[string] `db:"geospatial" `
|
||||
Version int32 `db:"version,pk" `
|
||||
OrganizationID int32 `db:"organization_id" `
|
||||
|
||||
R fieldseekerPolygonlocationR `db:"-" `
|
||||
}
|
||||
|
||||
// FieldseekerPolygonlocationSlice is an alias for a slice of pointers to FieldseekerPolygonlocation.
|
||||
|
|
@ -112,10 +130,15 @@ var FieldseekerPolygonlocations = psql.NewTablex[*FieldseekerPolygonlocation, Fi
|
|||
// FieldseekerPolygonlocationsQuery is a query on the polygonlocation table
|
||||
type FieldseekerPolygonlocationsQuery = *psql.ViewQuery[*FieldseekerPolygonlocation, FieldseekerPolygonlocationSlice]
|
||||
|
||||
// fieldseekerPolygonlocationR is where relationships are stored.
|
||||
type fieldseekerPolygonlocationR struct {
|
||||
Organization *Organization // fieldseeker.polygonlocation.polygonlocation_organization_id_fkey
|
||||
}
|
||||
|
||||
func buildFieldseekerPolygonlocationColumns(alias string) fieldseekerPolygonlocationColumns {
|
||||
return fieldseekerPolygonlocationColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "acres", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "hectares", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "filter", "creationdate", "creator", "editdate", "editor", "jurisdiction", "shape__area", "shape__length", "version",
|
||||
"objectid", "name", "zone", "habitat", "priority", "usetype", "active", "description", "accessdesc", "comments", "symbology", "externalid", "acres", "nextactiondatescheduled", "larvinspectinterval", "zone2", "locationnumber", "globalid", "lastinspectdate", "lastinspectbreeding", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectlstages", "lastinspectactiontaken", "lastinspectfieldspecies", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "hectares", "lastinspectactivity", "lasttreatactivity", "lastinspectconditions", "waterorigin", "filter", "creationdate", "creator", "editdate", "editor", "jurisdiction", "shape__area", "shape__length", "geometry", "geospatial", "version", "organization_id",
|
||||
).WithParent("fieldseeker.polygonlocation"),
|
||||
tableAlias: alias,
|
||||
Objectid: psql.Quote(alias, "objectid"),
|
||||
|
|
@ -160,7 +183,10 @@ func buildFieldseekerPolygonlocationColumns(alias string) fieldseekerPolygonloca
|
|||
Jurisdiction: psql.Quote(alias, "jurisdiction"),
|
||||
ShapeArea: psql.Quote(alias, "shape__area"),
|
||||
ShapeLength: psql.Quote(alias, "shape__length"),
|
||||
Geometry: psql.Quote(alias, "geometry"),
|
||||
Geospatial: psql.Quote(alias, "geospatial"),
|
||||
Version: psql.Quote(alias, "version"),
|
||||
OrganizationID: psql.Quote(alias, "organization_id"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +235,10 @@ type fieldseekerPolygonlocationColumns struct {
|
|||
Jurisdiction psql.Expression
|
||||
ShapeArea psql.Expression
|
||||
ShapeLength psql.Expression
|
||||
Geometry psql.Expression
|
||||
Geospatial psql.Expression
|
||||
Version psql.Expression
|
||||
OrganizationID psql.Expression
|
||||
}
|
||||
|
||||
func (c fieldseekerPolygonlocationColumns) Alias() string {
|
||||
|
|
@ -224,53 +253,56 @@ func (fieldseekerPolygonlocationColumns) AliasedAs(alias string) fieldseekerPoly
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type FieldseekerPolygonlocationSetter struct {
|
||||
Objectid omit.Val[int64] `db:"objectid,pk" `
|
||||
Name omitnull.Val[string] `db:"name" `
|
||||
Zone omitnull.Val[string] `db:"zone" `
|
||||
Habitat omitnull.Val[enums.FieldseekerPolygonlocationPolygonlocationHabitat45e9dde79ac84d959df8b65] `db:"habitat" `
|
||||
Priority omitnull.Val[enums.FieldseekerPolygonlocationLocationpriorityEnum] `db:"priority" `
|
||||
Usetype omitnull.Val[enums.FieldseekerPolygonlocationPolygonlocationUsetypeE546154cb9544b9aa8e7b13] `db:"usetype" `
|
||||
Active omitnull.Val[enums.FieldseekerPolygonlocationNotinuitFEnum] `db:"active" `
|
||||
Description omitnull.Val[string] `db:"description" `
|
||||
Accessdesc omitnull.Val[string] `db:"accessdesc" `
|
||||
Comments omitnull.Val[string] `db:"comments" `
|
||||
Symbology omitnull.Val[enums.FieldseekerPolygonlocationLocationsymbologyEnum] `db:"symbology" `
|
||||
Externalid omitnull.Val[string] `db:"externalid" `
|
||||
Acres omitnull.Val[float64] `db:"acres" `
|
||||
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" `
|
||||
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" `
|
||||
Hectares omitnull.Val[float64] `db:"hectares" `
|
||||
Lastinspectactivity omitnull.Val[string] `db:"lastinspectactivity" `
|
||||
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
|
||||
Lastinspectconditions omitnull.Val[string] `db:"lastinspectconditions" `
|
||||
Waterorigin omitnull.Val[enums.FieldseekerPolygonlocationPolygonlocationWateroriginE9018e925F474FF9] `db:"waterorigin" `
|
||||
Filter omitnull.Val[string] `db:"filter" `
|
||||
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" `
|
||||
ShapeArea omitnull.Val[float64] `db:"shape__area" `
|
||||
ShapeLength omitnull.Val[float64] `db:"shape__length" `
|
||||
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" `
|
||||
Acres omitnull.Val[float64] `db:"acres" `
|
||||
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" `
|
||||
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" `
|
||||
Hectares omitnull.Val[float64] `db:"hectares" `
|
||||
Lastinspectactivity omitnull.Val[string] `db:"lastinspectactivity" `
|
||||
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
|
||||
Lastinspectconditions omitnull.Val[string] `db:"lastinspectconditions" `
|
||||
Waterorigin omitnull.Val[string] `db:"waterorigin" `
|
||||
Filter omitnull.Val[string] `db:"filter" `
|
||||
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" `
|
||||
ShapeArea omitnull.Val[float64] `db:"shape__area" `
|
||||
ShapeLength omitnull.Val[float64] `db:"shape__length" `
|
||||
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 FieldseekerPolygonlocationSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 43)
|
||||
vals := make([]string, 0, 46)
|
||||
if s.Objectid.IsValue() {
|
||||
vals = append(vals, "objectid")
|
||||
}
|
||||
|
|
@ -397,9 +429,18 @@ func (s FieldseekerPolygonlocationSetter) SetColumns() []string {
|
|||
if !s.ShapeLength.IsUnset() {
|
||||
vals = append(vals, "shape__length")
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -530,9 +571,18 @@ func (s FieldseekerPolygonlocationSetter) Overwrite(t *FieldseekerPolygonlocatio
|
|||
if !s.ShapeLength.IsUnset() {
|
||||
t.ShapeLength = s.ShapeLength.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 *FieldseekerPolygonlocationSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -541,7 +591,7 @@ func (s *FieldseekerPolygonlocationSetter) 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, 43)
|
||||
vals := make([]bob.Expression, 46)
|
||||
if s.Objectid.IsValue() {
|
||||
vals[0] = psql.Arg(s.Objectid.MustGet())
|
||||
} else {
|
||||
|
|
@ -794,12 +844,30 @@ func (s *FieldseekerPolygonlocationSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[41] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Version.IsValue() {
|
||||
vals[42] = psql.Arg(s.Version.MustGet())
|
||||
if s.Geometry.IsValue() {
|
||||
vals[42] = psql.Arg(s.Geometry.MustGet())
|
||||
} else {
|
||||
vals[42] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Geospatial.IsUnset() {
|
||||
vals[43] = psql.Arg(s.Geospatial.MustGetNull())
|
||||
} else {
|
||||
vals[43] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Version.IsValue() {
|
||||
vals[44] = psql.Arg(s.Version.MustGet())
|
||||
} else {
|
||||
vals[44] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.OrganizationID.IsValue() {
|
||||
vals[45] = psql.Arg(s.OrganizationID.MustGet())
|
||||
} else {
|
||||
vals[45] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -809,7 +877,7 @@ func (s FieldseekerPolygonlocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQue
|
|||
}
|
||||
|
||||
func (s FieldseekerPolygonlocationSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 43)
|
||||
exprs := make([]bob.Expression, 0, 46)
|
||||
|
||||
if s.Objectid.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -1105,6 +1173,20 @@ func (s FieldseekerPolygonlocationSetter) Expressions(prefix ...string) []bob.Ex
|
|||
}})
|
||||
}
|
||||
|
||||
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")...),
|
||||
|
|
@ -1112,6 +1194,13 @@ func (s FieldseekerPolygonlocationSetter) Expressions(prefix ...string) []bob.Ex
|
|||
}})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -1179,6 +1268,7 @@ func (o *FieldseekerPolygonlocation) Update(ctx context.Context, exec bob.Execut
|
|||
return err
|
||||
}
|
||||
|
||||
o.R = v.R
|
||||
*o = *v
|
||||
|
||||
return nil
|
||||
|
|
@ -1199,7 +1289,7 @@ func (o *FieldseekerPolygonlocation) Reload(ctx context.Context, exec bob.Execut
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o2.R = o.R
|
||||
*o = *o2
|
||||
|
||||
return nil
|
||||
|
|
@ -1249,7 +1339,7 @@ func (o FieldseekerPolygonlocationSlice) copyMatchingRows(from ...*FieldseekerPo
|
|||
if new.Version != old.Version {
|
||||
continue
|
||||
}
|
||||
|
||||
new.R = old.R
|
||||
o[i] = new
|
||||
break
|
||||
}
|
||||
|
|
@ -1347,18 +1437,90 @@ func (o FieldseekerPolygonlocationSlice) ReloadAll(ctx context.Context, exec bob
|
|||
return nil
|
||||
}
|
||||
|
||||
// Organization starts a query for related objects on organization
|
||||
func (o *FieldseekerPolygonlocation) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
||||
return Organizations.Query(append(mods,
|
||||
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os FieldseekerPolygonlocationSlice) 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 attachFieldseekerPolygonlocationOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerPolygonlocation0 *FieldseekerPolygonlocation, organization1 *Organization) (*FieldseekerPolygonlocation, error) {
|
||||
setter := &FieldseekerPolygonlocationSetter{
|
||||
OrganizationID: omit.From(organization1.ID),
|
||||
}
|
||||
|
||||
err := fieldseekerPolygonlocation0.Update(ctx, exec, setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachFieldseekerPolygonlocationOrganization0: %w", err)
|
||||
}
|
||||
|
||||
return fieldseekerPolygonlocation0, nil
|
||||
}
|
||||
|
||||
func (fieldseekerPolygonlocation0 *FieldseekerPolygonlocation) 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 = attachFieldseekerPolygonlocationOrganization0(ctx, exec, 1, fieldseekerPolygonlocation0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fieldseekerPolygonlocation0.R.Organization = organization1
|
||||
|
||||
organization1.R.Polygonlocations = append(organization1.R.Polygonlocations, fieldseekerPolygonlocation0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fieldseekerPolygonlocation0 *FieldseekerPolygonlocation) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
||||
var err error
|
||||
|
||||
_, err = attachFieldseekerPolygonlocationOrganization0(ctx, exec, 1, fieldseekerPolygonlocation0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fieldseekerPolygonlocation0.R.Organization = organization1
|
||||
|
||||
organization1.R.Polygonlocations = append(organization1.R.Polygonlocations, fieldseekerPolygonlocation0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type fieldseekerPolygonlocationWhere[Q psql.Filterable] struct {
|
||||
Objectid psql.WhereMod[Q, int64]
|
||||
Name psql.WhereNullMod[Q, string]
|
||||
Zone psql.WhereNullMod[Q, string]
|
||||
Habitat psql.WhereNullMod[Q, enums.FieldseekerPolygonlocationPolygonlocationHabitat45e9dde79ac84d959df8b65]
|
||||
Priority psql.WhereNullMod[Q, enums.FieldseekerPolygonlocationLocationpriorityEnum]
|
||||
Usetype psql.WhereNullMod[Q, enums.FieldseekerPolygonlocationPolygonlocationUsetypeE546154cb9544b9aa8e7b13]
|
||||
Active psql.WhereNullMod[Q, enums.FieldseekerPolygonlocationNotinuitFEnum]
|
||||
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.FieldseekerPolygonlocationLocationsymbologyEnum]
|
||||
Symbology psql.WhereNullMod[Q, string]
|
||||
Externalid psql.WhereNullMod[Q, string]
|
||||
Acres psql.WhereNullMod[Q, float64]
|
||||
Nextactiondatescheduled psql.WhereNullMod[Q, time.Time]
|
||||
|
|
@ -1381,7 +1543,7 @@ type fieldseekerPolygonlocationWhere[Q psql.Filterable] struct {
|
|||
Lastinspectactivity psql.WhereNullMod[Q, string]
|
||||
Lasttreatactivity psql.WhereNullMod[Q, string]
|
||||
Lastinspectconditions psql.WhereNullMod[Q, string]
|
||||
Waterorigin psql.WhereNullMod[Q, enums.FieldseekerPolygonlocationPolygonlocationWateroriginE9018e925F474FF9]
|
||||
Waterorigin psql.WhereNullMod[Q, string]
|
||||
Filter psql.WhereNullMod[Q, string]
|
||||
Creationdate psql.WhereNullMod[Q, time.Time]
|
||||
Creator psql.WhereNullMod[Q, string]
|
||||
|
|
@ -1390,7 +1552,10 @@ type fieldseekerPolygonlocationWhere[Q psql.Filterable] struct {
|
|||
Jurisdiction psql.WhereNullMod[Q, string]
|
||||
ShapeArea psql.WhereNullMod[Q, float64]
|
||||
ShapeLength psql.WhereNullMod[Q, float64]
|
||||
Geometry psql.WhereMod[Q, types.JSON[json.RawMessage]]
|
||||
Geospatial psql.WhereNullMod[Q, string]
|
||||
Version psql.WhereMod[Q, int32]
|
||||
OrganizationID psql.WhereMod[Q, int32]
|
||||
}
|
||||
|
||||
func (fieldseekerPolygonlocationWhere[Q]) AliasedAs(alias string) fieldseekerPolygonlocationWhere[Q] {
|
||||
|
|
@ -1402,14 +1567,14 @@ func buildFieldseekerPolygonlocationWhere[Q psql.Filterable](cols fieldseekerPol
|
|||
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.FieldseekerPolygonlocationPolygonlocationHabitat45e9dde79ac84d959df8b65](cols.Habitat),
|
||||
Priority: psql.WhereNull[Q, enums.FieldseekerPolygonlocationLocationpriorityEnum](cols.Priority),
|
||||
Usetype: psql.WhereNull[Q, enums.FieldseekerPolygonlocationPolygonlocationUsetypeE546154cb9544b9aa8e7b13](cols.Usetype),
|
||||
Active: psql.WhereNull[Q, enums.FieldseekerPolygonlocationNotinuitFEnum](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.FieldseekerPolygonlocationLocationsymbologyEnum](cols.Symbology),
|
||||
Symbology: psql.WhereNull[Q, string](cols.Symbology),
|
||||
Externalid: psql.WhereNull[Q, string](cols.Externalid),
|
||||
Acres: psql.WhereNull[Q, float64](cols.Acres),
|
||||
Nextactiondatescheduled: psql.WhereNull[Q, time.Time](cols.Nextactiondatescheduled),
|
||||
|
|
@ -1432,7 +1597,7 @@ func buildFieldseekerPolygonlocationWhere[Q psql.Filterable](cols fieldseekerPol
|
|||
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.FieldseekerPolygonlocationPolygonlocationWateroriginE9018e925F474FF9](cols.Waterorigin),
|
||||
Waterorigin: psql.WhereNull[Q, string](cols.Waterorigin),
|
||||
Filter: psql.WhereNull[Q, string](cols.Filter),
|
||||
Creationdate: psql.WhereNull[Q, time.Time](cols.Creationdate),
|
||||
Creator: psql.WhereNull[Q, string](cols.Creator),
|
||||
|
|
@ -1441,6 +1606,154 @@ func buildFieldseekerPolygonlocationWhere[Q psql.Filterable](cols fieldseekerPol
|
|||
Jurisdiction: psql.WhereNull[Q, string](cols.Jurisdiction),
|
||||
ShapeArea: psql.WhereNull[Q, float64](cols.ShapeArea),
|
||||
ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength),
|
||||
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 *FieldseekerPolygonlocation) Preload(name string, retrieved any) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch name {
|
||||
case "Organization":
|
||||
rel, ok := retrieved.(*Organization)
|
||||
if !ok {
|
||||
return fmt.Errorf("fieldseekerPolygonlocation cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Organization = rel
|
||||
|
||||
if rel != nil {
|
||||
rel.R.Polygonlocations = FieldseekerPolygonlocationSlice{o}
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("fieldseekerPolygonlocation has no relationship %q", name)
|
||||
}
|
||||
}
|
||||
|
||||
type fieldseekerPolygonlocationPreloader struct {
|
||||
Organization func(...psql.PreloadOption) psql.Preloader
|
||||
}
|
||||
|
||||
func buildFieldseekerPolygonlocationPreloader() fieldseekerPolygonlocationPreloader {
|
||||
return fieldseekerPolygonlocationPreloader{
|
||||
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
||||
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
||||
Name: "Organization",
|
||||
Sides: []psql.PreloadSide{
|
||||
{
|
||||
From: FieldseekerPolygonlocations,
|
||||
To: Organizations,
|
||||
FromColumns: []string{"organization_id"},
|
||||
ToColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
}, Organizations.Columns.Names(), opts...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type fieldseekerPolygonlocationThenLoader[Q orm.Loadable] struct {
|
||||
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildFieldseekerPolygonlocationThenLoader[Q orm.Loadable]() fieldseekerPolygonlocationThenLoader[Q] {
|
||||
type OrganizationLoadInterface interface {
|
||||
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
||||
return fieldseekerPolygonlocationThenLoader[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 fieldseekerPolygonlocation's Organization into the .R struct
|
||||
func (o *FieldseekerPolygonlocation) 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.Polygonlocations = FieldseekerPolygonlocationSlice{o}
|
||||
|
||||
o.R.Organization = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadOrganization loads the fieldseekerPolygonlocation's Organization into the .R struct
|
||||
func (os FieldseekerPolygonlocationSlice) 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.Polygonlocations = append(rel.R.Polygonlocations, o)
|
||||
|
||||
o.R.Organization = rel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type fieldseekerPolygonlocationJoins[Q dialect.Joinable] struct {
|
||||
typ string
|
||||
Organization modAs[Q, organizationColumns]
|
||||
}
|
||||
|
||||
func (j fieldseekerPolygonlocationJoins[Q]) aliasedAs(alias string) fieldseekerPolygonlocationJoins[Q] {
|
||||
return buildFieldseekerPolygonlocationJoins[Q](buildFieldseekerPolygonlocationColumns(alias), j.typ)
|
||||
}
|
||||
|
||||
func buildFieldseekerPolygonlocationJoins[Q dialect.Joinable](cols fieldseekerPolygonlocationColumns, typ string) fieldseekerPolygonlocationJoins[Q] {
|
||||
return fieldseekerPolygonlocationJoins[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
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue