Initially made it through full update with new fieldseeker schema

This commit is contained in:
Eli Ribble 2025-12-05 23:11:57 +00:00
parent 0904f086b2
commit bd16f69e28
No known key found for this signature in database
510 changed files with 13617 additions and 14851 deletions

View file

@ -1,4 +1,4 @@
// Code generated by BobGen psql v0.42.0. DO NOT EDIT.
// Code generated by BobGen psql v0.0.3-0.20251202003046-49148fc66a73+dirty. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@ -38,6 +38,8 @@ type FieldseekerZone struct {
Editor null.Val[string] `db:"editor" `
ShapeArea null.Val[float64] `db:"shape__area" `
ShapeLength null.Val[float64] `db:"shape__length" `
// Tracks version changes to the row. Increases when data is modified.
Version int32 `db:"version,pk" `
}
// FieldseekerZoneSlice is an alias for a slice of pointers to FieldseekerZone.
@ -53,7 +55,7 @@ type FieldseekerZonesQuery = *psql.ViewQuery[*FieldseekerZone, FieldseekerZoneSl
func buildFieldseekerZoneColumns(alias string) fieldseekerZoneColumns {
return fieldseekerZoneColumns{
ColumnsExpr: expr.NewColumnsExpr(
"objectid", "name", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "active", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length",
"objectid", "name", "globalid", "created_user", "created_date", "last_edited_user", "last_edited_date", "active", "creationdate", "creator", "editdate", "editor", "shape__area", "shape__length", "version",
).WithParent("fieldseeker.zones"),
tableAlias: alias,
Objectid: psql.Quote(alias, "objectid"),
@ -70,6 +72,7 @@ func buildFieldseekerZoneColumns(alias string) fieldseekerZoneColumns {
Editor: psql.Quote(alias, "editor"),
ShapeArea: psql.Quote(alias, "shape__area"),
ShapeLength: psql.Quote(alias, "shape__length"),
Version: psql.Quote(alias, "version"),
}
}
@ -90,6 +93,7 @@ type fieldseekerZoneColumns struct {
Editor psql.Expression
ShapeArea psql.Expression
ShapeLength psql.Expression
Version psql.Expression
}
func (c fieldseekerZoneColumns) Alias() string {
@ -118,10 +122,11 @@ type FieldseekerZoneSetter struct {
Editor omitnull.Val[string] `db:"editor" `
ShapeArea omitnull.Val[float64] `db:"shape__area" `
ShapeLength omitnull.Val[float64] `db:"shape__length" `
Version omit.Val[int32] `db:"version,pk" `
}
func (s FieldseekerZoneSetter) SetColumns() []string {
vals := make([]string, 0, 14)
vals := make([]string, 0, 15)
if s.Objectid.IsValue() {
vals = append(vals, "objectid")
}
@ -164,6 +169,9 @@ func (s FieldseekerZoneSetter) SetColumns() []string {
if !s.ShapeLength.IsUnset() {
vals = append(vals, "shape__length")
}
if s.Version.IsValue() {
vals = append(vals, "version")
}
return vals
}
@ -210,6 +218,9 @@ func (s FieldseekerZoneSetter) Overwrite(t *FieldseekerZone) {
if !s.ShapeLength.IsUnset() {
t.ShapeLength = s.ShapeLength.MustGetNull()
}
if s.Version.IsValue() {
t.Version = s.Version.MustGet()
}
}
func (s *FieldseekerZoneSetter) Apply(q *dialect.InsertQuery) {
@ -218,7 +229,7 @@ func (s *FieldseekerZoneSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 14)
vals := make([]bob.Expression, 15)
if s.Objectid.IsValue() {
vals[0] = psql.Arg(s.Objectid.MustGet())
} else {
@ -303,6 +314,12 @@ func (s *FieldseekerZoneSetter) Apply(q *dialect.InsertQuery) {
vals[13] = psql.Raw("DEFAULT")
}
if s.Version.IsValue() {
vals[14] = psql.Arg(s.Version.MustGet())
} else {
vals[14] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -312,7 +329,7 @@ func (s FieldseekerZoneSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s FieldseekerZoneSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 14)
exprs := make([]bob.Expression, 0, 15)
if s.Objectid.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -412,28 +429,38 @@ func (s FieldseekerZoneSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if s.Version.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "version")...),
psql.Arg(s.Version),
}})
}
return exprs
}
// FindFieldseekerZone retrieves a single record by primary key
// If cols is empty Find will return all columns.
func FindFieldseekerZone(ctx context.Context, exec bob.Executor, ObjectidPK int64, cols ...string) (*FieldseekerZone, error) {
func FindFieldseekerZone(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerZone, error) {
if len(cols) == 0 {
return FieldseekerZones.Query(
sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(VersionPK))),
).One(ctx, exec)
}
return FieldseekerZones.Query(
sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(VersionPK))),
sm.Columns(FieldseekerZones.Columns.Only(cols...)),
).One(ctx, exec)
}
// FieldseekerZoneExists checks the presence of a single record by primary key
func FieldseekerZoneExists(ctx context.Context, exec bob.Executor, ObjectidPK int64) (bool, error) {
func FieldseekerZoneExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) {
return FieldseekerZones.Query(
sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(VersionPK))),
).Exists(ctx, exec)
}
@ -457,11 +484,14 @@ func (o *FieldseekerZone) AfterQueryHook(ctx context.Context, exec bob.Executor,
// primaryKeyVals returns the primary key values of the FieldseekerZone
func (o *FieldseekerZone) primaryKeyVals() bob.Expression {
return psql.Arg(o.Objectid)
return psql.ArgGroup(
o.Objectid,
o.Version,
)
}
func (o *FieldseekerZone) pkEQ() dialect.Expression {
return psql.Quote("fieldseeker.zones", "objectid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
return psql.Group(psql.Quote("fieldseeker.zones", "objectid"), psql.Quote("fieldseeker.zones", "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)
}))
}
@ -488,6 +518,7 @@ func (o *FieldseekerZone) Delete(ctx context.Context, exec bob.Executor) error {
func (o *FieldseekerZone) Reload(ctx context.Context, exec bob.Executor) error {
o2, err := FieldseekerZones.Query(
sm.Where(FieldseekerZones.Columns.Objectid.EQ(psql.Arg(o.Objectid))),
sm.Where(FieldseekerZones.Columns.Version.EQ(psql.Arg(o.Version))),
).One(ctx, exec)
if err != nil {
return err
@ -521,7 +552,7 @@ func (o FieldseekerZoneSlice) pkIN() dialect.Expression {
return psql.Raw("NULL")
}
return psql.Quote("fieldseeker.zones", "objectid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
return psql.Group(psql.Quote("fieldseeker.zones", "objectid"), psql.Quote("fieldseeker.zones", "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()
@ -539,6 +570,9 @@ func (o FieldseekerZoneSlice) copyMatchingRows(from ...*FieldseekerZone) {
if new.Objectid != old.Objectid {
continue
}
if new.Version != old.Version {
continue
}
o[i] = new
break
@ -652,6 +686,7 @@ type fieldseekerZoneWhere[Q psql.Filterable] struct {
Editor psql.WhereNullMod[Q, string]
ShapeArea psql.WhereNullMod[Q, float64]
ShapeLength psql.WhereNullMod[Q, float64]
Version psql.WhereMod[Q, int32]
}
func (fieldseekerZoneWhere[Q]) AliasedAs(alias string) fieldseekerZoneWhere[Q] {
@ -674,5 +709,6 @@ func buildFieldseekerZoneWhere[Q psql.Filterable](cols fieldseekerZoneColumns) f
Editor: psql.WhereNull[Q, string](cols.Editor),
ShapeArea: psql.WhereNull[Q, float64](cols.ShapeArea),
ShapeLength: psql.WhereNull[Q, float64](cols.ShapeLength),
Version: psql.Where[Q, int32](cols.Version),
}
}