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,35 +21,57 @@ 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"
|
||||
)
|
||||
|
||||
// FieldseekerStormdrain is an object representing the database table.
|
||||
type FieldseekerStormdrain struct {
|
||||
Objectid int64 `db:"objectid,pk" `
|
||||
Nexttreatmentdate null.Val[time.Time] `db:"nexttreatmentdate" `
|
||||
Lasttreatdate null.Val[time.Time] `db:"lasttreatdate" `
|
||||
Lastaction null.Val[string] `db:"lastaction" `
|
||||
Symbology null.Val[enums.FieldseekerStormdrainStormdrainsymbologyEnum] `db:"symbology" `
|
||||
Globalid null.Val[uuid.UUID] `db:"globalid" `
|
||||
CreatedUser null.Val[string] `db:"created_user" `
|
||||
CreatedDate null.Val[time.Time] `db:"created_date" `
|
||||
LastEditedUser null.Val[string] `db:"last_edited_user" `
|
||||
LastEditedDate null.Val[time.Time] `db:"last_edited_date" `
|
||||
Laststatus null.Val[string] `db:"laststatus" `
|
||||
// Zone
|
||||
Objectid int64 `db:"objectid,pk" `
|
||||
// Original attribute from ArcGIS API is NextTreatmentDate
|
||||
Nexttreatmentdate null.Val[time.Time] `db:"nexttreatmentdate" `
|
||||
// Original attribute from ArcGIS API is LastTreatDate
|
||||
Lasttreatdate null.Val[time.Time] `db:"lasttreatdate" `
|
||||
// Original attribute from ArcGIS API is LastAction
|
||||
Lastaction null.Val[string] `db:"lastaction" `
|
||||
// Original attribute from ArcGIS API is Symbology
|
||||
Symbology null.Val[string] `db:"symbology" `
|
||||
// Original attribute from ArcGIS API is GlobalID
|
||||
Globalid null.Val[uuid.UUID] `db:"globalid" `
|
||||
// Original attribute from ArcGIS API is created_user
|
||||
CreatedUser null.Val[string] `db:"created_user" `
|
||||
// Original attribute from ArcGIS API is created_date
|
||||
CreatedDate null.Val[time.Time] `db:"created_date" `
|
||||
// Original attribute from ArcGIS API is last_edited_user
|
||||
LastEditedUser null.Val[string] `db:"last_edited_user" `
|
||||
// Original attribute from ArcGIS API is last_edited_date
|
||||
LastEditedDate null.Val[time.Time] `db:"last_edited_date" `
|
||||
// Original attribute from ArcGIS API is LastStatus
|
||||
Laststatus null.Val[string] `db:"laststatus" `
|
||||
// Original attribute from ArcGIS API is ZONE
|
||||
Zone null.Val[string] `db:"zone" `
|
||||
// Zone2
|
||||
Zone2 null.Val[string] `db:"zone2" `
|
||||
// Original attribute from ArcGIS API is ZONE2
|
||||
Zone2 null.Val[string] `db:"zone2" `
|
||||
// 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" `
|
||||
// Type
|
||||
// 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 TYPE
|
||||
Type null.Val[string] `db:"type" `
|
||||
// Jurisdiction
|
||||
Jurisdiction null.Val[string] `db:"jurisdiction" `
|
||||
// Tracks version changes to the row. Increases when data is modified.
|
||||
Version int32 `db:"version,pk" `
|
||||
// Original attribute from ArcGIS API is JURISDICTION
|
||||
Jurisdiction null.Val[string] `db:"jurisdiction" `
|
||||
Geometry types.JSON[json.RawMessage] `db:"geometry" `
|
||||
Geospatial null.Val[string] `db:"geospatial" `
|
||||
Version int32 `db:"version,pk" `
|
||||
OrganizationID int32 `db:"organization_id" `
|
||||
|
||||
R fieldseekerStormdrainR `db:"-" `
|
||||
}
|
||||
|
||||
// FieldseekerStormdrainSlice is an alias for a slice of pointers to FieldseekerStormdrain.
|
||||
|
|
@ -61,10 +84,15 @@ var FieldseekerStormdrains = psql.NewTablex[*FieldseekerStormdrain, FieldseekerS
|
|||
// FieldseekerStormdrainsQuery is a query on the stormdrain table
|
||||
type FieldseekerStormdrainsQuery = *psql.ViewQuery[*FieldseekerStormdrain, FieldseekerStormdrainSlice]
|
||||
|
||||
// fieldseekerStormdrainR is where relationships are stored.
|
||||
type fieldseekerStormdrainR struct {
|
||||
Organization *Organization // fieldseeker.stormdrain.stormdrain_organization_id_fkey
|
||||
}
|
||||
|
||||
func buildFieldseekerStormdrainColumns(alias string) fieldseekerStormdrainColumns {
|
||||
return fieldseekerStormdrainColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"objectid", "nexttreatmentdate", "lasttreatdate", "lastaction", "symbology", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "laststatus", "zone", "zone2", "creationdate", "creator", "editdate", "editor", "type", "jurisdiction", "version",
|
||||
"objectid", "nexttreatmentdate", "lasttreatdate", "lastaction", "symbology", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "laststatus", "zone", "zone2", "creationdate", "creator", "editdate", "editor", "type", "jurisdiction", "geometry", "geospatial", "version", "organization_id",
|
||||
).WithParent("fieldseeker.stormdrain"),
|
||||
tableAlias: alias,
|
||||
Objectid: psql.Quote(alias, "objectid"),
|
||||
|
|
@ -86,7 +114,10 @@ func buildFieldseekerStormdrainColumns(alias string) fieldseekerStormdrainColumn
|
|||
Editor: psql.Quote(alias, "editor"),
|
||||
Type: psql.Quote(alias, "type"),
|
||||
Jurisdiction: psql.Quote(alias, "jurisdiction"),
|
||||
Geometry: psql.Quote(alias, "geometry"),
|
||||
Geospatial: psql.Quote(alias, "geospatial"),
|
||||
Version: psql.Quote(alias, "version"),
|
||||
OrganizationID: psql.Quote(alias, "organization_id"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +143,10 @@ type fieldseekerStormdrainColumns struct {
|
|||
Editor psql.Expression
|
||||
Type psql.Expression
|
||||
Jurisdiction psql.Expression
|
||||
Geometry psql.Expression
|
||||
Geospatial psql.Expression
|
||||
Version psql.Expression
|
||||
OrganizationID psql.Expression
|
||||
}
|
||||
|
||||
func (c fieldseekerStormdrainColumns) Alias() string {
|
||||
|
|
@ -127,30 +161,33 @@ func (fieldseekerStormdrainColumns) AliasedAs(alias string) fieldseekerStormdrai
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type FieldseekerStormdrainSetter struct {
|
||||
Objectid omit.Val[int64] `db:"objectid,pk" `
|
||||
Nexttreatmentdate omitnull.Val[time.Time] `db:"nexttreatmentdate" `
|
||||
Lasttreatdate omitnull.Val[time.Time] `db:"lasttreatdate" `
|
||||
Lastaction omitnull.Val[string] `db:"lastaction" `
|
||||
Symbology omitnull.Val[enums.FieldseekerStormdrainStormdrainsymbologyEnum] `db:"symbology" `
|
||||
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
|
||||
CreatedUser omitnull.Val[string] `db:"created_user" `
|
||||
CreatedDate omitnull.Val[time.Time] `db:"created_date" `
|
||||
LastEditedUser omitnull.Val[string] `db:"last_edited_user" `
|
||||
LastEditedDate omitnull.Val[time.Time] `db:"last_edited_date" `
|
||||
Laststatus omitnull.Val[string] `db:"laststatus" `
|
||||
Zone omitnull.Val[string] `db:"zone" `
|
||||
Zone2 omitnull.Val[string] `db:"zone2" `
|
||||
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" `
|
||||
Type omitnull.Val[string] `db:"type" `
|
||||
Jurisdiction omitnull.Val[string] `db:"jurisdiction" `
|
||||
Version omit.Val[int32] `db:"version,pk" `
|
||||
Objectid omit.Val[int64] `db:"objectid,pk" `
|
||||
Nexttreatmentdate omitnull.Val[time.Time] `db:"nexttreatmentdate" `
|
||||
Lasttreatdate omitnull.Val[time.Time] `db:"lasttreatdate" `
|
||||
Lastaction omitnull.Val[string] `db:"lastaction" `
|
||||
Symbology omitnull.Val[string] `db:"symbology" `
|
||||
Globalid omitnull.Val[uuid.UUID] `db:"globalid" `
|
||||
CreatedUser omitnull.Val[string] `db:"created_user" `
|
||||
CreatedDate omitnull.Val[time.Time] `db:"created_date" `
|
||||
LastEditedUser omitnull.Val[string] `db:"last_edited_user" `
|
||||
LastEditedDate omitnull.Val[time.Time] `db:"last_edited_date" `
|
||||
Laststatus omitnull.Val[string] `db:"laststatus" `
|
||||
Zone omitnull.Val[string] `db:"zone" `
|
||||
Zone2 omitnull.Val[string] `db:"zone2" `
|
||||
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" `
|
||||
Type omitnull.Val[string] `db:"type" `
|
||||
Jurisdiction omitnull.Val[string] `db:"jurisdiction" `
|
||||
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 FieldseekerStormdrainSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 20)
|
||||
vals := make([]string, 0, 23)
|
||||
if s.Objectid.IsValue() {
|
||||
vals = append(vals, "objectid")
|
||||
}
|
||||
|
|
@ -208,9 +245,18 @@ func (s FieldseekerStormdrainSetter) SetColumns() []string {
|
|||
if !s.Jurisdiction.IsUnset() {
|
||||
vals = append(vals, "jurisdiction")
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -272,9 +318,18 @@ func (s FieldseekerStormdrainSetter) Overwrite(t *FieldseekerStormdrain) {
|
|||
if !s.Jurisdiction.IsUnset() {
|
||||
t.Jurisdiction = s.Jurisdiction.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 *FieldseekerStormdrainSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -283,7 +338,7 @@ func (s *FieldseekerStormdrainSetter) 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, 20)
|
||||
vals := make([]bob.Expression, 23)
|
||||
if s.Objectid.IsValue() {
|
||||
vals[0] = psql.Arg(s.Objectid.MustGet())
|
||||
} else {
|
||||
|
|
@ -398,12 +453,30 @@ func (s *FieldseekerStormdrainSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[18] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Version.IsValue() {
|
||||
vals[19] = psql.Arg(s.Version.MustGet())
|
||||
if s.Geometry.IsValue() {
|
||||
vals[19] = psql.Arg(s.Geometry.MustGet())
|
||||
} else {
|
||||
vals[19] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Geospatial.IsUnset() {
|
||||
vals[20] = psql.Arg(s.Geospatial.MustGetNull())
|
||||
} else {
|
||||
vals[20] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Version.IsValue() {
|
||||
vals[21] = psql.Arg(s.Version.MustGet())
|
||||
} else {
|
||||
vals[21] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.OrganizationID.IsValue() {
|
||||
vals[22] = psql.Arg(s.OrganizationID.MustGet())
|
||||
} else {
|
||||
vals[22] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -413,7 +486,7 @@ func (s FieldseekerStormdrainSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s FieldseekerStormdrainSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 20)
|
||||
exprs := make([]bob.Expression, 0, 23)
|
||||
|
||||
if s.Objectid.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -548,6 +621,20 @@ func (s FieldseekerStormdrainSetter) Expressions(prefix ...string) []bob.Express
|
|||
}})
|
||||
}
|
||||
|
||||
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")...),
|
||||
|
|
@ -555,6 +642,13 @@ func (s FieldseekerStormdrainSetter) Expressions(prefix ...string) []bob.Express
|
|||
}})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -622,6 +716,7 @@ func (o *FieldseekerStormdrain) Update(ctx context.Context, exec bob.Executor, s
|
|||
return err
|
||||
}
|
||||
|
||||
o.R = v.R
|
||||
*o = *v
|
||||
|
||||
return nil
|
||||
|
|
@ -642,7 +737,7 @@ func (o *FieldseekerStormdrain) Reload(ctx context.Context, exec bob.Executor) e
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o2.R = o.R
|
||||
*o = *o2
|
||||
|
||||
return nil
|
||||
|
|
@ -692,7 +787,7 @@ func (o FieldseekerStormdrainSlice) copyMatchingRows(from ...*FieldseekerStormdr
|
|||
if new.Version != old.Version {
|
||||
continue
|
||||
}
|
||||
|
||||
new.R = old.R
|
||||
o[i] = new
|
||||
break
|
||||
}
|
||||
|
|
@ -790,12 +885,84 @@ func (o FieldseekerStormdrainSlice) ReloadAll(ctx context.Context, exec bob.Exec
|
|||
return nil
|
||||
}
|
||||
|
||||
// Organization starts a query for related objects on organization
|
||||
func (o *FieldseekerStormdrain) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
||||
return Organizations.Query(append(mods,
|
||||
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os FieldseekerStormdrainSlice) 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 attachFieldseekerStormdrainOrganization0(ctx context.Context, exec bob.Executor, count int, fieldseekerStormdrain0 *FieldseekerStormdrain, organization1 *Organization) (*FieldseekerStormdrain, error) {
|
||||
setter := &FieldseekerStormdrainSetter{
|
||||
OrganizationID: omit.From(organization1.ID),
|
||||
}
|
||||
|
||||
err := fieldseekerStormdrain0.Update(ctx, exec, setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachFieldseekerStormdrainOrganization0: %w", err)
|
||||
}
|
||||
|
||||
return fieldseekerStormdrain0, nil
|
||||
}
|
||||
|
||||
func (fieldseekerStormdrain0 *FieldseekerStormdrain) 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 = attachFieldseekerStormdrainOrganization0(ctx, exec, 1, fieldseekerStormdrain0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fieldseekerStormdrain0.R.Organization = organization1
|
||||
|
||||
organization1.R.Stormdrains = append(organization1.R.Stormdrains, fieldseekerStormdrain0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fieldseekerStormdrain0 *FieldseekerStormdrain) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
||||
var err error
|
||||
|
||||
_, err = attachFieldseekerStormdrainOrganization0(ctx, exec, 1, fieldseekerStormdrain0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fieldseekerStormdrain0.R.Organization = organization1
|
||||
|
||||
organization1.R.Stormdrains = append(organization1.R.Stormdrains, fieldseekerStormdrain0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type fieldseekerStormdrainWhere[Q psql.Filterable] struct {
|
||||
Objectid psql.WhereMod[Q, int64]
|
||||
Nexttreatmentdate psql.WhereNullMod[Q, time.Time]
|
||||
Lasttreatdate psql.WhereNullMod[Q, time.Time]
|
||||
Lastaction psql.WhereNullMod[Q, string]
|
||||
Symbology psql.WhereNullMod[Q, enums.FieldseekerStormdrainStormdrainsymbologyEnum]
|
||||
Symbology psql.WhereNullMod[Q, string]
|
||||
Globalid psql.WhereNullMod[Q, uuid.UUID]
|
||||
CreatedUser psql.WhereNullMod[Q, string]
|
||||
CreatedDate psql.WhereNullMod[Q, time.Time]
|
||||
|
|
@ -810,7 +977,10 @@ type fieldseekerStormdrainWhere[Q psql.Filterable] struct {
|
|||
Editor psql.WhereNullMod[Q, string]
|
||||
Type psql.WhereNullMod[Q, string]
|
||||
Jurisdiction 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 (fieldseekerStormdrainWhere[Q]) AliasedAs(alias string) fieldseekerStormdrainWhere[Q] {
|
||||
|
|
@ -823,7 +993,7 @@ func buildFieldseekerStormdrainWhere[Q psql.Filterable](cols fieldseekerStormdra
|
|||
Nexttreatmentdate: psql.WhereNull[Q, time.Time](cols.Nexttreatmentdate),
|
||||
Lasttreatdate: psql.WhereNull[Q, time.Time](cols.Lasttreatdate),
|
||||
Lastaction: psql.WhereNull[Q, string](cols.Lastaction),
|
||||
Symbology: psql.WhereNull[Q, enums.FieldseekerStormdrainStormdrainsymbologyEnum](cols.Symbology),
|
||||
Symbology: psql.WhereNull[Q, string](cols.Symbology),
|
||||
Globalid: psql.WhereNull[Q, uuid.UUID](cols.Globalid),
|
||||
CreatedUser: psql.WhereNull[Q, string](cols.CreatedUser),
|
||||
CreatedDate: psql.WhereNull[Q, time.Time](cols.CreatedDate),
|
||||
|
|
@ -838,6 +1008,154 @@ func buildFieldseekerStormdrainWhere[Q psql.Filterable](cols fieldseekerStormdra
|
|||
Editor: psql.WhereNull[Q, string](cols.Editor),
|
||||
Type: psql.WhereNull[Q, string](cols.Type),
|
||||
Jurisdiction: psql.WhereNull[Q, string](cols.Jurisdiction),
|
||||
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 *FieldseekerStormdrain) Preload(name string, retrieved any) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch name {
|
||||
case "Organization":
|
||||
rel, ok := retrieved.(*Organization)
|
||||
if !ok {
|
||||
return fmt.Errorf("fieldseekerStormdrain cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Organization = rel
|
||||
|
||||
if rel != nil {
|
||||
rel.R.Stormdrains = FieldseekerStormdrainSlice{o}
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("fieldseekerStormdrain has no relationship %q", name)
|
||||
}
|
||||
}
|
||||
|
||||
type fieldseekerStormdrainPreloader struct {
|
||||
Organization func(...psql.PreloadOption) psql.Preloader
|
||||
}
|
||||
|
||||
func buildFieldseekerStormdrainPreloader() fieldseekerStormdrainPreloader {
|
||||
return fieldseekerStormdrainPreloader{
|
||||
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
||||
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
||||
Name: "Organization",
|
||||
Sides: []psql.PreloadSide{
|
||||
{
|
||||
From: FieldseekerStormdrains,
|
||||
To: Organizations,
|
||||
FromColumns: []string{"organization_id"},
|
||||
ToColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
}, Organizations.Columns.Names(), opts...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type fieldseekerStormdrainThenLoader[Q orm.Loadable] struct {
|
||||
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildFieldseekerStormdrainThenLoader[Q orm.Loadable]() fieldseekerStormdrainThenLoader[Q] {
|
||||
type OrganizationLoadInterface interface {
|
||||
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
||||
return fieldseekerStormdrainThenLoader[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 fieldseekerStormdrain's Organization into the .R struct
|
||||
func (o *FieldseekerStormdrain) 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.Stormdrains = FieldseekerStormdrainSlice{o}
|
||||
|
||||
o.R.Organization = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadOrganization loads the fieldseekerStormdrain's Organization into the .R struct
|
||||
func (os FieldseekerStormdrainSlice) 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.Stormdrains = append(rel.R.Stormdrains, o)
|
||||
|
||||
o.R.Organization = rel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type fieldseekerStormdrainJoins[Q dialect.Joinable] struct {
|
||||
typ string
|
||||
Organization modAs[Q, organizationColumns]
|
||||
}
|
||||
|
||||
func (j fieldseekerStormdrainJoins[Q]) aliasedAs(alias string) fieldseekerStormdrainJoins[Q] {
|
||||
return buildFieldseekerStormdrainJoins[Q](buildFieldseekerStormdrainColumns(alias), j.typ)
|
||||
}
|
||||
|
||||
func buildFieldseekerStormdrainJoins[Q dialect.Joinable](cols fieldseekerStormdrainColumns, typ string) fieldseekerStormdrainJoins[Q] {
|
||||
return fieldseekerStormdrainJoins[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