This is an intermediate step between shifting from the old fs_* prefixed table names to an entire fieldseeker schema. At this point we have both, and we aren't doing much with the new schema but compiling.
1740 lines
55 KiB
Go
1740 lines
55 KiB
Go
// Code generated by BobGen psql v0.42.0. DO NOT EDIT.
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
package models
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/aarondl/opt/null"
|
|
"github.com/aarondl/opt/omit"
|
|
"github.com/aarondl/opt/omitnull"
|
|
"github.com/stephenafamo/bob"
|
|
"github.com/stephenafamo/bob/dialect/psql"
|
|
"github.com/stephenafamo/bob/dialect/psql/dialect"
|
|
"github.com/stephenafamo/bob/dialect/psql/dm"
|
|
"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/pgtypes"
|
|
)
|
|
|
|
// HistoryTrapdatum is an object representing the database table.
|
|
type HistoryTrapdatum struct {
|
|
OrganizationID int32 `db:"organization_id" `
|
|
Avetemp null.Val[float64] `db:"avetemp" `
|
|
Comments null.Val[string] `db:"comments" `
|
|
Creationdate null.Val[int64] `db:"creationdate" `
|
|
Creator null.Val[string] `db:"creator" `
|
|
Enddatetime null.Val[int64] `db:"enddatetime" `
|
|
Editdate null.Val[int64] `db:"editdate" `
|
|
Editor null.Val[string] `db:"editor" `
|
|
Fieldtech null.Val[string] `db:"fieldtech" `
|
|
Field null.Val[int64] `db:"field" `
|
|
Gatewaysync null.Val[int16] `db:"gatewaysync" `
|
|
Globalid null.Val[string] `db:"globalid" `
|
|
Idbytech null.Val[string] `db:"idbytech" `
|
|
Locationname null.Val[string] `db:"locationname" `
|
|
LocID null.Val[string] `db:"loc_id" `
|
|
LR null.Val[int16] `db:"lr" `
|
|
Objectid int32 `db:"objectid,pk" `
|
|
Processed null.Val[int16] `db:"processed" `
|
|
Raingauge null.Val[float64] `db:"raingauge" `
|
|
Recordstatus null.Val[int16] `db:"recordstatus" `
|
|
Reviewed null.Val[int16] `db:"reviewed" `
|
|
Reviewedby null.Val[string] `db:"reviewedby" `
|
|
Revieweddate null.Val[int64] `db:"revieweddate" `
|
|
Sitecond null.Val[string] `db:"sitecond" `
|
|
Sortbytech null.Val[string] `db:"sortbytech" `
|
|
Srid null.Val[string] `db:"srid" `
|
|
Startdatetime null.Val[int64] `db:"startdatetime" `
|
|
Trapactivitytype null.Val[string] `db:"trapactivitytype" `
|
|
Trapcondition null.Val[string] `db:"trapcondition" `
|
|
Trapnights null.Val[int16] `db:"trapnights" `
|
|
Traptype null.Val[string] `db:"traptype" `
|
|
Voltage null.Val[float64] `db:"voltage" `
|
|
Winddir null.Val[string] `db:"winddir" `
|
|
Windspeed null.Val[float64] `db:"windspeed" `
|
|
Zone null.Val[string] `db:"zone" `
|
|
Zone2 null.Val[string] `db:"zone2" `
|
|
Created null.Val[time.Time] `db:"created" `
|
|
CreatedDate null.Val[int64] `db:"created_date" `
|
|
CreatedUser null.Val[string] `db:"created_user" `
|
|
GeometryX null.Val[float64] `db:"geometry_x" `
|
|
GeometryY null.Val[float64] `db:"geometry_y" `
|
|
LastEditedDate null.Val[int64] `db:"last_edited_date" `
|
|
LastEditedUser null.Val[string] `db:"last_edited_user" `
|
|
Lure null.Val[string] `db:"lure" `
|
|
Vectorsurvtrapdataid null.Val[string] `db:"vectorsurvtrapdataid" `
|
|
Vectorsurvtraplocationid null.Val[string] `db:"vectorsurvtraplocationid" `
|
|
Version int32 `db:"version,pk" `
|
|
|
|
R historyTrapdatumR `db:"-" `
|
|
}
|
|
|
|
// HistoryTrapdatumSlice is an alias for a slice of pointers to HistoryTrapdatum.
|
|
// This should almost always be used instead of []*HistoryTrapdatum.
|
|
type HistoryTrapdatumSlice []*HistoryTrapdatum
|
|
|
|
// HistoryTrapdata contains methods to work with the history_trapdata table
|
|
var HistoryTrapdata = psql.NewTablex[*HistoryTrapdatum, HistoryTrapdatumSlice, *HistoryTrapdatumSetter]("", "history_trapdata", buildHistoryTrapdatumColumns("history_trapdata"))
|
|
|
|
// HistoryTrapdataQuery is a query on the history_trapdata table
|
|
type HistoryTrapdataQuery = *psql.ViewQuery[*HistoryTrapdatum, HistoryTrapdatumSlice]
|
|
|
|
// historyTrapdatumR is where relationships are stored.
|
|
type historyTrapdatumR struct {
|
|
Organization *Organization // history_trapdata.history_trapdata_organization_id_fkey
|
|
}
|
|
|
|
func buildHistoryTrapdatumColumns(alias string) historyTrapdatumColumns {
|
|
return historyTrapdatumColumns{
|
|
ColumnsExpr: expr.NewColumnsExpr(
|
|
"organization_id", "avetemp", "comments", "creationdate", "creator", "enddatetime", "editdate", "editor", "fieldtech", "field", "gatewaysync", "globalid", "idbytech", "locationname", "loc_id", "lr", "objectid", "processed", "raingauge", "recordstatus", "reviewed", "reviewedby", "revieweddate", "sitecond", "sortbytech", "srid", "startdatetime", "trapactivitytype", "trapcondition", "trapnights", "traptype", "voltage", "winddir", "windspeed", "zone", "zone2", "created", "created_date", "created_user", "geometry_x", "geometry_y", "last_edited_date", "last_edited_user", "lure", "vectorsurvtrapdataid", "vectorsurvtraplocationid", "version",
|
|
).WithParent("history_trapdata"),
|
|
tableAlias: alias,
|
|
OrganizationID: psql.Quote(alias, "organization_id"),
|
|
Avetemp: psql.Quote(alias, "avetemp"),
|
|
Comments: psql.Quote(alias, "comments"),
|
|
Creationdate: psql.Quote(alias, "creationdate"),
|
|
Creator: psql.Quote(alias, "creator"),
|
|
Enddatetime: psql.Quote(alias, "enddatetime"),
|
|
Editdate: psql.Quote(alias, "editdate"),
|
|
Editor: psql.Quote(alias, "editor"),
|
|
Fieldtech: psql.Quote(alias, "fieldtech"),
|
|
Field: psql.Quote(alias, "field"),
|
|
Gatewaysync: psql.Quote(alias, "gatewaysync"),
|
|
Globalid: psql.Quote(alias, "globalid"),
|
|
Idbytech: psql.Quote(alias, "idbytech"),
|
|
Locationname: psql.Quote(alias, "locationname"),
|
|
LocID: psql.Quote(alias, "loc_id"),
|
|
LR: psql.Quote(alias, "lr"),
|
|
Objectid: psql.Quote(alias, "objectid"),
|
|
Processed: psql.Quote(alias, "processed"),
|
|
Raingauge: psql.Quote(alias, "raingauge"),
|
|
Recordstatus: psql.Quote(alias, "recordstatus"),
|
|
Reviewed: psql.Quote(alias, "reviewed"),
|
|
Reviewedby: psql.Quote(alias, "reviewedby"),
|
|
Revieweddate: psql.Quote(alias, "revieweddate"),
|
|
Sitecond: psql.Quote(alias, "sitecond"),
|
|
Sortbytech: psql.Quote(alias, "sortbytech"),
|
|
Srid: psql.Quote(alias, "srid"),
|
|
Startdatetime: psql.Quote(alias, "startdatetime"),
|
|
Trapactivitytype: psql.Quote(alias, "trapactivitytype"),
|
|
Trapcondition: psql.Quote(alias, "trapcondition"),
|
|
Trapnights: psql.Quote(alias, "trapnights"),
|
|
Traptype: psql.Quote(alias, "traptype"),
|
|
Voltage: psql.Quote(alias, "voltage"),
|
|
Winddir: psql.Quote(alias, "winddir"),
|
|
Windspeed: psql.Quote(alias, "windspeed"),
|
|
Zone: psql.Quote(alias, "zone"),
|
|
Zone2: psql.Quote(alias, "zone2"),
|
|
Created: psql.Quote(alias, "created"),
|
|
CreatedDate: psql.Quote(alias, "created_date"),
|
|
CreatedUser: psql.Quote(alias, "created_user"),
|
|
GeometryX: psql.Quote(alias, "geometry_x"),
|
|
GeometryY: psql.Quote(alias, "geometry_y"),
|
|
LastEditedDate: psql.Quote(alias, "last_edited_date"),
|
|
LastEditedUser: psql.Quote(alias, "last_edited_user"),
|
|
Lure: psql.Quote(alias, "lure"),
|
|
Vectorsurvtrapdataid: psql.Quote(alias, "vectorsurvtrapdataid"),
|
|
Vectorsurvtraplocationid: psql.Quote(alias, "vectorsurvtraplocationid"),
|
|
Version: psql.Quote(alias, "version"),
|
|
}
|
|
}
|
|
|
|
type historyTrapdatumColumns struct {
|
|
expr.ColumnsExpr
|
|
tableAlias string
|
|
OrganizationID psql.Expression
|
|
Avetemp psql.Expression
|
|
Comments psql.Expression
|
|
Creationdate psql.Expression
|
|
Creator psql.Expression
|
|
Enddatetime psql.Expression
|
|
Editdate psql.Expression
|
|
Editor psql.Expression
|
|
Fieldtech psql.Expression
|
|
Field psql.Expression
|
|
Gatewaysync psql.Expression
|
|
Globalid psql.Expression
|
|
Idbytech psql.Expression
|
|
Locationname psql.Expression
|
|
LocID psql.Expression
|
|
LR psql.Expression
|
|
Objectid psql.Expression
|
|
Processed psql.Expression
|
|
Raingauge psql.Expression
|
|
Recordstatus psql.Expression
|
|
Reviewed psql.Expression
|
|
Reviewedby psql.Expression
|
|
Revieweddate psql.Expression
|
|
Sitecond psql.Expression
|
|
Sortbytech psql.Expression
|
|
Srid psql.Expression
|
|
Startdatetime psql.Expression
|
|
Trapactivitytype psql.Expression
|
|
Trapcondition psql.Expression
|
|
Trapnights psql.Expression
|
|
Traptype psql.Expression
|
|
Voltage psql.Expression
|
|
Winddir psql.Expression
|
|
Windspeed psql.Expression
|
|
Zone psql.Expression
|
|
Zone2 psql.Expression
|
|
Created psql.Expression
|
|
CreatedDate psql.Expression
|
|
CreatedUser psql.Expression
|
|
GeometryX psql.Expression
|
|
GeometryY psql.Expression
|
|
LastEditedDate psql.Expression
|
|
LastEditedUser psql.Expression
|
|
Lure psql.Expression
|
|
Vectorsurvtrapdataid psql.Expression
|
|
Vectorsurvtraplocationid psql.Expression
|
|
Version psql.Expression
|
|
}
|
|
|
|
func (c historyTrapdatumColumns) Alias() string {
|
|
return c.tableAlias
|
|
}
|
|
|
|
func (historyTrapdatumColumns) AliasedAs(alias string) historyTrapdatumColumns {
|
|
return buildHistoryTrapdatumColumns(alias)
|
|
}
|
|
|
|
// HistoryTrapdatumSetter is used for insert/upsert/update operations
|
|
// All values are optional, and do not have to be set
|
|
// Generated columns are not included
|
|
type HistoryTrapdatumSetter struct {
|
|
OrganizationID omit.Val[int32] `db:"organization_id" `
|
|
Avetemp omitnull.Val[float64] `db:"avetemp" `
|
|
Comments omitnull.Val[string] `db:"comments" `
|
|
Creationdate omitnull.Val[int64] `db:"creationdate" `
|
|
Creator omitnull.Val[string] `db:"creator" `
|
|
Enddatetime omitnull.Val[int64] `db:"enddatetime" `
|
|
Editdate omitnull.Val[int64] `db:"editdate" `
|
|
Editor omitnull.Val[string] `db:"editor" `
|
|
Fieldtech omitnull.Val[string] `db:"fieldtech" `
|
|
Field omitnull.Val[int64] `db:"field" `
|
|
Gatewaysync omitnull.Val[int16] `db:"gatewaysync" `
|
|
Globalid omitnull.Val[string] `db:"globalid" `
|
|
Idbytech omitnull.Val[string] `db:"idbytech" `
|
|
Locationname omitnull.Val[string] `db:"locationname" `
|
|
LocID omitnull.Val[string] `db:"loc_id" `
|
|
LR omitnull.Val[int16] `db:"lr" `
|
|
Objectid omit.Val[int32] `db:"objectid,pk" `
|
|
Processed omitnull.Val[int16] `db:"processed" `
|
|
Raingauge omitnull.Val[float64] `db:"raingauge" `
|
|
Recordstatus omitnull.Val[int16] `db:"recordstatus" `
|
|
Reviewed omitnull.Val[int16] `db:"reviewed" `
|
|
Reviewedby omitnull.Val[string] `db:"reviewedby" `
|
|
Revieweddate omitnull.Val[int64] `db:"revieweddate" `
|
|
Sitecond omitnull.Val[string] `db:"sitecond" `
|
|
Sortbytech omitnull.Val[string] `db:"sortbytech" `
|
|
Srid omitnull.Val[string] `db:"srid" `
|
|
Startdatetime omitnull.Val[int64] `db:"startdatetime" `
|
|
Trapactivitytype omitnull.Val[string] `db:"trapactivitytype" `
|
|
Trapcondition omitnull.Val[string] `db:"trapcondition" `
|
|
Trapnights omitnull.Val[int16] `db:"trapnights" `
|
|
Traptype omitnull.Val[string] `db:"traptype" `
|
|
Voltage omitnull.Val[float64] `db:"voltage" `
|
|
Winddir omitnull.Val[string] `db:"winddir" `
|
|
Windspeed omitnull.Val[float64] `db:"windspeed" `
|
|
Zone omitnull.Val[string] `db:"zone" `
|
|
Zone2 omitnull.Val[string] `db:"zone2" `
|
|
Created omitnull.Val[time.Time] `db:"created" `
|
|
CreatedDate omitnull.Val[int64] `db:"created_date" `
|
|
CreatedUser omitnull.Val[string] `db:"created_user" `
|
|
GeometryX omitnull.Val[float64] `db:"geometry_x" `
|
|
GeometryY omitnull.Val[float64] `db:"geometry_y" `
|
|
LastEditedDate omitnull.Val[int64] `db:"last_edited_date" `
|
|
LastEditedUser omitnull.Val[string] `db:"last_edited_user" `
|
|
Lure omitnull.Val[string] `db:"lure" `
|
|
Vectorsurvtrapdataid omitnull.Val[string] `db:"vectorsurvtrapdataid" `
|
|
Vectorsurvtraplocationid omitnull.Val[string] `db:"vectorsurvtraplocationid" `
|
|
Version omit.Val[int32] `db:"version,pk" `
|
|
}
|
|
|
|
func (s HistoryTrapdatumSetter) SetColumns() []string {
|
|
vals := make([]string, 0, 47)
|
|
if s.OrganizationID.IsValue() {
|
|
vals = append(vals, "organization_id")
|
|
}
|
|
if !s.Avetemp.IsUnset() {
|
|
vals = append(vals, "avetemp")
|
|
}
|
|
if !s.Comments.IsUnset() {
|
|
vals = append(vals, "comments")
|
|
}
|
|
if !s.Creationdate.IsUnset() {
|
|
vals = append(vals, "creationdate")
|
|
}
|
|
if !s.Creator.IsUnset() {
|
|
vals = append(vals, "creator")
|
|
}
|
|
if !s.Enddatetime.IsUnset() {
|
|
vals = append(vals, "enddatetime")
|
|
}
|
|
if !s.Editdate.IsUnset() {
|
|
vals = append(vals, "editdate")
|
|
}
|
|
if !s.Editor.IsUnset() {
|
|
vals = append(vals, "editor")
|
|
}
|
|
if !s.Fieldtech.IsUnset() {
|
|
vals = append(vals, "fieldtech")
|
|
}
|
|
if !s.Field.IsUnset() {
|
|
vals = append(vals, "field")
|
|
}
|
|
if !s.Gatewaysync.IsUnset() {
|
|
vals = append(vals, "gatewaysync")
|
|
}
|
|
if !s.Globalid.IsUnset() {
|
|
vals = append(vals, "globalid")
|
|
}
|
|
if !s.Idbytech.IsUnset() {
|
|
vals = append(vals, "idbytech")
|
|
}
|
|
if !s.Locationname.IsUnset() {
|
|
vals = append(vals, "locationname")
|
|
}
|
|
if !s.LocID.IsUnset() {
|
|
vals = append(vals, "loc_id")
|
|
}
|
|
if !s.LR.IsUnset() {
|
|
vals = append(vals, "lr")
|
|
}
|
|
if s.Objectid.IsValue() {
|
|
vals = append(vals, "objectid")
|
|
}
|
|
if !s.Processed.IsUnset() {
|
|
vals = append(vals, "processed")
|
|
}
|
|
if !s.Raingauge.IsUnset() {
|
|
vals = append(vals, "raingauge")
|
|
}
|
|
if !s.Recordstatus.IsUnset() {
|
|
vals = append(vals, "recordstatus")
|
|
}
|
|
if !s.Reviewed.IsUnset() {
|
|
vals = append(vals, "reviewed")
|
|
}
|
|
if !s.Reviewedby.IsUnset() {
|
|
vals = append(vals, "reviewedby")
|
|
}
|
|
if !s.Revieweddate.IsUnset() {
|
|
vals = append(vals, "revieweddate")
|
|
}
|
|
if !s.Sitecond.IsUnset() {
|
|
vals = append(vals, "sitecond")
|
|
}
|
|
if !s.Sortbytech.IsUnset() {
|
|
vals = append(vals, "sortbytech")
|
|
}
|
|
if !s.Srid.IsUnset() {
|
|
vals = append(vals, "srid")
|
|
}
|
|
if !s.Startdatetime.IsUnset() {
|
|
vals = append(vals, "startdatetime")
|
|
}
|
|
if !s.Trapactivitytype.IsUnset() {
|
|
vals = append(vals, "trapactivitytype")
|
|
}
|
|
if !s.Trapcondition.IsUnset() {
|
|
vals = append(vals, "trapcondition")
|
|
}
|
|
if !s.Trapnights.IsUnset() {
|
|
vals = append(vals, "trapnights")
|
|
}
|
|
if !s.Traptype.IsUnset() {
|
|
vals = append(vals, "traptype")
|
|
}
|
|
if !s.Voltage.IsUnset() {
|
|
vals = append(vals, "voltage")
|
|
}
|
|
if !s.Winddir.IsUnset() {
|
|
vals = append(vals, "winddir")
|
|
}
|
|
if !s.Windspeed.IsUnset() {
|
|
vals = append(vals, "windspeed")
|
|
}
|
|
if !s.Zone.IsUnset() {
|
|
vals = append(vals, "zone")
|
|
}
|
|
if !s.Zone2.IsUnset() {
|
|
vals = append(vals, "zone2")
|
|
}
|
|
if !s.Created.IsUnset() {
|
|
vals = append(vals, "created")
|
|
}
|
|
if !s.CreatedDate.IsUnset() {
|
|
vals = append(vals, "created_date")
|
|
}
|
|
if !s.CreatedUser.IsUnset() {
|
|
vals = append(vals, "created_user")
|
|
}
|
|
if !s.GeometryX.IsUnset() {
|
|
vals = append(vals, "geometry_x")
|
|
}
|
|
if !s.GeometryY.IsUnset() {
|
|
vals = append(vals, "geometry_y")
|
|
}
|
|
if !s.LastEditedDate.IsUnset() {
|
|
vals = append(vals, "last_edited_date")
|
|
}
|
|
if !s.LastEditedUser.IsUnset() {
|
|
vals = append(vals, "last_edited_user")
|
|
}
|
|
if !s.Lure.IsUnset() {
|
|
vals = append(vals, "lure")
|
|
}
|
|
if !s.Vectorsurvtrapdataid.IsUnset() {
|
|
vals = append(vals, "vectorsurvtrapdataid")
|
|
}
|
|
if !s.Vectorsurvtraplocationid.IsUnset() {
|
|
vals = append(vals, "vectorsurvtraplocationid")
|
|
}
|
|
if s.Version.IsValue() {
|
|
vals = append(vals, "version")
|
|
}
|
|
return vals
|
|
}
|
|
|
|
func (s HistoryTrapdatumSetter) Overwrite(t *HistoryTrapdatum) {
|
|
if s.OrganizationID.IsValue() {
|
|
t.OrganizationID = s.OrganizationID.MustGet()
|
|
}
|
|
if !s.Avetemp.IsUnset() {
|
|
t.Avetemp = s.Avetemp.MustGetNull()
|
|
}
|
|
if !s.Comments.IsUnset() {
|
|
t.Comments = s.Comments.MustGetNull()
|
|
}
|
|
if !s.Creationdate.IsUnset() {
|
|
t.Creationdate = s.Creationdate.MustGetNull()
|
|
}
|
|
if !s.Creator.IsUnset() {
|
|
t.Creator = s.Creator.MustGetNull()
|
|
}
|
|
if !s.Enddatetime.IsUnset() {
|
|
t.Enddatetime = s.Enddatetime.MustGetNull()
|
|
}
|
|
if !s.Editdate.IsUnset() {
|
|
t.Editdate = s.Editdate.MustGetNull()
|
|
}
|
|
if !s.Editor.IsUnset() {
|
|
t.Editor = s.Editor.MustGetNull()
|
|
}
|
|
if !s.Fieldtech.IsUnset() {
|
|
t.Fieldtech = s.Fieldtech.MustGetNull()
|
|
}
|
|
if !s.Field.IsUnset() {
|
|
t.Field = s.Field.MustGetNull()
|
|
}
|
|
if !s.Gatewaysync.IsUnset() {
|
|
t.Gatewaysync = s.Gatewaysync.MustGetNull()
|
|
}
|
|
if !s.Globalid.IsUnset() {
|
|
t.Globalid = s.Globalid.MustGetNull()
|
|
}
|
|
if !s.Idbytech.IsUnset() {
|
|
t.Idbytech = s.Idbytech.MustGetNull()
|
|
}
|
|
if !s.Locationname.IsUnset() {
|
|
t.Locationname = s.Locationname.MustGetNull()
|
|
}
|
|
if !s.LocID.IsUnset() {
|
|
t.LocID = s.LocID.MustGetNull()
|
|
}
|
|
if !s.LR.IsUnset() {
|
|
t.LR = s.LR.MustGetNull()
|
|
}
|
|
if s.Objectid.IsValue() {
|
|
t.Objectid = s.Objectid.MustGet()
|
|
}
|
|
if !s.Processed.IsUnset() {
|
|
t.Processed = s.Processed.MustGetNull()
|
|
}
|
|
if !s.Raingauge.IsUnset() {
|
|
t.Raingauge = s.Raingauge.MustGetNull()
|
|
}
|
|
if !s.Recordstatus.IsUnset() {
|
|
t.Recordstatus = s.Recordstatus.MustGetNull()
|
|
}
|
|
if !s.Reviewed.IsUnset() {
|
|
t.Reviewed = s.Reviewed.MustGetNull()
|
|
}
|
|
if !s.Reviewedby.IsUnset() {
|
|
t.Reviewedby = s.Reviewedby.MustGetNull()
|
|
}
|
|
if !s.Revieweddate.IsUnset() {
|
|
t.Revieweddate = s.Revieweddate.MustGetNull()
|
|
}
|
|
if !s.Sitecond.IsUnset() {
|
|
t.Sitecond = s.Sitecond.MustGetNull()
|
|
}
|
|
if !s.Sortbytech.IsUnset() {
|
|
t.Sortbytech = s.Sortbytech.MustGetNull()
|
|
}
|
|
if !s.Srid.IsUnset() {
|
|
t.Srid = s.Srid.MustGetNull()
|
|
}
|
|
if !s.Startdatetime.IsUnset() {
|
|
t.Startdatetime = s.Startdatetime.MustGetNull()
|
|
}
|
|
if !s.Trapactivitytype.IsUnset() {
|
|
t.Trapactivitytype = s.Trapactivitytype.MustGetNull()
|
|
}
|
|
if !s.Trapcondition.IsUnset() {
|
|
t.Trapcondition = s.Trapcondition.MustGetNull()
|
|
}
|
|
if !s.Trapnights.IsUnset() {
|
|
t.Trapnights = s.Trapnights.MustGetNull()
|
|
}
|
|
if !s.Traptype.IsUnset() {
|
|
t.Traptype = s.Traptype.MustGetNull()
|
|
}
|
|
if !s.Voltage.IsUnset() {
|
|
t.Voltage = s.Voltage.MustGetNull()
|
|
}
|
|
if !s.Winddir.IsUnset() {
|
|
t.Winddir = s.Winddir.MustGetNull()
|
|
}
|
|
if !s.Windspeed.IsUnset() {
|
|
t.Windspeed = s.Windspeed.MustGetNull()
|
|
}
|
|
if !s.Zone.IsUnset() {
|
|
t.Zone = s.Zone.MustGetNull()
|
|
}
|
|
if !s.Zone2.IsUnset() {
|
|
t.Zone2 = s.Zone2.MustGetNull()
|
|
}
|
|
if !s.Created.IsUnset() {
|
|
t.Created = s.Created.MustGetNull()
|
|
}
|
|
if !s.CreatedDate.IsUnset() {
|
|
t.CreatedDate = s.CreatedDate.MustGetNull()
|
|
}
|
|
if !s.CreatedUser.IsUnset() {
|
|
t.CreatedUser = s.CreatedUser.MustGetNull()
|
|
}
|
|
if !s.GeometryX.IsUnset() {
|
|
t.GeometryX = s.GeometryX.MustGetNull()
|
|
}
|
|
if !s.GeometryY.IsUnset() {
|
|
t.GeometryY = s.GeometryY.MustGetNull()
|
|
}
|
|
if !s.LastEditedDate.IsUnset() {
|
|
t.LastEditedDate = s.LastEditedDate.MustGetNull()
|
|
}
|
|
if !s.LastEditedUser.IsUnset() {
|
|
t.LastEditedUser = s.LastEditedUser.MustGetNull()
|
|
}
|
|
if !s.Lure.IsUnset() {
|
|
t.Lure = s.Lure.MustGetNull()
|
|
}
|
|
if !s.Vectorsurvtrapdataid.IsUnset() {
|
|
t.Vectorsurvtrapdataid = s.Vectorsurvtrapdataid.MustGetNull()
|
|
}
|
|
if !s.Vectorsurvtraplocationid.IsUnset() {
|
|
t.Vectorsurvtraplocationid = s.Vectorsurvtraplocationid.MustGetNull()
|
|
}
|
|
if s.Version.IsValue() {
|
|
t.Version = s.Version.MustGet()
|
|
}
|
|
}
|
|
|
|
func (s *HistoryTrapdatumSetter) Apply(q *dialect.InsertQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return HistoryTrapdata.BeforeInsertHooks.RunHooks(ctx, exec, s)
|
|
})
|
|
|
|
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
vals := make([]bob.Expression, 47)
|
|
if s.OrganizationID.IsValue() {
|
|
vals[0] = psql.Arg(s.OrganizationID.MustGet())
|
|
} else {
|
|
vals[0] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Avetemp.IsUnset() {
|
|
vals[1] = psql.Arg(s.Avetemp.MustGetNull())
|
|
} else {
|
|
vals[1] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Comments.IsUnset() {
|
|
vals[2] = psql.Arg(s.Comments.MustGetNull())
|
|
} else {
|
|
vals[2] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Creationdate.IsUnset() {
|
|
vals[3] = psql.Arg(s.Creationdate.MustGetNull())
|
|
} else {
|
|
vals[3] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Creator.IsUnset() {
|
|
vals[4] = psql.Arg(s.Creator.MustGetNull())
|
|
} else {
|
|
vals[4] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Enddatetime.IsUnset() {
|
|
vals[5] = psql.Arg(s.Enddatetime.MustGetNull())
|
|
} else {
|
|
vals[5] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Editdate.IsUnset() {
|
|
vals[6] = psql.Arg(s.Editdate.MustGetNull())
|
|
} else {
|
|
vals[6] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Editor.IsUnset() {
|
|
vals[7] = psql.Arg(s.Editor.MustGetNull())
|
|
} else {
|
|
vals[7] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Fieldtech.IsUnset() {
|
|
vals[8] = psql.Arg(s.Fieldtech.MustGetNull())
|
|
} else {
|
|
vals[8] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Field.IsUnset() {
|
|
vals[9] = psql.Arg(s.Field.MustGetNull())
|
|
} else {
|
|
vals[9] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Gatewaysync.IsUnset() {
|
|
vals[10] = psql.Arg(s.Gatewaysync.MustGetNull())
|
|
} else {
|
|
vals[10] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Globalid.IsUnset() {
|
|
vals[11] = psql.Arg(s.Globalid.MustGetNull())
|
|
} else {
|
|
vals[11] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Idbytech.IsUnset() {
|
|
vals[12] = psql.Arg(s.Idbytech.MustGetNull())
|
|
} else {
|
|
vals[12] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Locationname.IsUnset() {
|
|
vals[13] = psql.Arg(s.Locationname.MustGetNull())
|
|
} else {
|
|
vals[13] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.LocID.IsUnset() {
|
|
vals[14] = psql.Arg(s.LocID.MustGetNull())
|
|
} else {
|
|
vals[14] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.LR.IsUnset() {
|
|
vals[15] = psql.Arg(s.LR.MustGetNull())
|
|
} else {
|
|
vals[15] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Objectid.IsValue() {
|
|
vals[16] = psql.Arg(s.Objectid.MustGet())
|
|
} else {
|
|
vals[16] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Processed.IsUnset() {
|
|
vals[17] = psql.Arg(s.Processed.MustGetNull())
|
|
} else {
|
|
vals[17] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Raingauge.IsUnset() {
|
|
vals[18] = psql.Arg(s.Raingauge.MustGetNull())
|
|
} else {
|
|
vals[18] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Recordstatus.IsUnset() {
|
|
vals[19] = psql.Arg(s.Recordstatus.MustGetNull())
|
|
} else {
|
|
vals[19] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Reviewed.IsUnset() {
|
|
vals[20] = psql.Arg(s.Reviewed.MustGetNull())
|
|
} else {
|
|
vals[20] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Reviewedby.IsUnset() {
|
|
vals[21] = psql.Arg(s.Reviewedby.MustGetNull())
|
|
} else {
|
|
vals[21] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Revieweddate.IsUnset() {
|
|
vals[22] = psql.Arg(s.Revieweddate.MustGetNull())
|
|
} else {
|
|
vals[22] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Sitecond.IsUnset() {
|
|
vals[23] = psql.Arg(s.Sitecond.MustGetNull())
|
|
} else {
|
|
vals[23] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Sortbytech.IsUnset() {
|
|
vals[24] = psql.Arg(s.Sortbytech.MustGetNull())
|
|
} else {
|
|
vals[24] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Srid.IsUnset() {
|
|
vals[25] = psql.Arg(s.Srid.MustGetNull())
|
|
} else {
|
|
vals[25] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Startdatetime.IsUnset() {
|
|
vals[26] = psql.Arg(s.Startdatetime.MustGetNull())
|
|
} else {
|
|
vals[26] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Trapactivitytype.IsUnset() {
|
|
vals[27] = psql.Arg(s.Trapactivitytype.MustGetNull())
|
|
} else {
|
|
vals[27] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Trapcondition.IsUnset() {
|
|
vals[28] = psql.Arg(s.Trapcondition.MustGetNull())
|
|
} else {
|
|
vals[28] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Trapnights.IsUnset() {
|
|
vals[29] = psql.Arg(s.Trapnights.MustGetNull())
|
|
} else {
|
|
vals[29] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Traptype.IsUnset() {
|
|
vals[30] = psql.Arg(s.Traptype.MustGetNull())
|
|
} else {
|
|
vals[30] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Voltage.IsUnset() {
|
|
vals[31] = psql.Arg(s.Voltage.MustGetNull())
|
|
} else {
|
|
vals[31] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Winddir.IsUnset() {
|
|
vals[32] = psql.Arg(s.Winddir.MustGetNull())
|
|
} else {
|
|
vals[32] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Windspeed.IsUnset() {
|
|
vals[33] = psql.Arg(s.Windspeed.MustGetNull())
|
|
} else {
|
|
vals[33] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Zone.IsUnset() {
|
|
vals[34] = psql.Arg(s.Zone.MustGetNull())
|
|
} else {
|
|
vals[34] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Zone2.IsUnset() {
|
|
vals[35] = psql.Arg(s.Zone2.MustGetNull())
|
|
} else {
|
|
vals[35] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Created.IsUnset() {
|
|
vals[36] = psql.Arg(s.Created.MustGetNull())
|
|
} else {
|
|
vals[36] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.CreatedDate.IsUnset() {
|
|
vals[37] = psql.Arg(s.CreatedDate.MustGetNull())
|
|
} else {
|
|
vals[37] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.CreatedUser.IsUnset() {
|
|
vals[38] = psql.Arg(s.CreatedUser.MustGetNull())
|
|
} else {
|
|
vals[38] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.GeometryX.IsUnset() {
|
|
vals[39] = psql.Arg(s.GeometryX.MustGetNull())
|
|
} else {
|
|
vals[39] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.GeometryY.IsUnset() {
|
|
vals[40] = psql.Arg(s.GeometryY.MustGetNull())
|
|
} else {
|
|
vals[40] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.LastEditedDate.IsUnset() {
|
|
vals[41] = psql.Arg(s.LastEditedDate.MustGetNull())
|
|
} else {
|
|
vals[41] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.LastEditedUser.IsUnset() {
|
|
vals[42] = psql.Arg(s.LastEditedUser.MustGetNull())
|
|
} else {
|
|
vals[42] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Lure.IsUnset() {
|
|
vals[43] = psql.Arg(s.Lure.MustGetNull())
|
|
} else {
|
|
vals[43] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Vectorsurvtrapdataid.IsUnset() {
|
|
vals[44] = psql.Arg(s.Vectorsurvtrapdataid.MustGetNull())
|
|
} else {
|
|
vals[44] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Vectorsurvtraplocationid.IsUnset() {
|
|
vals[45] = psql.Arg(s.Vectorsurvtraplocationid.MustGetNull())
|
|
} else {
|
|
vals[45] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Version.IsValue() {
|
|
vals[46] = psql.Arg(s.Version.MustGet())
|
|
} else {
|
|
vals[46] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
|
}))
|
|
}
|
|
|
|
func (s HistoryTrapdatumSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
return um.Set(s.Expressions()...)
|
|
}
|
|
|
|
func (s HistoryTrapdatumSetter) Expressions(prefix ...string) []bob.Expression {
|
|
exprs := make([]bob.Expression, 0, 47)
|
|
|
|
if s.OrganizationID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "organization_id")...),
|
|
psql.Arg(s.OrganizationID),
|
|
}})
|
|
}
|
|
|
|
if !s.Avetemp.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "avetemp")...),
|
|
psql.Arg(s.Avetemp),
|
|
}})
|
|
}
|
|
|
|
if !s.Comments.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "comments")...),
|
|
psql.Arg(s.Comments),
|
|
}})
|
|
}
|
|
|
|
if !s.Creationdate.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "creationdate")...),
|
|
psql.Arg(s.Creationdate),
|
|
}})
|
|
}
|
|
|
|
if !s.Creator.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "creator")...),
|
|
psql.Arg(s.Creator),
|
|
}})
|
|
}
|
|
|
|
if !s.Enddatetime.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "enddatetime")...),
|
|
psql.Arg(s.Enddatetime),
|
|
}})
|
|
}
|
|
|
|
if !s.Editdate.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "editdate")...),
|
|
psql.Arg(s.Editdate),
|
|
}})
|
|
}
|
|
|
|
if !s.Editor.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "editor")...),
|
|
psql.Arg(s.Editor),
|
|
}})
|
|
}
|
|
|
|
if !s.Fieldtech.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "fieldtech")...),
|
|
psql.Arg(s.Fieldtech),
|
|
}})
|
|
}
|
|
|
|
if !s.Field.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "field")...),
|
|
psql.Arg(s.Field),
|
|
}})
|
|
}
|
|
|
|
if !s.Gatewaysync.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "gatewaysync")...),
|
|
psql.Arg(s.Gatewaysync),
|
|
}})
|
|
}
|
|
|
|
if !s.Globalid.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "globalid")...),
|
|
psql.Arg(s.Globalid),
|
|
}})
|
|
}
|
|
|
|
if !s.Idbytech.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "idbytech")...),
|
|
psql.Arg(s.Idbytech),
|
|
}})
|
|
}
|
|
|
|
if !s.Locationname.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "locationname")...),
|
|
psql.Arg(s.Locationname),
|
|
}})
|
|
}
|
|
|
|
if !s.LocID.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "loc_id")...),
|
|
psql.Arg(s.LocID),
|
|
}})
|
|
}
|
|
|
|
if !s.LR.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "lr")...),
|
|
psql.Arg(s.LR),
|
|
}})
|
|
}
|
|
|
|
if s.Objectid.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "objectid")...),
|
|
psql.Arg(s.Objectid),
|
|
}})
|
|
}
|
|
|
|
if !s.Processed.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "processed")...),
|
|
psql.Arg(s.Processed),
|
|
}})
|
|
}
|
|
|
|
if !s.Raingauge.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "raingauge")...),
|
|
psql.Arg(s.Raingauge),
|
|
}})
|
|
}
|
|
|
|
if !s.Recordstatus.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "recordstatus")...),
|
|
psql.Arg(s.Recordstatus),
|
|
}})
|
|
}
|
|
|
|
if !s.Reviewed.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reviewed")...),
|
|
psql.Arg(s.Reviewed),
|
|
}})
|
|
}
|
|
|
|
if !s.Reviewedby.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reviewedby")...),
|
|
psql.Arg(s.Reviewedby),
|
|
}})
|
|
}
|
|
|
|
if !s.Revieweddate.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "revieweddate")...),
|
|
psql.Arg(s.Revieweddate),
|
|
}})
|
|
}
|
|
|
|
if !s.Sitecond.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "sitecond")...),
|
|
psql.Arg(s.Sitecond),
|
|
}})
|
|
}
|
|
|
|
if !s.Sortbytech.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "sortbytech")...),
|
|
psql.Arg(s.Sortbytech),
|
|
}})
|
|
}
|
|
|
|
if !s.Srid.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "srid")...),
|
|
psql.Arg(s.Srid),
|
|
}})
|
|
}
|
|
|
|
if !s.Startdatetime.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "startdatetime")...),
|
|
psql.Arg(s.Startdatetime),
|
|
}})
|
|
}
|
|
|
|
if !s.Trapactivitytype.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "trapactivitytype")...),
|
|
psql.Arg(s.Trapactivitytype),
|
|
}})
|
|
}
|
|
|
|
if !s.Trapcondition.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "trapcondition")...),
|
|
psql.Arg(s.Trapcondition),
|
|
}})
|
|
}
|
|
|
|
if !s.Trapnights.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "trapnights")...),
|
|
psql.Arg(s.Trapnights),
|
|
}})
|
|
}
|
|
|
|
if !s.Traptype.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "traptype")...),
|
|
psql.Arg(s.Traptype),
|
|
}})
|
|
}
|
|
|
|
if !s.Voltage.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "voltage")...),
|
|
psql.Arg(s.Voltage),
|
|
}})
|
|
}
|
|
|
|
if !s.Winddir.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "winddir")...),
|
|
psql.Arg(s.Winddir),
|
|
}})
|
|
}
|
|
|
|
if !s.Windspeed.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "windspeed")...),
|
|
psql.Arg(s.Windspeed),
|
|
}})
|
|
}
|
|
|
|
if !s.Zone.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "zone")...),
|
|
psql.Arg(s.Zone),
|
|
}})
|
|
}
|
|
|
|
if !s.Zone2.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "zone2")...),
|
|
psql.Arg(s.Zone2),
|
|
}})
|
|
}
|
|
|
|
if !s.Created.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "created")...),
|
|
psql.Arg(s.Created),
|
|
}})
|
|
}
|
|
|
|
if !s.CreatedDate.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "created_date")...),
|
|
psql.Arg(s.CreatedDate),
|
|
}})
|
|
}
|
|
|
|
if !s.CreatedUser.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "created_user")...),
|
|
psql.Arg(s.CreatedUser),
|
|
}})
|
|
}
|
|
|
|
if !s.GeometryX.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "geometry_x")...),
|
|
psql.Arg(s.GeometryX),
|
|
}})
|
|
}
|
|
|
|
if !s.GeometryY.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "geometry_y")...),
|
|
psql.Arg(s.GeometryY),
|
|
}})
|
|
}
|
|
|
|
if !s.LastEditedDate.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "last_edited_date")...),
|
|
psql.Arg(s.LastEditedDate),
|
|
}})
|
|
}
|
|
|
|
if !s.LastEditedUser.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "last_edited_user")...),
|
|
psql.Arg(s.LastEditedUser),
|
|
}})
|
|
}
|
|
|
|
if !s.Lure.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "lure")...),
|
|
psql.Arg(s.Lure),
|
|
}})
|
|
}
|
|
|
|
if !s.Vectorsurvtrapdataid.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "vectorsurvtrapdataid")...),
|
|
psql.Arg(s.Vectorsurvtrapdataid),
|
|
}})
|
|
}
|
|
|
|
if !s.Vectorsurvtraplocationid.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "vectorsurvtraplocationid")...),
|
|
psql.Arg(s.Vectorsurvtraplocationid),
|
|
}})
|
|
}
|
|
|
|
if s.Version.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "version")...),
|
|
psql.Arg(s.Version),
|
|
}})
|
|
}
|
|
|
|
return exprs
|
|
}
|
|
|
|
// FindHistoryTrapdatum retrieves a single record by primary key
|
|
// If cols is empty Find will return all columns.
|
|
func FindHistoryTrapdatum(ctx context.Context, exec bob.Executor, ObjectidPK int32, VersionPK int32, cols ...string) (*HistoryTrapdatum, error) {
|
|
if len(cols) == 0 {
|
|
return HistoryTrapdata.Query(
|
|
sm.Where(HistoryTrapdata.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
|
sm.Where(HistoryTrapdata.Columns.Version.EQ(psql.Arg(VersionPK))),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
return HistoryTrapdata.Query(
|
|
sm.Where(HistoryTrapdata.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
|
sm.Where(HistoryTrapdata.Columns.Version.EQ(psql.Arg(VersionPK))),
|
|
sm.Columns(HistoryTrapdata.Columns.Only(cols...)),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
// HistoryTrapdatumExists checks the presence of a single record by primary key
|
|
func HistoryTrapdatumExists(ctx context.Context, exec bob.Executor, ObjectidPK int32, VersionPK int32) (bool, error) {
|
|
return HistoryTrapdata.Query(
|
|
sm.Where(HistoryTrapdata.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
|
sm.Where(HistoryTrapdata.Columns.Version.EQ(psql.Arg(VersionPK))),
|
|
).Exists(ctx, exec)
|
|
}
|
|
|
|
// AfterQueryHook is called after HistoryTrapdatum is retrieved from the database
|
|
func (o *HistoryTrapdatum) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = HistoryTrapdata.AfterSelectHooks.RunHooks(ctx, exec, HistoryTrapdatumSlice{o})
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = HistoryTrapdata.AfterInsertHooks.RunHooks(ctx, exec, HistoryTrapdatumSlice{o})
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = HistoryTrapdata.AfterUpdateHooks.RunHooks(ctx, exec, HistoryTrapdatumSlice{o})
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = HistoryTrapdata.AfterDeleteHooks.RunHooks(ctx, exec, HistoryTrapdatumSlice{o})
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// primaryKeyVals returns the primary key values of the HistoryTrapdatum
|
|
func (o *HistoryTrapdatum) primaryKeyVals() bob.Expression {
|
|
return psql.ArgGroup(
|
|
o.Objectid,
|
|
o.Version,
|
|
)
|
|
}
|
|
|
|
func (o *HistoryTrapdatum) pkEQ() dialect.Expression {
|
|
return psql.Group(psql.Quote("history_trapdata", "objectid"), psql.Quote("history_trapdata", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
|
|
}))
|
|
}
|
|
|
|
// Update uses an executor to update the HistoryTrapdatum
|
|
func (o *HistoryTrapdatum) Update(ctx context.Context, exec bob.Executor, s *HistoryTrapdatumSetter) error {
|
|
v, err := HistoryTrapdata.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.R = v.R
|
|
*o = *v
|
|
|
|
return nil
|
|
}
|
|
|
|
// Delete deletes a single HistoryTrapdatum record with an executor
|
|
func (o *HistoryTrapdatum) Delete(ctx context.Context, exec bob.Executor) error {
|
|
_, err := HistoryTrapdata.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
// Reload refreshes the HistoryTrapdatum using the executor
|
|
func (o *HistoryTrapdatum) Reload(ctx context.Context, exec bob.Executor) error {
|
|
o2, err := HistoryTrapdata.Query(
|
|
sm.Where(HistoryTrapdata.Columns.Objectid.EQ(psql.Arg(o.Objectid))),
|
|
sm.Where(HistoryTrapdata.Columns.Version.EQ(psql.Arg(o.Version))),
|
|
).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
o2.R = o.R
|
|
*o = *o2
|
|
|
|
return nil
|
|
}
|
|
|
|
// AfterQueryHook is called after HistoryTrapdatumSlice is retrieved from the database
|
|
func (o HistoryTrapdatumSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = HistoryTrapdata.AfterSelectHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = HistoryTrapdata.AfterInsertHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = HistoryTrapdata.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = HistoryTrapdata.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func (o HistoryTrapdatumSlice) pkIN() dialect.Expression {
|
|
if len(o) == 0 {
|
|
return psql.Raw("NULL")
|
|
}
|
|
|
|
return psql.Group(psql.Quote("history_trapdata", "objectid"), psql.Quote("history_trapdata", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
pkPairs := make([]bob.Expression, len(o))
|
|
for i, row := range o {
|
|
pkPairs[i] = row.primaryKeyVals()
|
|
}
|
|
return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
|
|
}))
|
|
}
|
|
|
|
// copyMatchingRows finds models in the given slice that have the same primary key
|
|
// then it first copies the existing relationships from the old model to the new model
|
|
// and then replaces the old model in the slice with the new model
|
|
func (o HistoryTrapdatumSlice) copyMatchingRows(from ...*HistoryTrapdatum) {
|
|
for i, old := range o {
|
|
for _, new := range from {
|
|
if new.Objectid != old.Objectid {
|
|
continue
|
|
}
|
|
if new.Version != old.Version {
|
|
continue
|
|
}
|
|
new.R = old.R
|
|
o[i] = new
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
|
|
func (o HistoryTrapdatumSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return HistoryTrapdata.BeforeUpdateHooks.RunHooks(ctx, exec, o)
|
|
})
|
|
|
|
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
|
|
var err error
|
|
switch retrieved := retrieved.(type) {
|
|
case *HistoryTrapdatum:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*HistoryTrapdatum:
|
|
o.copyMatchingRows(retrieved...)
|
|
case HistoryTrapdatumSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a HistoryTrapdatum or a slice of HistoryTrapdatum
|
|
// then run the AfterUpdateHooks on the slice
|
|
_, err = HistoryTrapdata.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
|
func (o HistoryTrapdatumSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
|
|
return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return HistoryTrapdata.BeforeDeleteHooks.RunHooks(ctx, exec, o)
|
|
})
|
|
|
|
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
|
|
var err error
|
|
switch retrieved := retrieved.(type) {
|
|
case *HistoryTrapdatum:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*HistoryTrapdatum:
|
|
o.copyMatchingRows(retrieved...)
|
|
case HistoryTrapdatumSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a HistoryTrapdatum or a slice of HistoryTrapdatum
|
|
// then run the AfterDeleteHooks on the slice
|
|
_, err = HistoryTrapdata.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
func (o HistoryTrapdatumSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals HistoryTrapdatumSetter) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := HistoryTrapdata.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o HistoryTrapdatumSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := HistoryTrapdata.Delete(o.DeleteMod()).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o HistoryTrapdatumSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
o2, err := HistoryTrapdata.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.copyMatchingRows(o2...)
|
|
|
|
return nil
|
|
}
|
|
|
|
// Organization starts a query for related objects on organization
|
|
func (o *HistoryTrapdatum) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
return Organizations.Query(append(mods,
|
|
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
|
)...)
|
|
}
|
|
|
|
func (os HistoryTrapdatumSlice) 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 attachHistoryTrapdatumOrganization0(ctx context.Context, exec bob.Executor, count int, historyTrapdatum0 *HistoryTrapdatum, organization1 *Organization) (*HistoryTrapdatum, error) {
|
|
setter := &HistoryTrapdatumSetter{
|
|
OrganizationID: omit.From(organization1.ID),
|
|
}
|
|
|
|
err := historyTrapdatum0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachHistoryTrapdatumOrganization0: %w", err)
|
|
}
|
|
|
|
return historyTrapdatum0, nil
|
|
}
|
|
|
|
func (historyTrapdatum0 *HistoryTrapdatum) 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 = attachHistoryTrapdatumOrganization0(ctx, exec, 1, historyTrapdatum0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
historyTrapdatum0.R.Organization = organization1
|
|
|
|
organization1.R.HistoryTrapdata = append(organization1.R.HistoryTrapdata, historyTrapdatum0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (historyTrapdatum0 *HistoryTrapdatum) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
|
var err error
|
|
|
|
_, err = attachHistoryTrapdatumOrganization0(ctx, exec, 1, historyTrapdatum0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
historyTrapdatum0.R.Organization = organization1
|
|
|
|
organization1.R.HistoryTrapdata = append(organization1.R.HistoryTrapdata, historyTrapdatum0)
|
|
|
|
return nil
|
|
}
|
|
|
|
type historyTrapdatumWhere[Q psql.Filterable] struct {
|
|
OrganizationID psql.WhereMod[Q, int32]
|
|
Avetemp psql.WhereNullMod[Q, float64]
|
|
Comments psql.WhereNullMod[Q, string]
|
|
Creationdate psql.WhereNullMod[Q, int64]
|
|
Creator psql.WhereNullMod[Q, string]
|
|
Enddatetime psql.WhereNullMod[Q, int64]
|
|
Editdate psql.WhereNullMod[Q, int64]
|
|
Editor psql.WhereNullMod[Q, string]
|
|
Fieldtech psql.WhereNullMod[Q, string]
|
|
Field psql.WhereNullMod[Q, int64]
|
|
Gatewaysync psql.WhereNullMod[Q, int16]
|
|
Globalid psql.WhereNullMod[Q, string]
|
|
Idbytech psql.WhereNullMod[Q, string]
|
|
Locationname psql.WhereNullMod[Q, string]
|
|
LocID psql.WhereNullMod[Q, string]
|
|
LR psql.WhereNullMod[Q, int16]
|
|
Objectid psql.WhereMod[Q, int32]
|
|
Processed psql.WhereNullMod[Q, int16]
|
|
Raingauge psql.WhereNullMod[Q, float64]
|
|
Recordstatus psql.WhereNullMod[Q, int16]
|
|
Reviewed psql.WhereNullMod[Q, int16]
|
|
Reviewedby psql.WhereNullMod[Q, string]
|
|
Revieweddate psql.WhereNullMod[Q, int64]
|
|
Sitecond psql.WhereNullMod[Q, string]
|
|
Sortbytech psql.WhereNullMod[Q, string]
|
|
Srid psql.WhereNullMod[Q, string]
|
|
Startdatetime psql.WhereNullMod[Q, int64]
|
|
Trapactivitytype psql.WhereNullMod[Q, string]
|
|
Trapcondition psql.WhereNullMod[Q, string]
|
|
Trapnights psql.WhereNullMod[Q, int16]
|
|
Traptype psql.WhereNullMod[Q, string]
|
|
Voltage psql.WhereNullMod[Q, float64]
|
|
Winddir psql.WhereNullMod[Q, string]
|
|
Windspeed psql.WhereNullMod[Q, float64]
|
|
Zone psql.WhereNullMod[Q, string]
|
|
Zone2 psql.WhereNullMod[Q, string]
|
|
Created psql.WhereNullMod[Q, time.Time]
|
|
CreatedDate psql.WhereNullMod[Q, int64]
|
|
CreatedUser psql.WhereNullMod[Q, string]
|
|
GeometryX psql.WhereNullMod[Q, float64]
|
|
GeometryY psql.WhereNullMod[Q, float64]
|
|
LastEditedDate psql.WhereNullMod[Q, int64]
|
|
LastEditedUser psql.WhereNullMod[Q, string]
|
|
Lure psql.WhereNullMod[Q, string]
|
|
Vectorsurvtrapdataid psql.WhereNullMod[Q, string]
|
|
Vectorsurvtraplocationid psql.WhereNullMod[Q, string]
|
|
Version psql.WhereMod[Q, int32]
|
|
}
|
|
|
|
func (historyTrapdatumWhere[Q]) AliasedAs(alias string) historyTrapdatumWhere[Q] {
|
|
return buildHistoryTrapdatumWhere[Q](buildHistoryTrapdatumColumns(alias))
|
|
}
|
|
|
|
func buildHistoryTrapdatumWhere[Q psql.Filterable](cols historyTrapdatumColumns) historyTrapdatumWhere[Q] {
|
|
return historyTrapdatumWhere[Q]{
|
|
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
|
|
Avetemp: psql.WhereNull[Q, float64](cols.Avetemp),
|
|
Comments: psql.WhereNull[Q, string](cols.Comments),
|
|
Creationdate: psql.WhereNull[Q, int64](cols.Creationdate),
|
|
Creator: psql.WhereNull[Q, string](cols.Creator),
|
|
Enddatetime: psql.WhereNull[Q, int64](cols.Enddatetime),
|
|
Editdate: psql.WhereNull[Q, int64](cols.Editdate),
|
|
Editor: psql.WhereNull[Q, string](cols.Editor),
|
|
Fieldtech: psql.WhereNull[Q, string](cols.Fieldtech),
|
|
Field: psql.WhereNull[Q, int64](cols.Field),
|
|
Gatewaysync: psql.WhereNull[Q, int16](cols.Gatewaysync),
|
|
Globalid: psql.WhereNull[Q, string](cols.Globalid),
|
|
Idbytech: psql.WhereNull[Q, string](cols.Idbytech),
|
|
Locationname: psql.WhereNull[Q, string](cols.Locationname),
|
|
LocID: psql.WhereNull[Q, string](cols.LocID),
|
|
LR: psql.WhereNull[Q, int16](cols.LR),
|
|
Objectid: psql.Where[Q, int32](cols.Objectid),
|
|
Processed: psql.WhereNull[Q, int16](cols.Processed),
|
|
Raingauge: psql.WhereNull[Q, float64](cols.Raingauge),
|
|
Recordstatus: psql.WhereNull[Q, int16](cols.Recordstatus),
|
|
Reviewed: psql.WhereNull[Q, int16](cols.Reviewed),
|
|
Reviewedby: psql.WhereNull[Q, string](cols.Reviewedby),
|
|
Revieweddate: psql.WhereNull[Q, int64](cols.Revieweddate),
|
|
Sitecond: psql.WhereNull[Q, string](cols.Sitecond),
|
|
Sortbytech: psql.WhereNull[Q, string](cols.Sortbytech),
|
|
Srid: psql.WhereNull[Q, string](cols.Srid),
|
|
Startdatetime: psql.WhereNull[Q, int64](cols.Startdatetime),
|
|
Trapactivitytype: psql.WhereNull[Q, string](cols.Trapactivitytype),
|
|
Trapcondition: psql.WhereNull[Q, string](cols.Trapcondition),
|
|
Trapnights: psql.WhereNull[Q, int16](cols.Trapnights),
|
|
Traptype: psql.WhereNull[Q, string](cols.Traptype),
|
|
Voltage: psql.WhereNull[Q, float64](cols.Voltage),
|
|
Winddir: psql.WhereNull[Q, string](cols.Winddir),
|
|
Windspeed: psql.WhereNull[Q, float64](cols.Windspeed),
|
|
Zone: psql.WhereNull[Q, string](cols.Zone),
|
|
Zone2: psql.WhereNull[Q, string](cols.Zone2),
|
|
Created: psql.WhereNull[Q, time.Time](cols.Created),
|
|
CreatedDate: psql.WhereNull[Q, int64](cols.CreatedDate),
|
|
CreatedUser: psql.WhereNull[Q, string](cols.CreatedUser),
|
|
GeometryX: psql.WhereNull[Q, float64](cols.GeometryX),
|
|
GeometryY: psql.WhereNull[Q, float64](cols.GeometryY),
|
|
LastEditedDate: psql.WhereNull[Q, int64](cols.LastEditedDate),
|
|
LastEditedUser: psql.WhereNull[Q, string](cols.LastEditedUser),
|
|
Lure: psql.WhereNull[Q, string](cols.Lure),
|
|
Vectorsurvtrapdataid: psql.WhereNull[Q, string](cols.Vectorsurvtrapdataid),
|
|
Vectorsurvtraplocationid: psql.WhereNull[Q, string](cols.Vectorsurvtraplocationid),
|
|
Version: psql.Where[Q, int32](cols.Version),
|
|
}
|
|
}
|
|
|
|
func (o *HistoryTrapdatum) Preload(name string, retrieved any) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
switch name {
|
|
case "Organization":
|
|
rel, ok := retrieved.(*Organization)
|
|
if !ok {
|
|
return fmt.Errorf("historyTrapdatum cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Organization = rel
|
|
|
|
if rel != nil {
|
|
rel.R.HistoryTrapdata = HistoryTrapdatumSlice{o}
|
|
}
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("historyTrapdatum has no relationship %q", name)
|
|
}
|
|
}
|
|
|
|
type historyTrapdatumPreloader struct {
|
|
Organization func(...psql.PreloadOption) psql.Preloader
|
|
}
|
|
|
|
func buildHistoryTrapdatumPreloader() historyTrapdatumPreloader {
|
|
return historyTrapdatumPreloader{
|
|
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
|
Name: "Organization",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: HistoryTrapdata,
|
|
To: Organizations,
|
|
FromColumns: []string{"organization_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Organizations.Columns.Names(), opts...)
|
|
},
|
|
}
|
|
}
|
|
|
|
type historyTrapdatumThenLoader[Q orm.Loadable] struct {
|
|
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
}
|
|
|
|
func buildHistoryTrapdatumThenLoader[Q orm.Loadable]() historyTrapdatumThenLoader[Q] {
|
|
type OrganizationLoadInterface interface {
|
|
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
|
|
return historyTrapdatumThenLoader[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 historyTrapdatum's Organization into the .R struct
|
|
func (o *HistoryTrapdatum) 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.HistoryTrapdata = HistoryTrapdatumSlice{o}
|
|
|
|
o.R.Organization = related
|
|
return nil
|
|
}
|
|
|
|
// LoadOrganization loads the historyTrapdatum's Organization into the .R struct
|
|
func (os HistoryTrapdatumSlice) 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.HistoryTrapdata = append(rel.R.HistoryTrapdata, o)
|
|
|
|
o.R.Organization = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type historyTrapdatumJoins[Q dialect.Joinable] struct {
|
|
typ string
|
|
Organization modAs[Q, organizationColumns]
|
|
}
|
|
|
|
func (j historyTrapdatumJoins[Q]) aliasedAs(alias string) historyTrapdatumJoins[Q] {
|
|
return buildHistoryTrapdatumJoins[Q](buildHistoryTrapdatumColumns(alias), j.typ)
|
|
}
|
|
|
|
func buildHistoryTrapdatumJoins[Q dialect.Joinable](cols historyTrapdatumColumns, typ string) historyTrapdatumJoins[Q] {
|
|
return historyTrapdatumJoins[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
|
|
},
|
|
},
|
|
}
|
|
}
|