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,69 +21,85 @@ 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"
|
||||
)
|
||||
|
||||
// FieldseekerProposedtreatmentarea is an object representing the database table.
|
||||
type FieldseekerProposedtreatmentarea struct {
|
||||
Objectid int64 `db:"objectid,pk" `
|
||||
// Method
|
||||
Method null.Val[enums.FieldseekerProposedtreatmentareaMosquitotreatmentmethodEnum] `db:"method" `
|
||||
// Comments
|
||||
// Original attribute from ArcGIS API is METHOD
|
||||
Method null.Val[string] `db:"method" `
|
||||
// Original attribute from ArcGIS API is COMMENTS
|
||||
Comments null.Val[string] `db:"comments" `
|
||||
// Zone
|
||||
// Original attribute from ArcGIS API is ZONE
|
||||
Zone null.Val[string] `db:"zone" `
|
||||
// Reviewed
|
||||
Reviewed null.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"reviewed" `
|
||||
// Reviewed By
|
||||
// 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" `
|
||||
// Reviewed Date
|
||||
// Original attribute from ArcGIS API is REVIEWEDDATE
|
||||
Revieweddate null.Val[time.Time] `db:"revieweddate" `
|
||||
// Zone2
|
||||
// Original attribute from ArcGIS API is ZONE2
|
||||
Zone2 null.Val[string] `db:"zone2" `
|
||||
// Completed Date
|
||||
// Original attribute from ArcGIS API is COMPLETEDDATE
|
||||
Completeddate null.Val[time.Time] `db:"completeddate" `
|
||||
// Completed By
|
||||
// Original attribute from ArcGIS API is COMPLETEDBY
|
||||
Completedby null.Val[string] `db:"completedby" `
|
||||
// Completed
|
||||
Completed null.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"completed" `
|
||||
// Is Spray Route
|
||||
Issprayroute null.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"issprayroute" `
|
||||
// Name
|
||||
// Original attribute from ArcGIS API is COMPLETED
|
||||
Completed null.Val[int16] `db:"completed" `
|
||||
// Original attribute from ArcGIS API is ISSPRAYROUTE
|
||||
Issprayroute null.Val[int16] `db:"issprayroute" `
|
||||
// Original attribute from ArcGIS API is NAME
|
||||
Name null.Val[string] `db:"name" `
|
||||
// Acres
|
||||
Acres null.Val[float64] `db:"acres" `
|
||||
Globalid null.Val[uuid.UUID] `db:"globalid" `
|
||||
Exported null.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"exported" `
|
||||
// Target Product
|
||||
// Original attribute from ArcGIS API is ACRES
|
||||
Acres null.Val[float64] `db:"acres" `
|
||||
// Original attribute from ArcGIS API is GlobalID
|
||||
Globalid null.Val[uuid.UUID] `db:"globalid" `
|
||||
// Original attribute from ArcGIS API is EXPORTED
|
||||
Exported null.Val[int16] `db:"exported" `
|
||||
// Original attribute from ArcGIS API is TARGETPRODUCT
|
||||
Targetproduct null.Val[string] `db:"targetproduct" `
|
||||
// Target App Rate
|
||||
// Original attribute from ArcGIS API is TARGETAPPRATE
|
||||
Targetapprate null.Val[float64] `db:"targetapprate" `
|
||||
// Hectares
|
||||
// Original attribute from ArcGIS API is HECTARES
|
||||
Hectares null.Val[float64] `db:"hectares" `
|
||||
// Last Treatment Activity
|
||||
// Original attribute from ArcGIS API is LASTTREATACTIVITY
|
||||
Lasttreatactivity null.Val[string] `db:"lasttreatactivity" `
|
||||
// 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" `
|
||||
// Priority
|
||||
Priority null.Val[enums.FieldseekerProposedtreatmentareaLocationpriorityEnum] `db:"priority" `
|
||||
// Due Date
|
||||
Duedate null.Val[time.Time] `db:"duedate" `
|
||||
// Original attribute from ArcGIS API is PRIORITY
|
||||
Priority null.Val[string] `db:"priority" `
|
||||
// Original attribute from ArcGIS API is DUEDATE
|
||||
Duedate null.Val[time.Time] `db:"duedate" `
|
||||
// Original attribute from ArcGIS API is CreationDate
|
||||
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" `
|
||||
// Target Species
|
||||
Targetspecies null.Val[string] `db:"targetspecies" `
|
||||
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 Creator
|
||||
Creator null.Val[string] `db:"creator" `
|
||||
// Original attribute from ArcGIS API is EditDate
|
||||
Editdate null.Val[time.Time] `db:"editdate" `
|
||||
// Original attribute from ArcGIS API is Editor
|
||||
Editor null.Val[string] `db:"editor" `
|
||||
// Original attribute from ArcGIS API is TARGETSPECIES
|
||||
Targetspecies null.Val[string] `db:"targetspecies" `
|
||||
// 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 fieldseekerProposedtreatmentareaR `db:"-" `
|
||||
}
|
||||
|
||||
// FieldseekerProposedtreatmentareaSlice is an alias for a slice of pointers to FieldseekerProposedtreatmentarea.
|
||||
|
|
@ -95,10 +112,15 @@ var FieldseekerProposedtreatmentareas = psql.NewTablex[*FieldseekerProposedtreat
|
|||
// FieldseekerProposedtreatmentareasQuery is a query on the proposedtreatmentarea table
|
||||
type FieldseekerProposedtreatmentareasQuery = *psql.ViewQuery[*FieldseekerProposedtreatmentarea, FieldseekerProposedtreatmentareaSlice]
|
||||
|
||||
// fieldseekerProposedtreatmentareaR is where relationships are stored.
|
||||
type fieldseekerProposedtreatmentareaR struct {
|
||||
Organization *Organization // fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey
|
||||
}
|
||||
|
||||
func buildFieldseekerProposedtreatmentareaColumns(alias string) fieldseekerProposedtreatmentareaColumns {
|
||||
return fieldseekerProposedtreatmentareaColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"objectid", "method", "comments", "zone", "reviewed", "reviewedby", "revieweddate", "zone2", "completeddate", "completedby", "completed", "issprayroute", "name", "acres", "globalid", "exported", "targetproduct", "targetapprate", "hectares", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "priority", "duedate", "creationdate", "creator", "editdate", "editor", "targetspecies", "shape__area", "shape__length", "version",
|
||||
"objectid", "method", "comments", "zone", "reviewed", "reviewedby", "revieweddate", "zone2", "completeddate", "completedby", "completed", "issprayroute", "name", "acres", "globalid", "exported", "targetproduct", "targetapprate", "hectares", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "priority", "duedate", "creationdate", "creator", "editdate", "editor", "targetspecies", "shape__area", "shape__length", "geometry", "geospatial", "version", "organization_id",
|
||||
).WithParent("fieldseeker.proposedtreatmentarea"),
|
||||
tableAlias: alias,
|
||||
Objectid: psql.Quote(alias, "objectid"),
|
||||
|
|
@ -134,7 +156,10 @@ func buildFieldseekerProposedtreatmentareaColumns(alias string) fieldseekerPropo
|
|||
Targetspecies: psql.Quote(alias, "targetspecies"),
|
||||
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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +199,10 @@ type fieldseekerProposedtreatmentareaColumns struct {
|
|||
Targetspecies psql.Expression
|
||||
ShapeArea psql.Expression
|
||||
ShapeLength psql.Expression
|
||||
Geometry psql.Expression
|
||||
Geospatial psql.Expression
|
||||
Version psql.Expression
|
||||
OrganizationID psql.Expression
|
||||
}
|
||||
|
||||
func (c fieldseekerProposedtreatmentareaColumns) Alias() string {
|
||||
|
|
@ -189,44 +217,47 @@ func (fieldseekerProposedtreatmentareaColumns) AliasedAs(alias string) fieldseek
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type FieldseekerProposedtreatmentareaSetter struct {
|
||||
Objectid omit.Val[int64] `db:"objectid,pk" `
|
||||
Method omitnull.Val[enums.FieldseekerProposedtreatmentareaMosquitotreatmentmethodEnum] `db:"method" `
|
||||
Comments omitnull.Val[string] `db:"comments" `
|
||||
Zone omitnull.Val[string] `db:"zone" `
|
||||
Reviewed omitnull.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"reviewed" `
|
||||
Reviewedby omitnull.Val[string] `db:"reviewedby" `
|
||||
Revieweddate omitnull.Val[time.Time] `db:"revieweddate" `
|
||||
Zone2 omitnull.Val[string] `db:"zone2" `
|
||||
Completeddate omitnull.Val[time.Time] `db:"completeddate" `
|
||||
Completedby omitnull.Val[string] `db:"completedby" `
|
||||
Completed omitnull.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"completed" `
|
||||
Issprayroute omitnull.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"issprayroute" `
|
||||
Name omitnull.Val[string] `db:"name" `
|
||||
Acres omitnull.Val[float64] `db:"acres" `
|
||||
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
|
||||
Exported omitnull.Val[enums.FieldseekerProposedtreatmentareaNotinuitFEnum] `db:"exported" `
|
||||
Targetproduct omitnull.Val[string] `db:"targetproduct" `
|
||||
Targetapprate omitnull.Val[float64] `db:"targetapprate" `
|
||||
Hectares omitnull.Val[float64] `db:"hectares" `
|
||||
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
|
||||
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" `
|
||||
Priority omitnull.Val[enums.FieldseekerProposedtreatmentareaLocationpriorityEnum] `db:"priority" `
|
||||
Duedate omitnull.Val[time.Time] `db:"duedate" `
|
||||
Creationdate omitnull.Val[time.Time] `db:"creationdate" `
|
||||
Creator omitnull.Val[string] `db:"creator" `
|
||||
Editdate omitnull.Val[time.Time] `db:"editdate" `
|
||||
Editor omitnull.Val[string] `db:"editor" `
|
||||
Targetspecies omitnull.Val[string] `db:"targetspecies" `
|
||||
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" `
|
||||
Method omitnull.Val[string] `db:"method" `
|
||||
Comments omitnull.Val[string] `db:"comments" `
|
||||
Zone omitnull.Val[string] `db:"zone" `
|
||||
Reviewed omitnull.Val[int16] `db:"reviewed" `
|
||||
Reviewedby omitnull.Val[string] `db:"reviewedby" `
|
||||
Revieweddate omitnull.Val[time.Time] `db:"revieweddate" `
|
||||
Zone2 omitnull.Val[string] `db:"zone2" `
|
||||
Completeddate omitnull.Val[time.Time] `db:"completeddate" `
|
||||
Completedby omitnull.Val[string] `db:"completedby" `
|
||||
Completed omitnull.Val[int16] `db:"completed" `
|
||||
Issprayroute omitnull.Val[int16] `db:"issprayroute" `
|
||||
Name omitnull.Val[string] `db:"name" `
|
||||
Acres omitnull.Val[float64] `db:"acres" `
|
||||
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
|
||||
Exported omitnull.Val[int16] `db:"exported" `
|
||||
Targetproduct omitnull.Val[string] `db:"targetproduct" `
|
||||
Targetapprate omitnull.Val[float64] `db:"targetapprate" `
|
||||
Hectares omitnull.Val[float64] `db:"hectares" `
|
||||
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
|
||||
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" `
|
||||
Priority omitnull.Val[string] `db:"priority" `
|
||||
Duedate omitnull.Val[time.Time] `db:"duedate" `
|
||||
Creationdate omitnull.Val[time.Time] `db:"creationdate" `
|
||||
Creator omitnull.Val[string] `db:"creator" `
|
||||
Editdate omitnull.Val[time.Time] `db:"editdate" `
|
||||
Editor omitnull.Val[string] `db:"editor" `
|
||||
Targetspecies omitnull.Val[string] `db:"targetspecies" `
|
||||
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 FieldseekerProposedtreatmentareaSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 34)
|
||||
vals := make([]string, 0, 37)
|
||||
if s.Objectid.IsValue() {
|
||||
vals = append(vals, "objectid")
|
||||
}
|
||||
|
|
@ -326,9 +357,18 @@ func (s FieldseekerProposedtreatmentareaSetter) 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
|
||||
}
|
||||
|
||||
|
|
@ -432,9 +472,18 @@ func (s FieldseekerProposedtreatmentareaSetter) Overwrite(t *FieldseekerProposed
|
|||
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 *FieldseekerProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -443,7 +492,7 @@ func (s *FieldseekerProposedtreatmentareaSetter) 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, 34)
|
||||
vals := make([]bob.Expression, 37)
|
||||
if s.Objectid.IsValue() {
|
||||
vals[0] = psql.Arg(s.Objectid.MustGet())
|
||||
} else {
|
||||
|
|
@ -642,12 +691,30 @@ func (s *FieldseekerProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[32] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Version.IsValue() {
|
||||
vals[33] = psql.Arg(s.Version.MustGet())
|
||||
if s.Geometry.IsValue() {
|
||||
vals[33] = psql.Arg(s.Geometry.MustGet())
|
||||
} else {
|
||||
vals[33] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Geospatial.IsUnset() {
|
||||
vals[34] = psql.Arg(s.Geospatial.MustGetNull())
|
||||
} else {
|
||||
vals[34] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Version.IsValue() {
|
||||
vals[35] = psql.Arg(s.Version.MustGet())
|
||||
} else {
|
||||
vals[35] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.OrganizationID.IsValue() {
|
||||
vals[36] = psql.Arg(s.OrganizationID.MustGet())
|
||||
} else {
|
||||
vals[36] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -657,7 +724,7 @@ func (s FieldseekerProposedtreatmentareaSetter) UpdateMod() bob.Mod[*dialect.Upd
|
|||
}
|
||||
|
||||
func (s FieldseekerProposedtreatmentareaSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 34)
|
||||
exprs := make([]bob.Expression, 0, 37)
|
||||
|
||||
if s.Objectid.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -890,6 +957,20 @@ func (s FieldseekerProposedtreatmentareaSetter) Expressions(prefix ...string) []
|
|||
}})
|
||||
}
|
||||
|
||||
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")...),
|
||||
|
|
@ -897,6 +978,13 @@ func (s FieldseekerProposedtreatmentareaSetter) Expressions(prefix ...string) []
|
|||
}})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -964,6 +1052,7 @@ func (o *FieldseekerProposedtreatmentarea) Update(ctx context.Context, exec bob.
|
|||
return err
|
||||
}
|
||||
|
||||
o.R = v.R
|
||||
*o = *v
|
||||
|
||||
return nil
|
||||
|
|
@ -984,7 +1073,7 @@ func (o *FieldseekerProposedtreatmentarea) Reload(ctx context.Context, exec bob.
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o2.R = o.R
|
||||
*o = *o2
|
||||
|
||||
return nil
|
||||
|
|
@ -1034,7 +1123,7 @@ func (o FieldseekerProposedtreatmentareaSlice) copyMatchingRows(from ...*Fieldse
|
|||
if new.Version != old.Version {
|
||||
continue
|
||||
}
|
||||
|
||||
new.R = old.R
|
||||
o[i] = new
|
||||
break
|
||||
}
|
||||
|
|
@ -1132,23 +1221,95 @@ func (o FieldseekerProposedtreatmentareaSlice) ReloadAll(ctx context.Context, ex
|
|||
return nil
|
||||
}
|
||||
|
||||
// Organization starts a query for related objects on organization
|
||||
func (o *FieldseekerProposedtreatmentarea) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
||||
return Organizations.Query(append(mods,
|
||||
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os FieldseekerProposedtreatmentareaSlice) 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 attachFieldseekerProposedtreatmentareaOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerProposedtreatmentarea0 *FieldseekerProposedtreatmentarea, organization1 *Organization) (*FieldseekerProposedtreatmentarea, error) {
|
||||
setter := &FieldseekerProposedtreatmentareaSetter{
|
||||
OrganizationID: omit.From(organization1.ID),
|
||||
}
|
||||
|
||||
err := fieldseekerProposedtreatmentarea0.Update(ctx, exec, setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachFieldseekerProposedtreatmentareaOrganization0: %w", err)
|
||||
}
|
||||
|
||||
return fieldseekerProposedtreatmentarea0, nil
|
||||
}
|
||||
|
||||
func (fieldseekerProposedtreatmentarea0 *FieldseekerProposedtreatmentarea) 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 = attachFieldseekerProposedtreatmentareaOrganization0(ctx, exec, 1, fieldseekerProposedtreatmentarea0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fieldseekerProposedtreatmentarea0.R.Organization = organization1
|
||||
|
||||
organization1.R.Proposedtreatmentareas = append(organization1.R.Proposedtreatmentareas, fieldseekerProposedtreatmentarea0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fieldseekerProposedtreatmentarea0 *FieldseekerProposedtreatmentarea) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
||||
var err error
|
||||
|
||||
_, err = attachFieldseekerProposedtreatmentareaOrganization0(ctx, exec, 1, fieldseekerProposedtreatmentarea0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fieldseekerProposedtreatmentarea0.R.Organization = organization1
|
||||
|
||||
organization1.R.Proposedtreatmentareas = append(organization1.R.Proposedtreatmentareas, fieldseekerProposedtreatmentarea0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type fieldseekerProposedtreatmentareaWhere[Q psql.Filterable] struct {
|
||||
Objectid psql.WhereMod[Q, int64]
|
||||
Method psql.WhereNullMod[Q, enums.FieldseekerProposedtreatmentareaMosquitotreatmentmethodEnum]
|
||||
Method psql.WhereNullMod[Q, string]
|
||||
Comments psql.WhereNullMod[Q, string]
|
||||
Zone psql.WhereNullMod[Q, string]
|
||||
Reviewed psql.WhereNullMod[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum]
|
||||
Reviewed psql.WhereNullMod[Q, int16]
|
||||
Reviewedby psql.WhereNullMod[Q, string]
|
||||
Revieweddate psql.WhereNullMod[Q, time.Time]
|
||||
Zone2 psql.WhereNullMod[Q, string]
|
||||
Completeddate psql.WhereNullMod[Q, time.Time]
|
||||
Completedby psql.WhereNullMod[Q, string]
|
||||
Completed psql.WhereNullMod[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum]
|
||||
Issprayroute psql.WhereNullMod[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum]
|
||||
Completed psql.WhereNullMod[Q, int16]
|
||||
Issprayroute psql.WhereNullMod[Q, int16]
|
||||
Name psql.WhereNullMod[Q, string]
|
||||
Acres psql.WhereNullMod[Q, float64]
|
||||
Globalid psql.WhereNullMod[Q, uuid.UUID]
|
||||
Exported psql.WhereNullMod[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum]
|
||||
Exported psql.WhereNullMod[Q, int16]
|
||||
Targetproduct psql.WhereNullMod[Q, string]
|
||||
Targetapprate psql.WhereNullMod[Q, float64]
|
||||
Hectares psql.WhereNullMod[Q, float64]
|
||||
|
|
@ -1157,7 +1318,7 @@ type fieldseekerProposedtreatmentareaWhere[Q psql.Filterable] struct {
|
|||
Lasttreatproduct psql.WhereNullMod[Q, string]
|
||||
Lasttreatqty psql.WhereNullMod[Q, float64]
|
||||
Lasttreatqtyunit psql.WhereNullMod[Q, string]
|
||||
Priority psql.WhereNullMod[Q, enums.FieldseekerProposedtreatmentareaLocationpriorityEnum]
|
||||
Priority psql.WhereNullMod[Q, string]
|
||||
Duedate psql.WhereNullMod[Q, time.Time]
|
||||
Creationdate psql.WhereNullMod[Q, time.Time]
|
||||
Creator psql.WhereNullMod[Q, string]
|
||||
|
|
@ -1166,7 +1327,10 @@ type fieldseekerProposedtreatmentareaWhere[Q psql.Filterable] struct {
|
|||
Targetspecies 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 (fieldseekerProposedtreatmentareaWhere[Q]) AliasedAs(alias string) fieldseekerProposedtreatmentareaWhere[Q] {
|
||||
|
|
@ -1176,21 +1340,21 @@ func (fieldseekerProposedtreatmentareaWhere[Q]) AliasedAs(alias string) fieldsee
|
|||
func buildFieldseekerProposedtreatmentareaWhere[Q psql.Filterable](cols fieldseekerProposedtreatmentareaColumns) fieldseekerProposedtreatmentareaWhere[Q] {
|
||||
return fieldseekerProposedtreatmentareaWhere[Q]{
|
||||
Objectid: psql.Where[Q, int64](cols.Objectid),
|
||||
Method: psql.WhereNull[Q, enums.FieldseekerProposedtreatmentareaMosquitotreatmentmethodEnum](cols.Method),
|
||||
Method: psql.WhereNull[Q, string](cols.Method),
|
||||
Comments: psql.WhereNull[Q, string](cols.Comments),
|
||||
Zone: psql.WhereNull[Q, string](cols.Zone),
|
||||
Reviewed: psql.WhereNull[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum](cols.Reviewed),
|
||||
Reviewed: psql.WhereNull[Q, int16](cols.Reviewed),
|
||||
Reviewedby: psql.WhereNull[Q, string](cols.Reviewedby),
|
||||
Revieweddate: psql.WhereNull[Q, time.Time](cols.Revieweddate),
|
||||
Zone2: psql.WhereNull[Q, string](cols.Zone2),
|
||||
Completeddate: psql.WhereNull[Q, time.Time](cols.Completeddate),
|
||||
Completedby: psql.WhereNull[Q, string](cols.Completedby),
|
||||
Completed: psql.WhereNull[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum](cols.Completed),
|
||||
Issprayroute: psql.WhereNull[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum](cols.Issprayroute),
|
||||
Completed: psql.WhereNull[Q, int16](cols.Completed),
|
||||
Issprayroute: psql.WhereNull[Q, int16](cols.Issprayroute),
|
||||
Name: psql.WhereNull[Q, string](cols.Name),
|
||||
Acres: psql.WhereNull[Q, float64](cols.Acres),
|
||||
Globalid: psql.WhereNull[Q, uuid.UUID](cols.Globalid),
|
||||
Exported: psql.WhereNull[Q, enums.FieldseekerProposedtreatmentareaNotinuitFEnum](cols.Exported),
|
||||
Exported: psql.WhereNull[Q, int16](cols.Exported),
|
||||
Targetproduct: psql.WhereNull[Q, string](cols.Targetproduct),
|
||||
Targetapprate: psql.WhereNull[Q, float64](cols.Targetapprate),
|
||||
Hectares: psql.WhereNull[Q, float64](cols.Hectares),
|
||||
|
|
@ -1199,7 +1363,7 @@ func buildFieldseekerProposedtreatmentareaWhere[Q psql.Filterable](cols fieldsee
|
|||
Lasttreatproduct: psql.WhereNull[Q, string](cols.Lasttreatproduct),
|
||||
Lasttreatqty: psql.WhereNull[Q, float64](cols.Lasttreatqty),
|
||||
Lasttreatqtyunit: psql.WhereNull[Q, string](cols.Lasttreatqtyunit),
|
||||
Priority: psql.WhereNull[Q, enums.FieldseekerProposedtreatmentareaLocationpriorityEnum](cols.Priority),
|
||||
Priority: psql.WhereNull[Q, string](cols.Priority),
|
||||
Duedate: psql.WhereNull[Q, time.Time](cols.Duedate),
|
||||
Creationdate: psql.WhereNull[Q, time.Time](cols.Creationdate),
|
||||
Creator: psql.WhereNull[Q, string](cols.Creator),
|
||||
|
|
@ -1208,6 +1372,154 @@ func buildFieldseekerProposedtreatmentareaWhere[Q psql.Filterable](cols fieldsee
|
|||
Targetspecies: psql.WhereNull[Q, string](cols.Targetspecies),
|
||||
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 *FieldseekerProposedtreatmentarea) Preload(name string, retrieved any) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch name {
|
||||
case "Organization":
|
||||
rel, ok := retrieved.(*Organization)
|
||||
if !ok {
|
||||
return fmt.Errorf("fieldseekerProposedtreatmentarea cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Organization = rel
|
||||
|
||||
if rel != nil {
|
||||
rel.R.Proposedtreatmentareas = FieldseekerProposedtreatmentareaSlice{o}
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("fieldseekerProposedtreatmentarea has no relationship %q", name)
|
||||
}
|
||||
}
|
||||
|
||||
type fieldseekerProposedtreatmentareaPreloader struct {
|
||||
Organization func(...psql.PreloadOption) psql.Preloader
|
||||
}
|
||||
|
||||
func buildFieldseekerProposedtreatmentareaPreloader() fieldseekerProposedtreatmentareaPreloader {
|
||||
return fieldseekerProposedtreatmentareaPreloader{
|
||||
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
||||
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
||||
Name: "Organization",
|
||||
Sides: []psql.PreloadSide{
|
||||
{
|
||||
From: FieldseekerProposedtreatmentareas,
|
||||
To: Organizations,
|
||||
FromColumns: []string{"organization_id"},
|
||||
ToColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
}, Organizations.Columns.Names(), opts...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type fieldseekerProposedtreatmentareaThenLoader[Q orm.Loadable] struct {
|
||||
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildFieldseekerProposedtreatmentareaThenLoader[Q orm.Loadable]() fieldseekerProposedtreatmentareaThenLoader[Q] {
|
||||
type OrganizationLoadInterface interface {
|
||||
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
||||
return fieldseekerProposedtreatmentareaThenLoader[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 fieldseekerProposedtreatmentarea's Organization into the .R struct
|
||||
func (o *FieldseekerProposedtreatmentarea) 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.Proposedtreatmentareas = FieldseekerProposedtreatmentareaSlice{o}
|
||||
|
||||
o.R.Organization = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadOrganization loads the fieldseekerProposedtreatmentarea's Organization into the .R struct
|
||||
func (os FieldseekerProposedtreatmentareaSlice) 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.Proposedtreatmentareas = append(rel.R.Proposedtreatmentareas, o)
|
||||
|
||||
o.R.Organization = rel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type fieldseekerProposedtreatmentareaJoins[Q dialect.Joinable] struct {
|
||||
typ string
|
||||
Organization modAs[Q, organizationColumns]
|
||||
}
|
||||
|
||||
func (j fieldseekerProposedtreatmentareaJoins[Q]) aliasedAs(alias string) fieldseekerProposedtreatmentareaJoins[Q] {
|
||||
return buildFieldseekerProposedtreatmentareaJoins[Q](buildFieldseekerProposedtreatmentareaColumns(alias), j.typ)
|
||||
}
|
||||
|
||||
func buildFieldseekerProposedtreatmentareaJoins[Q dialect.Joinable](cols fieldseekerProposedtreatmentareaColumns, typ string) fieldseekerProposedtreatmentareaJoins[Q] {
|
||||
return fieldseekerProposedtreatmentareaJoins[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