Pull notifications from the database

Previously we were storing them, just not showing them.
This commit is contained in:
Eli Ribble 2025-11-11 22:53:48 +00:00
parent 337e5f7a7d
commit bf3dedf7cd
No known key found for this signature in database
18 changed files with 905 additions and 586 deletions

View file

@ -7,6 +7,7 @@ import (
"context"
"fmt"
"io"
"time"
"github.com/aarondl/opt/null"
"github.com/aarondl/opt/omit"
@ -25,52 +26,53 @@ import (
// HistoryPolygonlocation is an object representing the database table.
type HistoryPolygonlocation struct {
OrganizationID int32 `db:"organization_id" `
Accessdesc null.Val[string] `db:"accessdesc" `
Acres null.Val[float64] `db:"acres" `
Active null.Val[int16] `db:"active" `
Comments null.Val[string] `db:"comments" `
Creationdate null.Val[int64] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Description null.Val[string] `db:"description" `
Externalid null.Val[string] `db:"externalid" `
Editdate null.Val[int64] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
Filter null.Val[string] `db:"filter" `
Globalid null.Val[string] `db:"globalid" `
Habitat null.Val[string] `db:"habitat" `
Hectares null.Val[float64] `db:"hectares" `
Jurisdiction null.Val[string] `db:"jurisdiction" `
Larvinspectinterval null.Val[int16] `db:"larvinspectinterval" `
Lastinspectactiontaken null.Val[string] `db:"lastinspectactiontaken" `
Lastinspectactivity null.Val[string] `db:"lastinspectactivity" `
Lastinspectavglarvae null.Val[float64] `db:"lastinspectavglarvae" `
Lastinspectavgpupae null.Val[float64] `db:"lastinspectavgpupae" `
Lastinspectbreeding null.Val[string] `db:"lastinspectbreeding" `
Lastinspectconditions null.Val[string] `db:"lastinspectconditions" `
Lastinspectdate null.Val[int64] `db:"lastinspectdate" `
Lastinspectfieldspecies null.Val[string] `db:"lastinspectfieldspecies" `
Lastinspectlstages null.Val[string] `db:"lastinspectlstages" `
Lasttreatactivity null.Val[string] `db:"lasttreatactivity" `
Lasttreatdate null.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct null.Val[string] `db:"lasttreatproduct" `
Lasttreatqty null.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit null.Val[string] `db:"lasttreatqtyunit" `
Locationnumber null.Val[int64] `db:"locationnumber" `
Name null.Val[string] `db:"name" `
Nextactiondatescheduled null.Val[int64] `db:"nextactiondatescheduled" `
Objectid int32 `db:"objectid,pk" `
Priority null.Val[string] `db:"priority" `
Symbology null.Val[string] `db:"symbology" `
ShapeArea null.Val[float64] `db:"shape__area" `
ShapeLength null.Val[float64] `db:"shape__length" `
Usetype null.Val[string] `db:"usetype" `
Waterorigin null.Val[string] `db:"waterorigin" `
Zone null.Val[string] `db:"zone" `
Zone2 null.Val[string] `db:"zone2" `
GeometryX null.Val[float64] `db:"geometry_x" `
GeometryY null.Val[float64] `db:"geometry_y" `
Version int32 `db:"version,pk" `
OrganizationID int32 `db:"organization_id" `
Accessdesc null.Val[string] `db:"accessdesc" `
Acres null.Val[float64] `db:"acres" `
Active null.Val[int16] `db:"active" `
Comments null.Val[string] `db:"comments" `
Creationdate null.Val[int64] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Description null.Val[string] `db:"description" `
Externalid null.Val[string] `db:"externalid" `
Editdate null.Val[int64] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
Filter null.Val[string] `db:"filter" `
Globalid null.Val[string] `db:"globalid" `
Habitat null.Val[string] `db:"habitat" `
Hectares null.Val[float64] `db:"hectares" `
Jurisdiction null.Val[string] `db:"jurisdiction" `
Larvinspectinterval null.Val[int16] `db:"larvinspectinterval" `
Lastinspectactiontaken null.Val[string] `db:"lastinspectactiontaken" `
Lastinspectactivity null.Val[string] `db:"lastinspectactivity" `
Lastinspectavglarvae null.Val[float64] `db:"lastinspectavglarvae" `
Lastinspectavgpupae null.Val[float64] `db:"lastinspectavgpupae" `
Lastinspectbreeding null.Val[string] `db:"lastinspectbreeding" `
Lastinspectconditions null.Val[string] `db:"lastinspectconditions" `
Lastinspectdate null.Val[int64] `db:"lastinspectdate" `
Lastinspectfieldspecies null.Val[string] `db:"lastinspectfieldspecies" `
Lastinspectlstages null.Val[string] `db:"lastinspectlstages" `
Lasttreatactivity null.Val[string] `db:"lasttreatactivity" `
Lasttreatdate null.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct null.Val[string] `db:"lasttreatproduct" `
Lasttreatqty null.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit null.Val[string] `db:"lasttreatqtyunit" `
Locationnumber null.Val[int64] `db:"locationnumber" `
Name null.Val[string] `db:"name" `
Nextactiondatescheduled null.Val[int64] `db:"nextactiondatescheduled" `
Objectid int32 `db:"objectid,pk" `
Priority null.Val[string] `db:"priority" `
Symbology null.Val[string] `db:"symbology" `
ShapeArea null.Val[float64] `db:"shape__area" `
ShapeLength null.Val[float64] `db:"shape__length" `
Usetype null.Val[string] `db:"usetype" `
Waterorigin null.Val[string] `db:"waterorigin" `
Zone null.Val[string] `db:"zone" `
Zone2 null.Val[string] `db:"zone2" `
GeometryX null.Val[float64] `db:"geometry_x" `
GeometryY null.Val[float64] `db:"geometry_y" `
Version int32 `db:"version,pk" `
Created null.Val[time.Time] `db:"created" `
R historyPolygonlocationR `db:"-" `
}
@ -93,7 +95,7 @@ type historyPolygonlocationR struct {
func buildHistoryPolygonlocationColumns(alias string) historyPolygonlocationColumns {
return historyPolygonlocationColumns{
ColumnsExpr: expr.NewColumnsExpr(
"organization_id", "accessdesc", "acres", "active", "comments", "creationdate", "creator", "description", "externalid", "editdate", "editor", "filter", "globalid", "habitat", "hectares", "jurisdiction", "larvinspectinterval", "lastinspectactiontaken", "lastinspectactivity", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectbreeding", "lastinspectconditions", "lastinspectdate", "lastinspectfieldspecies", "lastinspectlstages", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "locationnumber", "name", "nextactiondatescheduled", "objectid", "priority", "symbology", "shape__area", "shape__length", "usetype", "waterorigin", "zone", "zone2", "geometry_x", "geometry_y", "version",
"organization_id", "accessdesc", "acres", "active", "comments", "creationdate", "creator", "description", "externalid", "editdate", "editor", "filter", "globalid", "habitat", "hectares", "jurisdiction", "larvinspectinterval", "lastinspectactiontaken", "lastinspectactivity", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectbreeding", "lastinspectconditions", "lastinspectdate", "lastinspectfieldspecies", "lastinspectlstages", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "locationnumber", "name", "nextactiondatescheduled", "objectid", "priority", "symbology", "shape__area", "shape__length", "usetype", "waterorigin", "zone", "zone2", "geometry_x", "geometry_y", "version", "created",
).WithParent("history_polygonlocation"),
tableAlias: alias,
OrganizationID: psql.Quote(alias, "organization_id"),
@ -142,6 +144,7 @@ func buildHistoryPolygonlocationColumns(alias string) historyPolygonlocationColu
GeometryX: psql.Quote(alias, "geometry_x"),
GeometryY: psql.Quote(alias, "geometry_y"),
Version: psql.Quote(alias, "version"),
Created: psql.Quote(alias, "created"),
}
}
@ -194,6 +197,7 @@ type historyPolygonlocationColumns struct {
GeometryX psql.Expression
GeometryY psql.Expression
Version psql.Expression
Created psql.Expression
}
func (c historyPolygonlocationColumns) Alias() string {
@ -208,56 +212,57 @@ func (historyPolygonlocationColumns) AliasedAs(alias string) historyPolygonlocat
// All values are optional, and do not have to be set
// Generated columns are not included
type HistoryPolygonlocationSetter struct {
OrganizationID omit.Val[int32] `db:"organization_id" `
Accessdesc omitnull.Val[string] `db:"accessdesc" `
Acres omitnull.Val[float64] `db:"acres" `
Active omitnull.Val[int16] `db:"active" `
Comments omitnull.Val[string] `db:"comments" `
Creationdate omitnull.Val[int64] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Description omitnull.Val[string] `db:"description" `
Externalid omitnull.Val[string] `db:"externalid" `
Editdate omitnull.Val[int64] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Filter omitnull.Val[string] `db:"filter" `
Globalid omitnull.Val[string] `db:"globalid" `
Habitat omitnull.Val[string] `db:"habitat" `
Hectares omitnull.Val[float64] `db:"hectares" `
Jurisdiction omitnull.Val[string] `db:"jurisdiction" `
Larvinspectinterval omitnull.Val[int16] `db:"larvinspectinterval" `
Lastinspectactiontaken omitnull.Val[string] `db:"lastinspectactiontaken" `
Lastinspectactivity omitnull.Val[string] `db:"lastinspectactivity" `
Lastinspectavglarvae omitnull.Val[float64] `db:"lastinspectavglarvae" `
Lastinspectavgpupae omitnull.Val[float64] `db:"lastinspectavgpupae" `
Lastinspectbreeding omitnull.Val[string] `db:"lastinspectbreeding" `
Lastinspectconditions omitnull.Val[string] `db:"lastinspectconditions" `
Lastinspectdate omitnull.Val[int64] `db:"lastinspectdate" `
Lastinspectfieldspecies omitnull.Val[string] `db:"lastinspectfieldspecies" `
Lastinspectlstages omitnull.Val[string] `db:"lastinspectlstages" `
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
Lasttreatdate omitnull.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct omitnull.Val[string] `db:"lasttreatproduct" `
Lasttreatqty omitnull.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit omitnull.Val[string] `db:"lasttreatqtyunit" `
Locationnumber omitnull.Val[int64] `db:"locationnumber" `
Name omitnull.Val[string] `db:"name" `
Nextactiondatescheduled omitnull.Val[int64] `db:"nextactiondatescheduled" `
Objectid omit.Val[int32] `db:"objectid,pk" `
Priority omitnull.Val[string] `db:"priority" `
Symbology omitnull.Val[string] `db:"symbology" `
ShapeArea omitnull.Val[float64] `db:"shape__area" `
ShapeLength omitnull.Val[float64] `db:"shape__length" `
Usetype omitnull.Val[string] `db:"usetype" `
Waterorigin omitnull.Val[string] `db:"waterorigin" `
Zone omitnull.Val[string] `db:"zone" `
Zone2 omitnull.Val[string] `db:"zone2" `
GeometryX omitnull.Val[float64] `db:"geometry_x" `
GeometryY omitnull.Val[float64] `db:"geometry_y" `
Version omit.Val[int32] `db:"version,pk" `
OrganizationID omit.Val[int32] `db:"organization_id" `
Accessdesc omitnull.Val[string] `db:"accessdesc" `
Acres omitnull.Val[float64] `db:"acres" `
Active omitnull.Val[int16] `db:"active" `
Comments omitnull.Val[string] `db:"comments" `
Creationdate omitnull.Val[int64] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Description omitnull.Val[string] `db:"description" `
Externalid omitnull.Val[string] `db:"externalid" `
Editdate omitnull.Val[int64] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Filter omitnull.Val[string] `db:"filter" `
Globalid omitnull.Val[string] `db:"globalid" `
Habitat omitnull.Val[string] `db:"habitat" `
Hectares omitnull.Val[float64] `db:"hectares" `
Jurisdiction omitnull.Val[string] `db:"jurisdiction" `
Larvinspectinterval omitnull.Val[int16] `db:"larvinspectinterval" `
Lastinspectactiontaken omitnull.Val[string] `db:"lastinspectactiontaken" `
Lastinspectactivity omitnull.Val[string] `db:"lastinspectactivity" `
Lastinspectavglarvae omitnull.Val[float64] `db:"lastinspectavglarvae" `
Lastinspectavgpupae omitnull.Val[float64] `db:"lastinspectavgpupae" `
Lastinspectbreeding omitnull.Val[string] `db:"lastinspectbreeding" `
Lastinspectconditions omitnull.Val[string] `db:"lastinspectconditions" `
Lastinspectdate omitnull.Val[int64] `db:"lastinspectdate" `
Lastinspectfieldspecies omitnull.Val[string] `db:"lastinspectfieldspecies" `
Lastinspectlstages omitnull.Val[string] `db:"lastinspectlstages" `
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
Lasttreatdate omitnull.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct omitnull.Val[string] `db:"lasttreatproduct" `
Lasttreatqty omitnull.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit omitnull.Val[string] `db:"lasttreatqtyunit" `
Locationnumber omitnull.Val[int64] `db:"locationnumber" `
Name omitnull.Val[string] `db:"name" `
Nextactiondatescheduled omitnull.Val[int64] `db:"nextactiondatescheduled" `
Objectid omit.Val[int32] `db:"objectid,pk" `
Priority omitnull.Val[string] `db:"priority" `
Symbology omitnull.Val[string] `db:"symbology" `
ShapeArea omitnull.Val[float64] `db:"shape__area" `
ShapeLength omitnull.Val[float64] `db:"shape__length" `
Usetype omitnull.Val[string] `db:"usetype" `
Waterorigin omitnull.Val[string] `db:"waterorigin" `
Zone omitnull.Val[string] `db:"zone" `
Zone2 omitnull.Val[string] `db:"zone2" `
GeometryX omitnull.Val[float64] `db:"geometry_x" `
GeometryY omitnull.Val[float64] `db:"geometry_y" `
Version omit.Val[int32] `db:"version,pk" `
Created omitnull.Val[time.Time] `db:"created" `
}
func (s HistoryPolygonlocationSetter) SetColumns() []string {
vals := make([]string, 0, 46)
vals := make([]string, 0, 47)
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
@ -396,6 +401,9 @@ func (s HistoryPolygonlocationSetter) SetColumns() []string {
if s.Version.IsValue() {
vals = append(vals, "version")
}
if !s.Created.IsUnset() {
vals = append(vals, "created")
}
return vals
}
@ -538,6 +546,9 @@ func (s HistoryPolygonlocationSetter) Overwrite(t *HistoryPolygonlocation) {
if s.Version.IsValue() {
t.Version = s.Version.MustGet()
}
if !s.Created.IsUnset() {
t.Created = s.Created.MustGetNull()
}
}
func (s *HistoryPolygonlocationSetter) Apply(q *dialect.InsertQuery) {
@ -546,7 +557,7 @@ func (s *HistoryPolygonlocationSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 46)
vals := make([]bob.Expression, 47)
if s.OrganizationID.IsValue() {
vals[0] = psql.Arg(s.OrganizationID.MustGet())
} else {
@ -823,6 +834,12 @@ func (s *HistoryPolygonlocationSetter) Apply(q *dialect.InsertQuery) {
vals[45] = psql.Raw("DEFAULT")
}
if !s.Created.IsUnset() {
vals[46] = psql.Arg(s.Created.MustGetNull())
} else {
vals[46] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -832,7 +849,7 @@ func (s HistoryPolygonlocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery]
}
func (s HistoryPolygonlocationSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 46)
exprs := make([]bob.Expression, 0, 47)
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -1156,6 +1173,13 @@ func (s HistoryPolygonlocationSetter) Expressions(prefix ...string) []bob.Expres
}})
}
if !s.Created.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "created")...),
psql.Arg(s.Created),
}})
}
return exprs
}
@ -1511,6 +1535,7 @@ type historyPolygonlocationWhere[Q psql.Filterable] struct {
GeometryX psql.WhereNullMod[Q, float64]
GeometryY psql.WhereNullMod[Q, float64]
Version psql.WhereMod[Q, int32]
Created psql.WhereNullMod[Q, time.Time]
}
func (historyPolygonlocationWhere[Q]) AliasedAs(alias string) historyPolygonlocationWhere[Q] {
@ -1565,6 +1590,7 @@ func buildHistoryPolygonlocationWhere[Q psql.Filterable](cols historyPolygonloca
GeometryX: psql.WhereNull[Q, float64](cols.GeometryX),
GeometryY: psql.WhereNull[Q, float64](cols.GeometryY),
Version: psql.Where[Q, int32](cols.Version),
Created: psql.WhereNull[Q, time.Time](cols.Created),
}
}

View file

@ -7,6 +7,7 @@ import (
"context"
"fmt"
"io"
"time"
"github.com/aarondl/opt/null"
"github.com/aarondl/opt/omit"
@ -25,43 +26,44 @@ import (
// HistoryProposedtreatmentarea is an object representing the database table.
type HistoryProposedtreatmentarea struct {
OrganizationID int32 `db:"organization_id" `
Acres null.Val[float64] `db:"acres" `
Comments null.Val[string] `db:"comments" `
Completed null.Val[int16] `db:"completed" `
Completedby null.Val[string] `db:"completedby" `
Completeddate null.Val[int64] `db:"completeddate" `
Creationdate null.Val[int64] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Duedate null.Val[int64] `db:"duedate" `
Exported null.Val[int16] `db:"exported" `
Editdate null.Val[int64] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
Globalid null.Val[string] `db:"globalid" `
Hectares null.Val[float64] `db:"hectares" `
Issprayroute null.Val[int16] `db:"issprayroute" `
Lasttreatactivity null.Val[string] `db:"lasttreatactivity" `
Lasttreatdate null.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct null.Val[string] `db:"lasttreatproduct" `
Lasttreatqty null.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit null.Val[string] `db:"lasttreatqtyunit" `
Method null.Val[string] `db:"method" `
Name null.Val[string] `db:"name" `
Objectid int32 `db:"objectid,pk" `
Priority null.Val[string] `db:"priority" `
Reviewed null.Val[int16] `db:"reviewed" `
Reviewedby null.Val[string] `db:"reviewedby" `
Revieweddate null.Val[int64] `db:"revieweddate" `
ShapeArea null.Val[float64] `db:"shape__area" `
ShapeLength null.Val[float64] `db:"shape__length" `
Targetapprate null.Val[float64] `db:"targetapprate" `
Targetproduct null.Val[string] `db:"targetproduct" `
Targetspecies null.Val[string] `db:"targetspecies" `
Zone null.Val[string] `db:"zone" `
Zone2 null.Val[string] `db:"zone2" `
GeometryX null.Val[float64] `db:"geometry_x" `
GeometryY null.Val[float64] `db:"geometry_y" `
Version int32 `db:"version,pk" `
OrganizationID int32 `db:"organization_id" `
Acres null.Val[float64] `db:"acres" `
Comments null.Val[string] `db:"comments" `
Completed null.Val[int16] `db:"completed" `
Completedby null.Val[string] `db:"completedby" `
Completeddate null.Val[int64] `db:"completeddate" `
Creationdate null.Val[int64] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Duedate null.Val[int64] `db:"duedate" `
Exported null.Val[int16] `db:"exported" `
Editdate null.Val[int64] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
Globalid null.Val[string] `db:"globalid" `
Hectares null.Val[float64] `db:"hectares" `
Issprayroute null.Val[int16] `db:"issprayroute" `
Lasttreatactivity null.Val[string] `db:"lasttreatactivity" `
Lasttreatdate null.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct null.Val[string] `db:"lasttreatproduct" `
Lasttreatqty null.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit null.Val[string] `db:"lasttreatqtyunit" `
Method null.Val[string] `db:"method" `
Name null.Val[string] `db:"name" `
Objectid int32 `db:"objectid,pk" `
Priority null.Val[string] `db:"priority" `
Reviewed null.Val[int16] `db:"reviewed" `
Reviewedby null.Val[string] `db:"reviewedby" `
Revieweddate null.Val[int64] `db:"revieweddate" `
ShapeArea null.Val[float64] `db:"shape__area" `
ShapeLength null.Val[float64] `db:"shape__length" `
Targetapprate null.Val[float64] `db:"targetapprate" `
Targetproduct null.Val[string] `db:"targetproduct" `
Targetspecies null.Val[string] `db:"targetspecies" `
Zone null.Val[string] `db:"zone" `
Zone2 null.Val[string] `db:"zone2" `
GeometryX null.Val[float64] `db:"geometry_x" `
GeometryY null.Val[float64] `db:"geometry_y" `
Version int32 `db:"version,pk" `
Created null.Val[time.Time] `db:"created" `
R historyProposedtreatmentareaR `db:"-" `
}
@ -84,7 +86,7 @@ type historyProposedtreatmentareaR struct {
func buildHistoryProposedtreatmentareaColumns(alias string) historyProposedtreatmentareaColumns {
return historyProposedtreatmentareaColumns{
ColumnsExpr: expr.NewColumnsExpr(
"organization_id", "acres", "comments", "completed", "completedby", "completeddate", "creationdate", "creator", "duedate", "exported", "editdate", "editor", "globalid", "hectares", "issprayroute", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "method", "name", "objectid", "priority", "reviewed", "reviewedby", "revieweddate", "shape__area", "shape__length", "targetapprate", "targetproduct", "targetspecies", "zone", "zone2", "geometry_x", "geometry_y", "version",
"organization_id", "acres", "comments", "completed", "completedby", "completeddate", "creationdate", "creator", "duedate", "exported", "editdate", "editor", "globalid", "hectares", "issprayroute", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "method", "name", "objectid", "priority", "reviewed", "reviewedby", "revieweddate", "shape__area", "shape__length", "targetapprate", "targetproduct", "targetspecies", "zone", "zone2", "geometry_x", "geometry_y", "version", "created",
).WithParent("history_proposedtreatmentarea"),
tableAlias: alias,
OrganizationID: psql.Quote(alias, "organization_id"),
@ -124,6 +126,7 @@ func buildHistoryProposedtreatmentareaColumns(alias string) historyProposedtreat
GeometryX: psql.Quote(alias, "geometry_x"),
GeometryY: psql.Quote(alias, "geometry_y"),
Version: psql.Quote(alias, "version"),
Created: psql.Quote(alias, "created"),
}
}
@ -167,6 +170,7 @@ type historyProposedtreatmentareaColumns struct {
GeometryX psql.Expression
GeometryY psql.Expression
Version psql.Expression
Created psql.Expression
}
func (c historyProposedtreatmentareaColumns) Alias() string {
@ -181,47 +185,48 @@ func (historyProposedtreatmentareaColumns) AliasedAs(alias string) historyPropos
// All values are optional, and do not have to be set
// Generated columns are not included
type HistoryProposedtreatmentareaSetter struct {
OrganizationID omit.Val[int32] `db:"organization_id" `
Acres omitnull.Val[float64] `db:"acres" `
Comments omitnull.Val[string] `db:"comments" `
Completed omitnull.Val[int16] `db:"completed" `
Completedby omitnull.Val[string] `db:"completedby" `
Completeddate omitnull.Val[int64] `db:"completeddate" `
Creationdate omitnull.Val[int64] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Duedate omitnull.Val[int64] `db:"duedate" `
Exported omitnull.Val[int16] `db:"exported" `
Editdate omitnull.Val[int64] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Globalid omitnull.Val[string] `db:"globalid" `
Hectares omitnull.Val[float64] `db:"hectares" `
Issprayroute omitnull.Val[int16] `db:"issprayroute" `
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
Lasttreatdate omitnull.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct omitnull.Val[string] `db:"lasttreatproduct" `
Lasttreatqty omitnull.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit omitnull.Val[string] `db:"lasttreatqtyunit" `
Method omitnull.Val[string] `db:"method" `
Name omitnull.Val[string] `db:"name" `
Objectid omit.Val[int32] `db:"objectid,pk" `
Priority omitnull.Val[string] `db:"priority" `
Reviewed omitnull.Val[int16] `db:"reviewed" `
Reviewedby omitnull.Val[string] `db:"reviewedby" `
Revieweddate omitnull.Val[int64] `db:"revieweddate" `
ShapeArea omitnull.Val[float64] `db:"shape__area" `
ShapeLength omitnull.Val[float64] `db:"shape__length" `
Targetapprate omitnull.Val[float64] `db:"targetapprate" `
Targetproduct omitnull.Val[string] `db:"targetproduct" `
Targetspecies omitnull.Val[string] `db:"targetspecies" `
Zone omitnull.Val[string] `db:"zone" `
Zone2 omitnull.Val[string] `db:"zone2" `
GeometryX omitnull.Val[float64] `db:"geometry_x" `
GeometryY omitnull.Val[float64] `db:"geometry_y" `
Version omit.Val[int32] `db:"version,pk" `
OrganizationID omit.Val[int32] `db:"organization_id" `
Acres omitnull.Val[float64] `db:"acres" `
Comments omitnull.Val[string] `db:"comments" `
Completed omitnull.Val[int16] `db:"completed" `
Completedby omitnull.Val[string] `db:"completedby" `
Completeddate omitnull.Val[int64] `db:"completeddate" `
Creationdate omitnull.Val[int64] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Duedate omitnull.Val[int64] `db:"duedate" `
Exported omitnull.Val[int16] `db:"exported" `
Editdate omitnull.Val[int64] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Globalid omitnull.Val[string] `db:"globalid" `
Hectares omitnull.Val[float64] `db:"hectares" `
Issprayroute omitnull.Val[int16] `db:"issprayroute" `
Lasttreatactivity omitnull.Val[string] `db:"lasttreatactivity" `
Lasttreatdate omitnull.Val[int64] `db:"lasttreatdate" `
Lasttreatproduct omitnull.Val[string] `db:"lasttreatproduct" `
Lasttreatqty omitnull.Val[float64] `db:"lasttreatqty" `
Lasttreatqtyunit omitnull.Val[string] `db:"lasttreatqtyunit" `
Method omitnull.Val[string] `db:"method" `
Name omitnull.Val[string] `db:"name" `
Objectid omit.Val[int32] `db:"objectid,pk" `
Priority omitnull.Val[string] `db:"priority" `
Reviewed omitnull.Val[int16] `db:"reviewed" `
Reviewedby omitnull.Val[string] `db:"reviewedby" `
Revieweddate omitnull.Val[int64] `db:"revieweddate" `
ShapeArea omitnull.Val[float64] `db:"shape__area" `
ShapeLength omitnull.Val[float64] `db:"shape__length" `
Targetapprate omitnull.Val[float64] `db:"targetapprate" `
Targetproduct omitnull.Val[string] `db:"targetproduct" `
Targetspecies omitnull.Val[string] `db:"targetspecies" `
Zone omitnull.Val[string] `db:"zone" `
Zone2 omitnull.Val[string] `db:"zone2" `
GeometryX omitnull.Val[float64] `db:"geometry_x" `
GeometryY omitnull.Val[float64] `db:"geometry_y" `
Version omit.Val[int32] `db:"version,pk" `
Created omitnull.Val[time.Time] `db:"created" `
}
func (s HistoryProposedtreatmentareaSetter) SetColumns() []string {
vals := make([]string, 0, 37)
vals := make([]string, 0, 38)
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
@ -333,6 +338,9 @@ func (s HistoryProposedtreatmentareaSetter) SetColumns() []string {
if s.Version.IsValue() {
vals = append(vals, "version")
}
if !s.Created.IsUnset() {
vals = append(vals, "created")
}
return vals
}
@ -448,6 +456,9 @@ func (s HistoryProposedtreatmentareaSetter) Overwrite(t *HistoryProposedtreatmen
if s.Version.IsValue() {
t.Version = s.Version.MustGet()
}
if !s.Created.IsUnset() {
t.Created = s.Created.MustGetNull()
}
}
func (s *HistoryProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) {
@ -456,7 +467,7 @@ func (s *HistoryProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 37)
vals := make([]bob.Expression, 38)
if s.OrganizationID.IsValue() {
vals[0] = psql.Arg(s.OrganizationID.MustGet())
} else {
@ -679,6 +690,12 @@ func (s *HistoryProposedtreatmentareaSetter) Apply(q *dialect.InsertQuery) {
vals[36] = psql.Raw("DEFAULT")
}
if !s.Created.IsUnset() {
vals[37] = psql.Arg(s.Created.MustGetNull())
} else {
vals[37] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -688,7 +705,7 @@ func (s HistoryProposedtreatmentareaSetter) UpdateMod() bob.Mod[*dialect.UpdateQ
}
func (s HistoryProposedtreatmentareaSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 37)
exprs := make([]bob.Expression, 0, 38)
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -949,6 +966,13 @@ func (s HistoryProposedtreatmentareaSetter) Expressions(prefix ...string) []bob.
}})
}
if !s.Created.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "created")...),
psql.Arg(s.Created),
}})
}
return exprs
}
@ -1295,6 +1319,7 @@ type historyProposedtreatmentareaWhere[Q psql.Filterable] struct {
GeometryX psql.WhereNullMod[Q, float64]
GeometryY psql.WhereNullMod[Q, float64]
Version psql.WhereMod[Q, int32]
Created psql.WhereNullMod[Q, time.Time]
}
func (historyProposedtreatmentareaWhere[Q]) AliasedAs(alias string) historyProposedtreatmentareaWhere[Q] {
@ -1340,6 +1365,7 @@ func buildHistoryProposedtreatmentareaWhere[Q psql.Filterable](cols historyPropo
GeometryX: psql.WhereNull[Q, float64](cols.GeometryX),
GeometryY: psql.WhereNull[Q, float64](cols.GeometryY),
Version: psql.Where[Q, int32](cols.Version),
Created: psql.WhereNull[Q, time.Time](cols.Created),
}
}

View file

@ -7,6 +7,7 @@ import (
"context"
"fmt"
"io"
"time"
"github.com/aarondl/opt/null"
"github.com/aarondl/opt/omit"
@ -25,64 +26,65 @@ import (
// HistoryTreatment is an object representing the database table.
type HistoryTreatment struct {
OrganizationID int32 `db:"organization_id" `
Activity null.Val[string] `db:"activity" `
Areaunit null.Val[string] `db:"areaunit" `
Avetemp null.Val[float64] `db:"avetemp" `
Barrierrouteid null.Val[string] `db:"barrierrouteid" `
Cbcount null.Val[int16] `db:"cbcount" `
Comments null.Val[string] `db:"comments" `
Containercount null.Val[int16] `db:"containercount" `
Creationdate null.Val[int64] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Enddatetime null.Val[int64] `db:"enddatetime" `
Equiptype null.Val[string] `db:"equiptype" `
Editdate null.Val[int64] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
Fieldtech null.Val[string] `db:"fieldtech" `
Flowrate null.Val[float64] `db:"flowrate" `
Globalid null.Val[string] `db:"globalid" `
Habitat null.Val[string] `db:"habitat" `
InspID null.Val[string] `db:"insp_id" `
Invloc null.Val[string] `db:"invloc" `
Linelocid null.Val[string] `db:"linelocid" `
Locationname null.Val[string] `db:"locationname" `
Method null.Val[string] `db:"method" `
Objectid int32 `db:"objectid,pk" `
Pointlocid null.Val[string] `db:"pointlocid" `
Polygonlocid null.Val[string] `db:"polygonlocid" `
Product null.Val[string] `db:"product" `
Ptaid null.Val[string] `db:"ptaid" `
Qty null.Val[float64] `db:"qty" `
Qtyunit null.Val[string] `db:"qtyunit" `
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" `
Sdid null.Val[string] `db:"sdid" `
Sitecond null.Val[string] `db:"sitecond" `
Srid null.Val[string] `db:"srid" `
Startdatetime null.Val[int64] `db:"startdatetime" `
Targetspecies null.Val[string] `db:"targetspecies" `
Tirecount null.Val[int16] `db:"tirecount" `
Treatacres null.Val[float64] `db:"treatacres" `
Treatarea null.Val[float64] `db:"treatarea" `
Treathectares null.Val[float64] `db:"treathectares" `
Treatmenthours null.Val[float64] `db:"treatmenthours" `
Treatmentlength null.Val[float64] `db:"treatmentlength" `
Treatmentlengthunits null.Val[string] `db:"treatmentlengthunits" `
Totalcostprodcut null.Val[float64] `db:"totalcostprodcut" `
Ulvrouteid null.Val[string] `db:"ulvrouteid" `
Warningoverride null.Val[int16] `db:"warningoverride" `
Winddir null.Val[string] `db:"winddir" `
Windspeed null.Val[float64] `db:"windspeed" `
Zone null.Val[string] `db:"zone" `
Zone2 null.Val[string] `db:"zone2" `
GeometryX null.Val[float64] `db:"geometry_x" `
GeometryY null.Val[float64] `db:"geometry_y" `
TempSitecond null.Val[string] `db:"temp_sitecond" `
Version int32 `db:"version,pk" `
OrganizationID int32 `db:"organization_id" `
Activity null.Val[string] `db:"activity" `
Areaunit null.Val[string] `db:"areaunit" `
Avetemp null.Val[float64] `db:"avetemp" `
Barrierrouteid null.Val[string] `db:"barrierrouteid" `
Cbcount null.Val[int16] `db:"cbcount" `
Comments null.Val[string] `db:"comments" `
Containercount null.Val[int16] `db:"containercount" `
Creationdate null.Val[int64] `db:"creationdate" `
Creator null.Val[string] `db:"creator" `
Enddatetime null.Val[int64] `db:"enddatetime" `
Equiptype null.Val[string] `db:"equiptype" `
Editdate null.Val[int64] `db:"editdate" `
Editor null.Val[string] `db:"editor" `
Fieldtech null.Val[string] `db:"fieldtech" `
Flowrate null.Val[float64] `db:"flowrate" `
Globalid null.Val[string] `db:"globalid" `
Habitat null.Val[string] `db:"habitat" `
InspID null.Val[string] `db:"insp_id" `
Invloc null.Val[string] `db:"invloc" `
Linelocid null.Val[string] `db:"linelocid" `
Locationname null.Val[string] `db:"locationname" `
Method null.Val[string] `db:"method" `
Objectid int32 `db:"objectid,pk" `
Pointlocid null.Val[string] `db:"pointlocid" `
Polygonlocid null.Val[string] `db:"polygonlocid" `
Product null.Val[string] `db:"product" `
Ptaid null.Val[string] `db:"ptaid" `
Qty null.Val[float64] `db:"qty" `
Qtyunit null.Val[string] `db:"qtyunit" `
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" `
Sdid null.Val[string] `db:"sdid" `
Sitecond null.Val[string] `db:"sitecond" `
Srid null.Val[string] `db:"srid" `
Startdatetime null.Val[int64] `db:"startdatetime" `
Targetspecies null.Val[string] `db:"targetspecies" `
Tirecount null.Val[int16] `db:"tirecount" `
Treatacres null.Val[float64] `db:"treatacres" `
Treatarea null.Val[float64] `db:"treatarea" `
Treathectares null.Val[float64] `db:"treathectares" `
Treatmenthours null.Val[float64] `db:"treatmenthours" `
Treatmentlength null.Val[float64] `db:"treatmentlength" `
Treatmentlengthunits null.Val[string] `db:"treatmentlengthunits" `
Totalcostprodcut null.Val[float64] `db:"totalcostprodcut" `
Ulvrouteid null.Val[string] `db:"ulvrouteid" `
Warningoverride null.Val[int16] `db:"warningoverride" `
Winddir null.Val[string] `db:"winddir" `
Windspeed null.Val[float64] `db:"windspeed" `
Zone null.Val[string] `db:"zone" `
Zone2 null.Val[string] `db:"zone2" `
GeometryX null.Val[float64] `db:"geometry_x" `
GeometryY null.Val[float64] `db:"geometry_y" `
TempSitecond null.Val[string] `db:"temp_sitecond" `
Version int32 `db:"version,pk" `
Created null.Val[time.Time] `db:"created" `
R historyTreatmentR `db:"-" `
}
@ -105,7 +107,7 @@ type historyTreatmentR struct {
func buildHistoryTreatmentColumns(alias string) historyTreatmentColumns {
return historyTreatmentColumns{
ColumnsExpr: expr.NewColumnsExpr(
"organization_id", "activity", "areaunit", "avetemp", "barrierrouteid", "cbcount", "comments", "containercount", "creationdate", "creator", "enddatetime", "equiptype", "editdate", "editor", "fieldtech", "flowrate", "globalid", "habitat", "insp_id", "invloc", "linelocid", "locationname", "method", "objectid", "pointlocid", "polygonlocid", "product", "ptaid", "qty", "qtyunit", "raingauge", "recordstatus", "reviewed", "reviewedby", "revieweddate", "sdid", "sitecond", "srid", "startdatetime", "targetspecies", "tirecount", "treatacres", "treatarea", "treathectares", "treatmenthours", "treatmentlength", "treatmentlengthunits", "totalcostprodcut", "ulvrouteid", "warningoverride", "winddir", "windspeed", "zone", "zone2", "geometry_x", "geometry_y", "temp_sitecond", "version",
"organization_id", "activity", "areaunit", "avetemp", "barrierrouteid", "cbcount", "comments", "containercount", "creationdate", "creator", "enddatetime", "equiptype", "editdate", "editor", "fieldtech", "flowrate", "globalid", "habitat", "insp_id", "invloc", "linelocid", "locationname", "method", "objectid", "pointlocid", "polygonlocid", "product", "ptaid", "qty", "qtyunit", "raingauge", "recordstatus", "reviewed", "reviewedby", "revieweddate", "sdid", "sitecond", "srid", "startdatetime", "targetspecies", "tirecount", "treatacres", "treatarea", "treathectares", "treatmenthours", "treatmentlength", "treatmentlengthunits", "totalcostprodcut", "ulvrouteid", "warningoverride", "winddir", "windspeed", "zone", "zone2", "geometry_x", "geometry_y", "temp_sitecond", "version", "created",
).WithParent("history_treatment"),
tableAlias: alias,
OrganizationID: psql.Quote(alias, "organization_id"),
@ -166,6 +168,7 @@ func buildHistoryTreatmentColumns(alias string) historyTreatmentColumns {
GeometryY: psql.Quote(alias, "geometry_y"),
TempSitecond: psql.Quote(alias, "temp_sitecond"),
Version: psql.Quote(alias, "version"),
Created: psql.Quote(alias, "created"),
}
}
@ -230,6 +233,7 @@ type historyTreatmentColumns struct {
GeometryY psql.Expression
TempSitecond psql.Expression
Version psql.Expression
Created psql.Expression
}
func (c historyTreatmentColumns) Alias() string {
@ -244,68 +248,69 @@ func (historyTreatmentColumns) AliasedAs(alias string) historyTreatmentColumns {
// All values are optional, and do not have to be set
// Generated columns are not included
type HistoryTreatmentSetter struct {
OrganizationID omit.Val[int32] `db:"organization_id" `
Activity omitnull.Val[string] `db:"activity" `
Areaunit omitnull.Val[string] `db:"areaunit" `
Avetemp omitnull.Val[float64] `db:"avetemp" `
Barrierrouteid omitnull.Val[string] `db:"barrierrouteid" `
Cbcount omitnull.Val[int16] `db:"cbcount" `
Comments omitnull.Val[string] `db:"comments" `
Containercount omitnull.Val[int16] `db:"containercount" `
Creationdate omitnull.Val[int64] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Enddatetime omitnull.Val[int64] `db:"enddatetime" `
Equiptype omitnull.Val[string] `db:"equiptype" `
Editdate omitnull.Val[int64] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Fieldtech omitnull.Val[string] `db:"fieldtech" `
Flowrate omitnull.Val[float64] `db:"flowrate" `
Globalid omitnull.Val[string] `db:"globalid" `
Habitat omitnull.Val[string] `db:"habitat" `
InspID omitnull.Val[string] `db:"insp_id" `
Invloc omitnull.Val[string] `db:"invloc" `
Linelocid omitnull.Val[string] `db:"linelocid" `
Locationname omitnull.Val[string] `db:"locationname" `
Method omitnull.Val[string] `db:"method" `
Objectid omit.Val[int32] `db:"objectid,pk" `
Pointlocid omitnull.Val[string] `db:"pointlocid" `
Polygonlocid omitnull.Val[string] `db:"polygonlocid" `
Product omitnull.Val[string] `db:"product" `
Ptaid omitnull.Val[string] `db:"ptaid" `
Qty omitnull.Val[float64] `db:"qty" `
Qtyunit omitnull.Val[string] `db:"qtyunit" `
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" `
Sdid omitnull.Val[string] `db:"sdid" `
Sitecond omitnull.Val[string] `db:"sitecond" `
Srid omitnull.Val[string] `db:"srid" `
Startdatetime omitnull.Val[int64] `db:"startdatetime" `
Targetspecies omitnull.Val[string] `db:"targetspecies" `
Tirecount omitnull.Val[int16] `db:"tirecount" `
Treatacres omitnull.Val[float64] `db:"treatacres" `
Treatarea omitnull.Val[float64] `db:"treatarea" `
Treathectares omitnull.Val[float64] `db:"treathectares" `
Treatmenthours omitnull.Val[float64] `db:"treatmenthours" `
Treatmentlength omitnull.Val[float64] `db:"treatmentlength" `
Treatmentlengthunits omitnull.Val[string] `db:"treatmentlengthunits" `
Totalcostprodcut omitnull.Val[float64] `db:"totalcostprodcut" `
Ulvrouteid omitnull.Val[string] `db:"ulvrouteid" `
Warningoverride omitnull.Val[int16] `db:"warningoverride" `
Winddir omitnull.Val[string] `db:"winddir" `
Windspeed omitnull.Val[float64] `db:"windspeed" `
Zone omitnull.Val[string] `db:"zone" `
Zone2 omitnull.Val[string] `db:"zone2" `
GeometryX omitnull.Val[float64] `db:"geometry_x" `
GeometryY omitnull.Val[float64] `db:"geometry_y" `
TempSitecond omitnull.Val[string] `db:"temp_sitecond" `
Version omit.Val[int32] `db:"version,pk" `
OrganizationID omit.Val[int32] `db:"organization_id" `
Activity omitnull.Val[string] `db:"activity" `
Areaunit omitnull.Val[string] `db:"areaunit" `
Avetemp omitnull.Val[float64] `db:"avetemp" `
Barrierrouteid omitnull.Val[string] `db:"barrierrouteid" `
Cbcount omitnull.Val[int16] `db:"cbcount" `
Comments omitnull.Val[string] `db:"comments" `
Containercount omitnull.Val[int16] `db:"containercount" `
Creationdate omitnull.Val[int64] `db:"creationdate" `
Creator omitnull.Val[string] `db:"creator" `
Enddatetime omitnull.Val[int64] `db:"enddatetime" `
Equiptype omitnull.Val[string] `db:"equiptype" `
Editdate omitnull.Val[int64] `db:"editdate" `
Editor omitnull.Val[string] `db:"editor" `
Fieldtech omitnull.Val[string] `db:"fieldtech" `
Flowrate omitnull.Val[float64] `db:"flowrate" `
Globalid omitnull.Val[string] `db:"globalid" `
Habitat omitnull.Val[string] `db:"habitat" `
InspID omitnull.Val[string] `db:"insp_id" `
Invloc omitnull.Val[string] `db:"invloc" `
Linelocid omitnull.Val[string] `db:"linelocid" `
Locationname omitnull.Val[string] `db:"locationname" `
Method omitnull.Val[string] `db:"method" `
Objectid omit.Val[int32] `db:"objectid,pk" `
Pointlocid omitnull.Val[string] `db:"pointlocid" `
Polygonlocid omitnull.Val[string] `db:"polygonlocid" `
Product omitnull.Val[string] `db:"product" `
Ptaid omitnull.Val[string] `db:"ptaid" `
Qty omitnull.Val[float64] `db:"qty" `
Qtyunit omitnull.Val[string] `db:"qtyunit" `
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" `
Sdid omitnull.Val[string] `db:"sdid" `
Sitecond omitnull.Val[string] `db:"sitecond" `
Srid omitnull.Val[string] `db:"srid" `
Startdatetime omitnull.Val[int64] `db:"startdatetime" `
Targetspecies omitnull.Val[string] `db:"targetspecies" `
Tirecount omitnull.Val[int16] `db:"tirecount" `
Treatacres omitnull.Val[float64] `db:"treatacres" `
Treatarea omitnull.Val[float64] `db:"treatarea" `
Treathectares omitnull.Val[float64] `db:"treathectares" `
Treatmenthours omitnull.Val[float64] `db:"treatmenthours" `
Treatmentlength omitnull.Val[float64] `db:"treatmentlength" `
Treatmentlengthunits omitnull.Val[string] `db:"treatmentlengthunits" `
Totalcostprodcut omitnull.Val[float64] `db:"totalcostprodcut" `
Ulvrouteid omitnull.Val[string] `db:"ulvrouteid" `
Warningoverride omitnull.Val[int16] `db:"warningoverride" `
Winddir omitnull.Val[string] `db:"winddir" `
Windspeed omitnull.Val[float64] `db:"windspeed" `
Zone omitnull.Val[string] `db:"zone" `
Zone2 omitnull.Val[string] `db:"zone2" `
GeometryX omitnull.Val[float64] `db:"geometry_x" `
GeometryY omitnull.Val[float64] `db:"geometry_y" `
TempSitecond omitnull.Val[string] `db:"temp_sitecond" `
Version omit.Val[int32] `db:"version,pk" `
Created omitnull.Val[time.Time] `db:"created" `
}
func (s HistoryTreatmentSetter) SetColumns() []string {
vals := make([]string, 0, 58)
vals := make([]string, 0, 59)
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
@ -480,6 +485,9 @@ func (s HistoryTreatmentSetter) SetColumns() []string {
if s.Version.IsValue() {
vals = append(vals, "version")
}
if !s.Created.IsUnset() {
vals = append(vals, "created")
}
return vals
}
@ -658,6 +666,9 @@ func (s HistoryTreatmentSetter) Overwrite(t *HistoryTreatment) {
if s.Version.IsValue() {
t.Version = s.Version.MustGet()
}
if !s.Created.IsUnset() {
t.Created = s.Created.MustGetNull()
}
}
func (s *HistoryTreatmentSetter) Apply(q *dialect.InsertQuery) {
@ -666,7 +677,7 @@ func (s *HistoryTreatmentSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 58)
vals := make([]bob.Expression, 59)
if s.OrganizationID.IsValue() {
vals[0] = psql.Arg(s.OrganizationID.MustGet())
} else {
@ -1015,6 +1026,12 @@ func (s *HistoryTreatmentSetter) Apply(q *dialect.InsertQuery) {
vals[57] = psql.Raw("DEFAULT")
}
if !s.Created.IsUnset() {
vals[58] = psql.Arg(s.Created.MustGetNull())
} else {
vals[58] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -1024,7 +1041,7 @@ func (s HistoryTreatmentSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s HistoryTreatmentSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 58)
exprs := make([]bob.Expression, 0, 59)
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -1432,6 +1449,13 @@ func (s HistoryTreatmentSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if !s.Created.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "created")...),
psql.Arg(s.Created),
}})
}
return exprs
}
@ -1799,6 +1823,7 @@ type historyTreatmentWhere[Q psql.Filterable] struct {
GeometryY psql.WhereNullMod[Q, float64]
TempSitecond psql.WhereNullMod[Q, string]
Version psql.WhereMod[Q, int32]
Created psql.WhereNullMod[Q, time.Time]
}
func (historyTreatmentWhere[Q]) AliasedAs(alias string) historyTreatmentWhere[Q] {
@ -1865,6 +1890,7 @@ func buildHistoryTreatmentWhere[Q psql.Filterable](cols historyTreatmentColumns)
GeometryY: psql.WhereNull[Q, float64](cols.GeometryY),
TempSitecond: psql.WhereNull[Q, string](cols.TempSitecond),
Version: psql.Where[Q, int32](cols.Version),
Created: psql.WhereNull[Q, time.Time](cols.Created),
}
}

View file

@ -7,11 +7,10 @@ import (
"context"
"fmt"
"io"
"time"
enums "github.com/Gleipnir-Technology/nidus-sync/enums"
"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"
@ -26,11 +25,12 @@ import (
// Notification is an object representing the database table.
type Notification struct {
ID int32 `db:"id,pk" `
UserID null.Val[int32] `db:"user_id" `
Message null.Val[string] `db:"message" `
Link null.Val[string] `db:"link" `
Type null.Val[enums.Notificationtype] `db:"type" `
ID int32 `db:"id,pk" `
Created time.Time `db:"created" `
Link string `db:"link" `
Message string `db:"message" `
Type enums.Notificationtype `db:"type" `
UserID int32 `db:"user_id" `
R notificationR `db:"-" `
}
@ -53,14 +53,15 @@ type notificationR struct {
func buildNotificationColumns(alias string) notificationColumns {
return notificationColumns{
ColumnsExpr: expr.NewColumnsExpr(
"id", "user_id", "message", "link", "type",
"id", "created", "link", "message", "type", "user_id",
).WithParent("notification"),
tableAlias: alias,
ID: psql.Quote(alias, "id"),
UserID: psql.Quote(alias, "user_id"),
Message: psql.Quote(alias, "message"),
Created: psql.Quote(alias, "created"),
Link: psql.Quote(alias, "link"),
Message: psql.Quote(alias, "message"),
Type: psql.Quote(alias, "type"),
UserID: psql.Quote(alias, "user_id"),
}
}
@ -68,10 +69,11 @@ type notificationColumns struct {
expr.ColumnsExpr
tableAlias string
ID psql.Expression
UserID psql.Expression
Message psql.Expression
Created psql.Expression
Link psql.Expression
Message psql.Expression
Type psql.Expression
UserID psql.Expression
}
func (c notificationColumns) Alias() string {
@ -86,30 +88,34 @@ func (notificationColumns) AliasedAs(alias string) notificationColumns {
// All values are optional, and do not have to be set
// Generated columns are not included
type NotificationSetter struct {
ID omit.Val[int32] `db:"id,pk" `
UserID omitnull.Val[int32] `db:"user_id" `
Message omitnull.Val[string] `db:"message" `
Link omitnull.Val[string] `db:"link" `
Type omitnull.Val[enums.Notificationtype] `db:"type" `
ID omit.Val[int32] `db:"id,pk" `
Created omit.Val[time.Time] `db:"created" `
Link omit.Val[string] `db:"link" `
Message omit.Val[string] `db:"message" `
Type omit.Val[enums.Notificationtype] `db:"type" `
UserID omit.Val[int32] `db:"user_id" `
}
func (s NotificationSetter) SetColumns() []string {
vals := make([]string, 0, 5)
vals := make([]string, 0, 6)
if s.ID.IsValue() {
vals = append(vals, "id")
}
if !s.UserID.IsUnset() {
vals = append(vals, "user_id")
if s.Created.IsValue() {
vals = append(vals, "created")
}
if !s.Message.IsUnset() {
vals = append(vals, "message")
}
if !s.Link.IsUnset() {
if s.Link.IsValue() {
vals = append(vals, "link")
}
if !s.Type.IsUnset() {
if s.Message.IsValue() {
vals = append(vals, "message")
}
if s.Type.IsValue() {
vals = append(vals, "type")
}
if s.UserID.IsValue() {
vals = append(vals, "user_id")
}
return vals
}
@ -117,17 +123,20 @@ func (s NotificationSetter) Overwrite(t *Notification) {
if s.ID.IsValue() {
t.ID = s.ID.MustGet()
}
if !s.UserID.IsUnset() {
t.UserID = s.UserID.MustGetNull()
if s.Created.IsValue() {
t.Created = s.Created.MustGet()
}
if !s.Message.IsUnset() {
t.Message = s.Message.MustGetNull()
if s.Link.IsValue() {
t.Link = s.Link.MustGet()
}
if !s.Link.IsUnset() {
t.Link = s.Link.MustGetNull()
if s.Message.IsValue() {
t.Message = s.Message.MustGet()
}
if !s.Type.IsUnset() {
t.Type = s.Type.MustGetNull()
if s.Type.IsValue() {
t.Type = s.Type.MustGet()
}
if s.UserID.IsValue() {
t.UserID = s.UserID.MustGet()
}
}
@ -137,37 +146,43 @@ func (s *NotificationSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 5)
vals := make([]bob.Expression, 6)
if s.ID.IsValue() {
vals[0] = psql.Arg(s.ID.MustGet())
} else {
vals[0] = psql.Raw("DEFAULT")
}
if !s.UserID.IsUnset() {
vals[1] = psql.Arg(s.UserID.MustGetNull())
if s.Created.IsValue() {
vals[1] = psql.Arg(s.Created.MustGet())
} else {
vals[1] = psql.Raw("DEFAULT")
}
if !s.Message.IsUnset() {
vals[2] = psql.Arg(s.Message.MustGetNull())
if s.Link.IsValue() {
vals[2] = psql.Arg(s.Link.MustGet())
} else {
vals[2] = psql.Raw("DEFAULT")
}
if !s.Link.IsUnset() {
vals[3] = psql.Arg(s.Link.MustGetNull())
if s.Message.IsValue() {
vals[3] = psql.Arg(s.Message.MustGet())
} else {
vals[3] = psql.Raw("DEFAULT")
}
if !s.Type.IsUnset() {
vals[4] = psql.Arg(s.Type.MustGetNull())
if s.Type.IsValue() {
vals[4] = psql.Arg(s.Type.MustGet())
} else {
vals[4] = psql.Raw("DEFAULT")
}
if s.UserID.IsValue() {
vals[5] = psql.Arg(s.UserID.MustGet())
} else {
vals[5] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -177,7 +192,7 @@ func (s NotificationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s NotificationSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 5)
exprs := make([]bob.Expression, 0, 6)
if s.ID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -186,34 +201,41 @@ func (s NotificationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if !s.UserID.IsUnset() {
if s.Created.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "user_id")...),
psql.Arg(s.UserID),
psql.Quote(append(prefix, "created")...),
psql.Arg(s.Created),
}})
}
if !s.Message.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "message")...),
psql.Arg(s.Message),
}})
}
if !s.Link.IsUnset() {
if s.Link.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "link")...),
psql.Arg(s.Link),
}})
}
if !s.Type.IsUnset() {
if s.Message.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "message")...),
psql.Arg(s.Message),
}})
}
if s.Type.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "type")...),
psql.Arg(s.Type),
}})
}
if s.UserID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "user_id")...),
psql.Arg(s.UserID),
}})
}
return exprs
}
@ -448,7 +470,7 @@ func (o *Notification) UserUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuer
}
func (os NotificationSlice) UserUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
pkUserID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
pkUserID := make(pgtypes.Array[int32], 0, len(os))
for _, o := range os {
if o == nil {
continue
@ -466,7 +488,7 @@ func (os NotificationSlice) UserUser(mods ...bob.Mod[*dialect.SelectQuery]) User
func attachNotificationUserUser0(ctx context.Context, exec bob.Executor, count int, notification0 *Notification, user1 *User) (*Notification, error) {
setter := &NotificationSetter{
UserID: omitnull.From(user1.ID),
UserID: omit.From(user1.ID),
}
err := notification0.Update(ctx, exec, setter)
@ -514,10 +536,11 @@ func (notification0 *Notification) AttachUserUser(ctx context.Context, exec bob.
type notificationWhere[Q psql.Filterable] struct {
ID psql.WhereMod[Q, int32]
UserID psql.WhereNullMod[Q, int32]
Message psql.WhereNullMod[Q, string]
Link psql.WhereNullMod[Q, string]
Type psql.WhereNullMod[Q, enums.Notificationtype]
Created psql.WhereMod[Q, time.Time]
Link psql.WhereMod[Q, string]
Message psql.WhereMod[Q, string]
Type psql.WhereMod[Q, enums.Notificationtype]
UserID psql.WhereMod[Q, int32]
}
func (notificationWhere[Q]) AliasedAs(alias string) notificationWhere[Q] {
@ -527,10 +550,11 @@ func (notificationWhere[Q]) AliasedAs(alias string) notificationWhere[Q] {
func buildNotificationWhere[Q psql.Filterable](cols notificationColumns) notificationWhere[Q] {
return notificationWhere[Q]{
ID: psql.Where[Q, int32](cols.ID),
UserID: psql.WhereNull[Q, int32](cols.UserID),
Message: psql.WhereNull[Q, string](cols.Message),
Link: psql.WhereNull[Q, string](cols.Link),
Type: psql.WhereNull[Q, enums.Notificationtype](cols.Type),
Created: psql.Where[Q, time.Time](cols.Created),
Link: psql.Where[Q, string](cols.Link),
Message: psql.Where[Q, string](cols.Message),
Type: psql.Where[Q, enums.Notificationtype](cols.Type),
UserID: psql.Where[Q, int32](cols.UserID),
}
}
@ -635,11 +659,8 @@ func (os NotificationSlice) LoadUserUser(ctx context.Context, exec bob.Executor,
}
for _, rel := range users {
if !o.UserID.IsValue() {
continue
}
if !(o.UserID.IsValue() && o.UserID.MustGet() == rel.ID) {
if !(o.UserID == rel.ID) {
continue
}

View file

@ -678,7 +678,7 @@ func (os UserSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) Organiza
func insertUserUserNotifications0(ctx context.Context, exec bob.Executor, notifications1 []*NotificationSetter, user0 *User) (NotificationSlice, error) {
for i := range notifications1 {
notifications1[i].UserID = omitnull.From(user0.ID)
notifications1[i].UserID = omit.From(user0.ID)
}
ret, err := Notifications.Insert(bob.ToMods(notifications1...)).All(ctx, exec)
@ -691,7 +691,7 @@ func insertUserUserNotifications0(ctx context.Context, exec bob.Executor, notifi
func attachUserUserNotifications0(ctx context.Context, exec bob.Executor, count int, notifications1 NotificationSlice, user0 *User) (NotificationSlice, error) {
setter := &NotificationSetter{
UserID: omitnull.From(user0.ID),
UserID: omit.From(user0.ID),
}
err := notifications1.UpdateAll(ctx, exec, *setter)
@ -1056,10 +1056,7 @@ func (os UserSlice) LoadUserNotifications(ctx context.Context, exec bob.Executor
for _, rel := range notifications {
if !rel.UserID.IsValue() {
continue
}
if !(rel.UserID.IsValue() && o.ID == rel.UserID.MustGet()) {
if !(o.ID == rel.UserID) {
continue
}