2026-02-09 19:03:27 +00:00
|
|
|
// Code generated by BobGen psql v0.42.5. 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/Gleipnir-Technology/bob"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/dialect"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/dm"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/um"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/expr"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/orm"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/types/pgtypes"
|
|
|
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
|
|
|
|
"github.com/aarondl/opt/null"
|
|
|
|
|
"github.com/aarondl/opt/omit"
|
|
|
|
|
"github.com/aarondl/opt/omitnull"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// FileuploadPool is an object representing the database table.
|
|
|
|
|
type FileuploadPool struct {
|
2026-03-05 01:22:21 +00:00
|
|
|
AddressPostalCode string `db:"address_postal_code" `
|
|
|
|
|
AddressStreet string `db:"address_street" `
|
|
|
|
|
Committed bool `db:"committed" `
|
|
|
|
|
Created time.Time `db:"created" `
|
|
|
|
|
CreatorID int32 `db:"creator_id" `
|
|
|
|
|
CSVFile int32 `db:"csv_file" `
|
|
|
|
|
Deleted null.Val[time.Time] `db:"deleted" `
|
|
|
|
|
Geom null.Val[string] `db:"geom" `
|
|
|
|
|
H3cell null.Val[string] `db:"h3cell" `
|
|
|
|
|
ID int32 `db:"id,pk" `
|
|
|
|
|
IsInDistrict bool `db:"is_in_district" `
|
|
|
|
|
IsNew bool `db:"is_new" `
|
|
|
|
|
Notes string `db:"notes" `
|
|
|
|
|
PropertyOwnerName string `db:"property_owner_name" `
|
|
|
|
|
PropertyOwnerPhoneE164 null.Val[string] `db:"property_owner_phone_e164" `
|
|
|
|
|
ResidentOwned null.Val[bool] `db:"resident_owned" `
|
|
|
|
|
ResidentPhoneE164 null.Val[string] `db:"resident_phone_e164" `
|
|
|
|
|
LineNumber int32 `db:"line_number" `
|
|
|
|
|
Tags pgtypes.HStore `db:"tags" `
|
|
|
|
|
AddressNumber string `db:"address_number" `
|
|
|
|
|
AddressLocality string `db:"address_locality" `
|
|
|
|
|
AddressRegion string `db:"address_region" `
|
|
|
|
|
Condition enums.Poolconditiontype `db:"condition" `
|
2026-02-09 19:03:27 +00:00
|
|
|
|
|
|
|
|
R fileuploadPoolR `db:"-" `
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FileuploadPoolSlice is an alias for a slice of pointers to FileuploadPool.
|
|
|
|
|
// This should almost always be used instead of []*FileuploadPool.
|
|
|
|
|
type FileuploadPoolSlice []*FileuploadPool
|
|
|
|
|
|
|
|
|
|
// FileuploadPools contains methods to work with the pool table
|
|
|
|
|
var FileuploadPools = psql.NewTablex[*FileuploadPool, FileuploadPoolSlice, *FileuploadPoolSetter]("fileupload", "pool", buildFileuploadPoolColumns("fileupload.pool"))
|
|
|
|
|
|
|
|
|
|
// FileuploadPoolsQuery is a query on the pool table
|
|
|
|
|
type FileuploadPoolsQuery = *psql.ViewQuery[*FileuploadPool, FileuploadPoolSlice]
|
|
|
|
|
|
|
|
|
|
// fileuploadPoolR is where relationships are stored.
|
|
|
|
|
type fileuploadPoolR struct {
|
2026-02-14 05:40:27 +00:00
|
|
|
CreatorUser *User // fileupload.pool.pool_creator_id_fkey
|
|
|
|
|
CSVFileCSV *FileuploadCSV // fileupload.pool.pool_csv_file_fkey
|
|
|
|
|
PropertyOwnerPhoneE164Phone *CommsPhone // fileupload.pool.pool_property_owner_phone_e164_fkey
|
|
|
|
|
ResidentPhoneE164Phone *CommsPhone // fileupload.pool.pool_resident_phone_e164_fkey
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildFileuploadPoolColumns(alias string) fileuploadPoolColumns {
|
|
|
|
|
return fileuploadPoolColumns{
|
|
|
|
|
ColumnsExpr: expr.NewColumnsExpr(
|
2026-03-05 01:22:21 +00:00
|
|
|
"address_postal_code", "address_street", "committed", "created", "creator_id", "csv_file", "deleted", "geom", "h3cell", "id", "is_in_district", "is_new", "notes", "property_owner_name", "property_owner_phone_e164", "resident_owned", "resident_phone_e164", "line_number", "tags", "address_number", "address_locality", "address_region", "condition",
|
2026-02-09 19:03:27 +00:00
|
|
|
).WithParent("fileupload.pool"),
|
2026-02-14 05:40:27 +00:00
|
|
|
tableAlias: alias,
|
|
|
|
|
AddressPostalCode: psql.Quote(alias, "address_postal_code"),
|
|
|
|
|
AddressStreet: psql.Quote(alias, "address_street"),
|
|
|
|
|
Committed: psql.Quote(alias, "committed"),
|
|
|
|
|
Created: psql.Quote(alias, "created"),
|
|
|
|
|
CreatorID: psql.Quote(alias, "creator_id"),
|
|
|
|
|
CSVFile: psql.Quote(alias, "csv_file"),
|
|
|
|
|
Deleted: psql.Quote(alias, "deleted"),
|
2026-02-16 17:59:18 +00:00
|
|
|
Geom: psql.Quote(alias, "geom"),
|
2026-02-14 05:40:27 +00:00
|
|
|
H3cell: psql.Quote(alias, "h3cell"),
|
|
|
|
|
ID: psql.Quote(alias, "id"),
|
|
|
|
|
IsInDistrict: psql.Quote(alias, "is_in_district"),
|
|
|
|
|
IsNew: psql.Quote(alias, "is_new"),
|
|
|
|
|
Notes: psql.Quote(alias, "notes"),
|
|
|
|
|
PropertyOwnerName: psql.Quote(alias, "property_owner_name"),
|
|
|
|
|
PropertyOwnerPhoneE164: psql.Quote(alias, "property_owner_phone_e164"),
|
2026-02-16 17:59:18 +00:00
|
|
|
ResidentOwned: psql.Quote(alias, "resident_owned"),
|
2026-02-14 05:40:27 +00:00
|
|
|
ResidentPhoneE164: psql.Quote(alias, "resident_phone_e164"),
|
2026-02-16 17:59:18 +00:00
|
|
|
LineNumber: psql.Quote(alias, "line_number"),
|
2026-02-16 16:38:04 +00:00
|
|
|
Tags: psql.Quote(alias, "tags"),
|
2026-03-04 14:52:34 +00:00
|
|
|
AddressNumber: psql.Quote(alias, "address_number"),
|
|
|
|
|
AddressLocality: psql.Quote(alias, "address_locality"),
|
|
|
|
|
AddressRegion: psql.Quote(alias, "address_region"),
|
2026-03-05 01:22:21 +00:00
|
|
|
Condition: psql.Quote(alias, "condition"),
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type fileuploadPoolColumns struct {
|
|
|
|
|
expr.ColumnsExpr
|
2026-02-14 05:40:27 +00:00
|
|
|
tableAlias string
|
|
|
|
|
AddressPostalCode psql.Expression
|
|
|
|
|
AddressStreet psql.Expression
|
|
|
|
|
Committed psql.Expression
|
|
|
|
|
Created psql.Expression
|
|
|
|
|
CreatorID psql.Expression
|
|
|
|
|
CSVFile psql.Expression
|
|
|
|
|
Deleted psql.Expression
|
2026-02-16 17:59:18 +00:00
|
|
|
Geom psql.Expression
|
2026-02-14 05:40:27 +00:00
|
|
|
H3cell psql.Expression
|
|
|
|
|
ID psql.Expression
|
|
|
|
|
IsInDistrict psql.Expression
|
|
|
|
|
IsNew psql.Expression
|
|
|
|
|
Notes psql.Expression
|
|
|
|
|
PropertyOwnerName psql.Expression
|
|
|
|
|
PropertyOwnerPhoneE164 psql.Expression
|
2026-02-16 17:59:18 +00:00
|
|
|
ResidentOwned psql.Expression
|
2026-02-14 05:40:27 +00:00
|
|
|
ResidentPhoneE164 psql.Expression
|
2026-02-16 17:59:18 +00:00
|
|
|
LineNumber psql.Expression
|
2026-02-16 16:38:04 +00:00
|
|
|
Tags psql.Expression
|
2026-03-04 14:52:34 +00:00
|
|
|
AddressNumber psql.Expression
|
|
|
|
|
AddressLocality psql.Expression
|
|
|
|
|
AddressRegion psql.Expression
|
2026-03-05 01:22:21 +00:00
|
|
|
Condition psql.Expression
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c fileuploadPoolColumns) Alias() string {
|
|
|
|
|
return c.tableAlias
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPoolColumns) AliasedAs(alias string) fileuploadPoolColumns {
|
|
|
|
|
return buildFileuploadPoolColumns(alias)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FileuploadPoolSetter is used for insert/upsert/update operations
|
|
|
|
|
// All values are optional, and do not have to be set
|
|
|
|
|
// Generated columns are not included
|
|
|
|
|
type FileuploadPoolSetter struct {
|
2026-03-05 01:22:21 +00:00
|
|
|
AddressPostalCode omit.Val[string] `db:"address_postal_code" `
|
|
|
|
|
AddressStreet omit.Val[string] `db:"address_street" `
|
|
|
|
|
Committed omit.Val[bool] `db:"committed" `
|
|
|
|
|
Created omit.Val[time.Time] `db:"created" `
|
|
|
|
|
CreatorID omit.Val[int32] `db:"creator_id" `
|
|
|
|
|
CSVFile omit.Val[int32] `db:"csv_file" `
|
|
|
|
|
Deleted omitnull.Val[time.Time] `db:"deleted" `
|
|
|
|
|
Geom omitnull.Val[string] `db:"geom" `
|
|
|
|
|
H3cell omitnull.Val[string] `db:"h3cell" `
|
|
|
|
|
ID omit.Val[int32] `db:"id,pk" `
|
|
|
|
|
IsInDistrict omit.Val[bool] `db:"is_in_district" `
|
|
|
|
|
IsNew omit.Val[bool] `db:"is_new" `
|
|
|
|
|
Notes omit.Val[string] `db:"notes" `
|
|
|
|
|
PropertyOwnerName omit.Val[string] `db:"property_owner_name" `
|
|
|
|
|
PropertyOwnerPhoneE164 omitnull.Val[string] `db:"property_owner_phone_e164" `
|
|
|
|
|
ResidentOwned omitnull.Val[bool] `db:"resident_owned" `
|
|
|
|
|
ResidentPhoneE164 omitnull.Val[string] `db:"resident_phone_e164" `
|
|
|
|
|
LineNumber omit.Val[int32] `db:"line_number" `
|
|
|
|
|
Tags omit.Val[pgtypes.HStore] `db:"tags" `
|
|
|
|
|
AddressNumber omit.Val[string] `db:"address_number" `
|
|
|
|
|
AddressLocality omit.Val[string] `db:"address_locality" `
|
|
|
|
|
AddressRegion omit.Val[string] `db:"address_region" `
|
|
|
|
|
Condition omit.Val[enums.Poolconditiontype] `db:"condition" `
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s FileuploadPoolSetter) SetColumns() []string {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals := make([]string, 0, 23)
|
2026-02-09 19:03:27 +00:00
|
|
|
if s.AddressPostalCode.IsValue() {
|
|
|
|
|
vals = append(vals, "address_postal_code")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
|
|
|
vals = append(vals, "address_street")
|
|
|
|
|
}
|
|
|
|
|
if s.Committed.IsValue() {
|
|
|
|
|
vals = append(vals, "committed")
|
|
|
|
|
}
|
|
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
vals = append(vals, "created")
|
|
|
|
|
}
|
|
|
|
|
if s.CreatorID.IsValue() {
|
|
|
|
|
vals = append(vals, "creator_id")
|
|
|
|
|
}
|
|
|
|
|
if s.CSVFile.IsValue() {
|
|
|
|
|
vals = append(vals, "csv_file")
|
|
|
|
|
}
|
|
|
|
|
if !s.Deleted.IsUnset() {
|
|
|
|
|
vals = append(vals, "deleted")
|
|
|
|
|
}
|
2026-02-16 17:59:18 +00:00
|
|
|
if !s.Geom.IsUnset() {
|
|
|
|
|
vals = append(vals, "geom")
|
|
|
|
|
}
|
2026-02-09 19:03:27 +00:00
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
vals = append(vals, "h3cell")
|
|
|
|
|
}
|
|
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
vals = append(vals, "id")
|
|
|
|
|
}
|
|
|
|
|
if s.IsInDistrict.IsValue() {
|
|
|
|
|
vals = append(vals, "is_in_district")
|
|
|
|
|
}
|
|
|
|
|
if s.IsNew.IsValue() {
|
|
|
|
|
vals = append(vals, "is_new")
|
|
|
|
|
}
|
|
|
|
|
if s.Notes.IsValue() {
|
|
|
|
|
vals = append(vals, "notes")
|
|
|
|
|
}
|
|
|
|
|
if s.PropertyOwnerName.IsValue() {
|
|
|
|
|
vals = append(vals, "property_owner_name")
|
|
|
|
|
}
|
2026-02-14 05:40:27 +00:00
|
|
|
if !s.PropertyOwnerPhoneE164.IsUnset() {
|
|
|
|
|
vals = append(vals, "property_owner_phone_e164")
|
|
|
|
|
}
|
2026-02-16 17:59:18 +00:00
|
|
|
if !s.ResidentOwned.IsUnset() {
|
|
|
|
|
vals = append(vals, "resident_owned")
|
|
|
|
|
}
|
2026-02-14 05:40:27 +00:00
|
|
|
if !s.ResidentPhoneE164.IsUnset() {
|
|
|
|
|
vals = append(vals, "resident_phone_e164")
|
|
|
|
|
}
|
2026-02-16 17:59:18 +00:00
|
|
|
if s.LineNumber.IsValue() {
|
|
|
|
|
vals = append(vals, "line_number")
|
2026-02-16 16:38:04 +00:00
|
|
|
}
|
|
|
|
|
if s.Tags.IsValue() {
|
|
|
|
|
vals = append(vals, "tags")
|
|
|
|
|
}
|
2026-03-04 14:52:34 +00:00
|
|
|
if s.AddressNumber.IsValue() {
|
|
|
|
|
vals = append(vals, "address_number")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressLocality.IsValue() {
|
|
|
|
|
vals = append(vals, "address_locality")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
|
|
|
vals = append(vals, "address_region")
|
|
|
|
|
}
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.Condition.IsValue() {
|
|
|
|
|
vals = append(vals, "condition")
|
|
|
|
|
}
|
2026-02-09 19:03:27 +00:00
|
|
|
return vals
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s FileuploadPoolSetter) Overwrite(t *FileuploadPool) {
|
|
|
|
|
if s.AddressPostalCode.IsValue() {
|
|
|
|
|
t.AddressPostalCode = s.AddressPostalCode.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
|
|
|
t.AddressStreet = s.AddressStreet.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.Committed.IsValue() {
|
|
|
|
|
t.Committed = s.Committed.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
t.Created = s.Created.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.CreatorID.IsValue() {
|
|
|
|
|
t.CreatorID = s.CreatorID.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.CSVFile.IsValue() {
|
|
|
|
|
t.CSVFile = s.CSVFile.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if !s.Deleted.IsUnset() {
|
|
|
|
|
t.Deleted = s.Deleted.MustGetNull()
|
|
|
|
|
}
|
2026-02-16 17:59:18 +00:00
|
|
|
if !s.Geom.IsUnset() {
|
|
|
|
|
t.Geom = s.Geom.MustGetNull()
|
|
|
|
|
}
|
2026-02-09 19:03:27 +00:00
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
t.H3cell = s.H3cell.MustGetNull()
|
|
|
|
|
}
|
|
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
t.ID = s.ID.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.IsInDistrict.IsValue() {
|
|
|
|
|
t.IsInDistrict = s.IsInDistrict.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.IsNew.IsValue() {
|
|
|
|
|
t.IsNew = s.IsNew.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.Notes.IsValue() {
|
|
|
|
|
t.Notes = s.Notes.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.PropertyOwnerName.IsValue() {
|
|
|
|
|
t.PropertyOwnerName = s.PropertyOwnerName.MustGet()
|
|
|
|
|
}
|
2026-02-14 05:40:27 +00:00
|
|
|
if !s.PropertyOwnerPhoneE164.IsUnset() {
|
|
|
|
|
t.PropertyOwnerPhoneE164 = s.PropertyOwnerPhoneE164.MustGetNull()
|
|
|
|
|
}
|
2026-02-16 17:59:18 +00:00
|
|
|
if !s.ResidentOwned.IsUnset() {
|
|
|
|
|
t.ResidentOwned = s.ResidentOwned.MustGetNull()
|
|
|
|
|
}
|
2026-02-14 05:40:27 +00:00
|
|
|
if !s.ResidentPhoneE164.IsUnset() {
|
|
|
|
|
t.ResidentPhoneE164 = s.ResidentPhoneE164.MustGetNull()
|
|
|
|
|
}
|
2026-02-16 17:59:18 +00:00
|
|
|
if s.LineNumber.IsValue() {
|
|
|
|
|
t.LineNumber = s.LineNumber.MustGet()
|
2026-02-16 16:38:04 +00:00
|
|
|
}
|
|
|
|
|
if s.Tags.IsValue() {
|
|
|
|
|
t.Tags = s.Tags.MustGet()
|
|
|
|
|
}
|
2026-03-04 14:52:34 +00:00
|
|
|
if s.AddressNumber.IsValue() {
|
|
|
|
|
t.AddressNumber = s.AddressNumber.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressLocality.IsValue() {
|
|
|
|
|
t.AddressLocality = s.AddressLocality.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
|
|
|
t.AddressRegion = s.AddressRegion.MustGet()
|
|
|
|
|
}
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.Condition.IsValue() {
|
|
|
|
|
t.Condition = s.Condition.MustGet()
|
|
|
|
|
}
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *FileuploadPoolSetter) Apply(q *dialect.InsertQuery) {
|
|
|
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
|
|
|
return FileuploadPools.BeforeInsertHooks.RunHooks(ctx, exec, s)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals := make([]bob.Expression, 23)
|
2026-03-04 14:52:34 +00:00
|
|
|
if s.AddressPostalCode.IsValue() {
|
|
|
|
|
vals[0] = psql.Arg(s.AddressPostalCode.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[0] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 14:52:34 +00:00
|
|
|
if s.AddressStreet.IsValue() {
|
|
|
|
|
vals[1] = psql.Arg(s.AddressStreet.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[1] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 14:52:34 +00:00
|
|
|
if s.Committed.IsValue() {
|
|
|
|
|
vals[2] = psql.Arg(s.Committed.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[2] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
vals[3] = psql.Arg(s.Created.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[3] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.CreatorID.IsValue() {
|
|
|
|
|
vals[4] = psql.Arg(s.CreatorID.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[4] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.CSVFile.IsValue() {
|
|
|
|
|
vals[5] = psql.Arg(s.CSVFile.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[5] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if !s.Deleted.IsUnset() {
|
|
|
|
|
vals[6] = psql.Arg(s.Deleted.MustGetNull())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[6] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if !s.Geom.IsUnset() {
|
|
|
|
|
vals[7] = psql.Arg(s.Geom.MustGetNull())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[7] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
vals[8] = psql.Arg(s.H3cell.MustGetNull())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[8] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
vals[9] = psql.Arg(s.ID.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[9] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.IsInDistrict.IsValue() {
|
|
|
|
|
vals[10] = psql.Arg(s.IsInDistrict.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[10] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.IsNew.IsValue() {
|
|
|
|
|
vals[11] = psql.Arg(s.IsNew.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[11] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.Notes.IsValue() {
|
|
|
|
|
vals[12] = psql.Arg(s.Notes.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[12] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.PropertyOwnerName.IsValue() {
|
|
|
|
|
vals[13] = psql.Arg(s.PropertyOwnerName.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
vals[13] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if !s.PropertyOwnerPhoneE164.IsUnset() {
|
|
|
|
|
vals[14] = psql.Arg(s.PropertyOwnerPhoneE164.MustGetNull())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[14] = psql.Raw("DEFAULT")
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if !s.ResidentOwned.IsUnset() {
|
|
|
|
|
vals[15] = psql.Arg(s.ResidentOwned.MustGetNull())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[15] = psql.Raw("DEFAULT")
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if !s.ResidentPhoneE164.IsUnset() {
|
|
|
|
|
vals[16] = psql.Arg(s.ResidentPhoneE164.MustGetNull())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[16] = psql.Raw("DEFAULT")
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.LineNumber.IsValue() {
|
|
|
|
|
vals[17] = psql.Arg(s.LineNumber.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[17] = psql.Raw("DEFAULT")
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.Tags.IsValue() {
|
|
|
|
|
vals[18] = psql.Arg(s.Tags.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[18] = psql.Raw("DEFAULT")
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.AddressNumber.IsValue() {
|
|
|
|
|
vals[19] = psql.Arg(s.AddressNumber.MustGet())
|
2026-02-09 19:03:27 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[19] = psql.Raw("DEFAULT")
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.AddressLocality.IsValue() {
|
|
|
|
|
vals[20] = psql.Arg(s.AddressLocality.MustGet())
|
2026-02-16 16:38:04 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[20] = psql.Raw("DEFAULT")
|
2026-02-16 16:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.AddressRegion.IsValue() {
|
|
|
|
|
vals[21] = psql.Arg(s.AddressRegion.MustGet())
|
2026-03-04 14:52:34 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[21] = psql.Raw("DEFAULT")
|
2026-03-04 14:52:34 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.Condition.IsValue() {
|
|
|
|
|
vals[22] = psql.Arg(s.Condition.MustGet())
|
2026-03-04 14:52:34 +00:00
|
|
|
} else {
|
2026-03-04 20:59:57 +00:00
|
|
|
vals[22] = psql.Raw("DEFAULT")
|
2026-03-04 14:52:34 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-09 19:03:27 +00:00
|
|
|
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s FileuploadPoolSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
|
|
|
return um.Set(s.Expressions()...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s FileuploadPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
2026-03-04 20:59:57 +00:00
|
|
|
exprs := make([]bob.Expression, 0, 23)
|
2026-02-09 19:03:27 +00:00
|
|
|
|
|
|
|
|
if s.AddressPostalCode.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_postal_code")...),
|
|
|
|
|
psql.Arg(s.AddressPostalCode),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_street")...),
|
|
|
|
|
psql.Arg(s.AddressStreet),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Committed.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "committed")...),
|
|
|
|
|
psql.Arg(s.Committed),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "created")...),
|
|
|
|
|
psql.Arg(s.Created),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.CreatorID.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "creator_id")...),
|
|
|
|
|
psql.Arg(s.CreatorID),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.CSVFile.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "csv_file")...),
|
|
|
|
|
psql.Arg(s.CSVFile),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !s.Deleted.IsUnset() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "deleted")...),
|
|
|
|
|
psql.Arg(s.Deleted),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 17:59:18 +00:00
|
|
|
if !s.Geom.IsUnset() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "geom")...),
|
|
|
|
|
psql.Arg(s.Geom),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 19:03:27 +00:00
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "h3cell")...),
|
|
|
|
|
psql.Arg(s.H3cell),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "id")...),
|
|
|
|
|
psql.Arg(s.ID),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.IsInDistrict.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "is_in_district")...),
|
|
|
|
|
psql.Arg(s.IsInDistrict),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.IsNew.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "is_new")...),
|
|
|
|
|
psql.Arg(s.IsNew),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Notes.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "notes")...),
|
|
|
|
|
psql.Arg(s.Notes),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.PropertyOwnerName.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "property_owner_name")...),
|
|
|
|
|
psql.Arg(s.PropertyOwnerName),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 17:59:18 +00:00
|
|
|
if !s.PropertyOwnerPhoneE164.IsUnset() {
|
2026-02-09 19:03:27 +00:00
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
2026-02-16 17:59:18 +00:00
|
|
|
psql.Quote(append(prefix, "property_owner_phone_e164")...),
|
|
|
|
|
psql.Arg(s.PropertyOwnerPhoneE164),
|
2026-02-09 19:03:27 +00:00
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 17:59:18 +00:00
|
|
|
if !s.ResidentOwned.IsUnset() {
|
2026-02-09 19:03:27 +00:00
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
2026-02-16 17:59:18 +00:00
|
|
|
psql.Quote(append(prefix, "resident_owned")...),
|
|
|
|
|
psql.Arg(s.ResidentOwned),
|
2026-02-09 19:03:27 +00:00
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-14 05:40:27 +00:00
|
|
|
if !s.ResidentPhoneE164.IsUnset() {
|
2026-02-09 19:03:27 +00:00
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
2026-02-14 05:40:27 +00:00
|
|
|
psql.Quote(append(prefix, "resident_phone_e164")...),
|
|
|
|
|
psql.Arg(s.ResidentPhoneE164),
|
2026-02-09 19:03:27 +00:00
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 17:59:18 +00:00
|
|
|
if s.LineNumber.IsValue() {
|
2026-02-16 16:38:04 +00:00
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
2026-02-16 17:59:18 +00:00
|
|
|
psql.Quote(append(prefix, "line_number")...),
|
|
|
|
|
psql.Arg(s.LineNumber),
|
2026-02-16 16:38:04 +00:00
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Tags.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "tags")...),
|
|
|
|
|
psql.Arg(s.Tags),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 14:52:34 +00:00
|
|
|
if s.AddressNumber.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_number")...),
|
|
|
|
|
psql.Arg(s.AddressNumber),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressLocality.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_locality")...),
|
|
|
|
|
psql.Arg(s.AddressLocality),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_region")...),
|
|
|
|
|
psql.Arg(s.AddressRegion),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 01:22:21 +00:00
|
|
|
if s.Condition.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "condition")...),
|
|
|
|
|
psql.Arg(s.Condition),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 19:03:27 +00:00
|
|
|
return exprs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FindFileuploadPool retrieves a single record by primary key
|
|
|
|
|
// If cols is empty Find will return all columns.
|
2026-02-16 17:59:18 +00:00
|
|
|
func FindFileuploadPool(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*FileuploadPool, error) {
|
2026-02-09 19:03:27 +00:00
|
|
|
if len(cols) == 0 {
|
|
|
|
|
return FileuploadPools.Query(
|
|
|
|
|
sm.Where(FileuploadPools.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
|
|
|
).One(ctx, exec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FileuploadPools.Query(
|
|
|
|
|
sm.Where(FileuploadPools.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
|
|
|
sm.Columns(FileuploadPools.Columns.Only(cols...)),
|
|
|
|
|
).One(ctx, exec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FileuploadPoolExists checks the presence of a single record by primary key
|
2026-02-16 17:59:18 +00:00
|
|
|
func FileuploadPoolExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
|
2026-02-09 19:03:27 +00:00
|
|
|
return FileuploadPools.Query(
|
|
|
|
|
sm.Where(FileuploadPools.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
|
|
|
).Exists(ctx, exec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AfterQueryHook is called after FileuploadPool is retrieved from the database
|
|
|
|
|
func (o *FileuploadPool) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
switch queryType {
|
|
|
|
|
case bob.QueryTypeSelect:
|
|
|
|
|
ctx, err = FileuploadPools.AfterSelectHooks.RunHooks(ctx, exec, FileuploadPoolSlice{o})
|
|
|
|
|
case bob.QueryTypeInsert:
|
|
|
|
|
ctx, err = FileuploadPools.AfterInsertHooks.RunHooks(ctx, exec, FileuploadPoolSlice{o})
|
|
|
|
|
case bob.QueryTypeUpdate:
|
|
|
|
|
ctx, err = FileuploadPools.AfterUpdateHooks.RunHooks(ctx, exec, FileuploadPoolSlice{o})
|
|
|
|
|
case bob.QueryTypeDelete:
|
|
|
|
|
ctx, err = FileuploadPools.AfterDeleteHooks.RunHooks(ctx, exec, FileuploadPoolSlice{o})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// primaryKeyVals returns the primary key values of the FileuploadPool
|
|
|
|
|
func (o *FileuploadPool) primaryKeyVals() bob.Expression {
|
2026-02-16 17:59:18 +00:00
|
|
|
return psql.Arg(o.ID)
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o *FileuploadPool) pkEQ() dialect.Expression {
|
2026-02-16 17:59:18 +00:00
|
|
|
return psql.Quote("fileupload.pool", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
2026-02-09 19:03:27 +00:00
|
|
|
return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update uses an executor to update the FileuploadPool
|
|
|
|
|
func (o *FileuploadPool) Update(ctx context.Context, exec bob.Executor, s *FileuploadPoolSetter) error {
|
|
|
|
|
v, err := FileuploadPools.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 FileuploadPool record with an executor
|
|
|
|
|
func (o *FileuploadPool) Delete(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
_, err := FileuploadPools.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reload refreshes the FileuploadPool using the executor
|
|
|
|
|
func (o *FileuploadPool) Reload(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
o2, err := FileuploadPools.Query(
|
|
|
|
|
sm.Where(FileuploadPools.Columns.ID.EQ(psql.Arg(o.ID))),
|
|
|
|
|
).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
o2.R = o.R
|
|
|
|
|
*o = *o2
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AfterQueryHook is called after FileuploadPoolSlice is retrieved from the database
|
|
|
|
|
func (o FileuploadPoolSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
switch queryType {
|
|
|
|
|
case bob.QueryTypeSelect:
|
|
|
|
|
ctx, err = FileuploadPools.AfterSelectHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
case bob.QueryTypeInsert:
|
|
|
|
|
ctx, err = FileuploadPools.AfterInsertHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
case bob.QueryTypeUpdate:
|
|
|
|
|
ctx, err = FileuploadPools.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
case bob.QueryTypeDelete:
|
|
|
|
|
ctx, err = FileuploadPools.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o FileuploadPoolSlice) pkIN() dialect.Expression {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return psql.Raw("NULL")
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 17:59:18 +00:00
|
|
|
return psql.Quote("fileupload.pool", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
2026-02-09 19:03:27 +00:00
|
|
|
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 FileuploadPoolSlice) copyMatchingRows(from ...*FileuploadPool) {
|
|
|
|
|
for i, old := range o {
|
|
|
|
|
for _, new := range from {
|
|
|
|
|
if new.ID != old.ID {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
new.R = old.R
|
|
|
|
|
o[i] = new
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
|
|
|
|
|
func (o FileuploadPoolSlice) 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 FileuploadPools.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 *FileuploadPool:
|
|
|
|
|
o.copyMatchingRows(retrieved)
|
|
|
|
|
case []*FileuploadPool:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
case FileuploadPoolSlice:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
default:
|
|
|
|
|
// If the retrieved value is not a FileuploadPool or a slice of FileuploadPool
|
|
|
|
|
// then run the AfterUpdateHooks on the slice
|
|
|
|
|
_, err = FileuploadPools.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
|
|
|
|
func (o FileuploadPoolSlice) 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 FileuploadPools.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 *FileuploadPool:
|
|
|
|
|
o.copyMatchingRows(retrieved)
|
|
|
|
|
case []*FileuploadPool:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
case FileuploadPoolSlice:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
default:
|
|
|
|
|
// If the retrieved value is not a FileuploadPool or a slice of FileuploadPool
|
|
|
|
|
// then run the AfterDeleteHooks on the slice
|
|
|
|
|
_, err = FileuploadPools.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o FileuploadPoolSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals FileuploadPoolSetter) error {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := FileuploadPools.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o FileuploadPoolSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := FileuploadPools.Delete(o.DeleteMod()).Exec(ctx, exec)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o FileuploadPoolSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o2, err := FileuploadPools.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o.copyMatchingRows(o2...)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreatorUser starts a query for related objects on user_
|
|
|
|
|
func (o *FileuploadPool) CreatorUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
|
|
|
|
|
return Users.Query(append(mods,
|
|
|
|
|
sm.Where(Users.Columns.ID.EQ(psql.Arg(o.CreatorID))),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (os FileuploadPoolSlice) CreatorUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
|
|
|
|
|
pkCreatorID := make(pgtypes.Array[int32], 0, len(os))
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
pkCreatorID = append(pkCreatorID, o.CreatorID)
|
|
|
|
|
}
|
|
|
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
|
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkCreatorID), "integer[]")),
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
return Users.Query(append(mods,
|
|
|
|
|
sm.Where(psql.Group(Users.Columns.ID).OP("IN", PKArgExpr)),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CSVFileCSV starts a query for related objects on fileupload.csv
|
|
|
|
|
func (o *FileuploadPool) CSVFileCSV(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadCSVSQuery {
|
|
|
|
|
return FileuploadCSVS.Query(append(mods,
|
|
|
|
|
sm.Where(FileuploadCSVS.Columns.FileID.EQ(psql.Arg(o.CSVFile))),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (os FileuploadPoolSlice) CSVFileCSV(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadCSVSQuery {
|
|
|
|
|
pkCSVFile := make(pgtypes.Array[int32], 0, len(os))
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
pkCSVFile = append(pkCSVFile, o.CSVFile)
|
|
|
|
|
}
|
|
|
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
|
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkCSVFile), "integer[]")),
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
return FileuploadCSVS.Query(append(mods,
|
|
|
|
|
sm.Where(psql.Group(FileuploadCSVS.Columns.FileID).OP("IN", PKArgExpr)),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-14 05:40:27 +00:00
|
|
|
// PropertyOwnerPhoneE164Phone starts a query for related objects on comms.phone
|
|
|
|
|
func (o *FileuploadPool) PropertyOwnerPhoneE164Phone(mods ...bob.Mod[*dialect.SelectQuery]) CommsPhonesQuery {
|
|
|
|
|
return CommsPhones.Query(append(mods,
|
|
|
|
|
sm.Where(CommsPhones.Columns.E164.EQ(psql.Arg(o.PropertyOwnerPhoneE164))),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (os FileuploadPoolSlice) PropertyOwnerPhoneE164Phone(mods ...bob.Mod[*dialect.SelectQuery]) CommsPhonesQuery {
|
|
|
|
|
pkPropertyOwnerPhoneE164 := make(pgtypes.Array[null.Val[string]], 0, len(os))
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
pkPropertyOwnerPhoneE164 = append(pkPropertyOwnerPhoneE164, o.PropertyOwnerPhoneE164)
|
|
|
|
|
}
|
|
|
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
|
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkPropertyOwnerPhoneE164), "text[]")),
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
return CommsPhones.Query(append(mods,
|
|
|
|
|
sm.Where(psql.Group(CommsPhones.Columns.E164).OP("IN", PKArgExpr)),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ResidentPhoneE164Phone starts a query for related objects on comms.phone
|
|
|
|
|
func (o *FileuploadPool) ResidentPhoneE164Phone(mods ...bob.Mod[*dialect.SelectQuery]) CommsPhonesQuery {
|
|
|
|
|
return CommsPhones.Query(append(mods,
|
|
|
|
|
sm.Where(CommsPhones.Columns.E164.EQ(psql.Arg(o.ResidentPhoneE164))),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (os FileuploadPoolSlice) ResidentPhoneE164Phone(mods ...bob.Mod[*dialect.SelectQuery]) CommsPhonesQuery {
|
|
|
|
|
pkResidentPhoneE164 := make(pgtypes.Array[null.Val[string]], 0, len(os))
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
pkResidentPhoneE164 = append(pkResidentPhoneE164, o.ResidentPhoneE164)
|
|
|
|
|
}
|
|
|
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
|
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkResidentPhoneE164), "text[]")),
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
return CommsPhones.Query(append(mods,
|
|
|
|
|
sm.Where(psql.Group(CommsPhones.Columns.E164).OP("IN", PKArgExpr)),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 19:03:27 +00:00
|
|
|
func attachFileuploadPoolCreatorUser0(ctx context.Context, exec bob.Executor, count int, fileuploadPool0 *FileuploadPool, user1 *User) (*FileuploadPool, error) {
|
|
|
|
|
setter := &FileuploadPoolSetter{
|
|
|
|
|
CreatorID: omit.From(user1.ID),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := fileuploadPool0.Update(ctx, exec, setter)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("attachFileuploadPoolCreatorUser0: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fileuploadPool0, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) InsertCreatorUser(ctx context.Context, exec bob.Executor, related *UserSetter) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
user1, err := Users.Insert(related).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolCreatorUser0(ctx, exec, 1, fileuploadPool0, user1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.CreatorUser = user1
|
|
|
|
|
|
2026-02-26 18:18:33 +00:00
|
|
|
user1.R.FileuploadPool = append(user1.R.FileuploadPool, fileuploadPool0)
|
2026-02-09 19:03:27 +00:00
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) AttachCreatorUser(ctx context.Context, exec bob.Executor, user1 *User) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolCreatorUser0(ctx, exec, 1, fileuploadPool0, user1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.CreatorUser = user1
|
|
|
|
|
|
2026-02-26 18:18:33 +00:00
|
|
|
user1.R.FileuploadPool = append(user1.R.FileuploadPool, fileuploadPool0)
|
2026-02-09 19:03:27 +00:00
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func attachFileuploadPoolCSVFileCSV0(ctx context.Context, exec bob.Executor, count int, fileuploadPool0 *FileuploadPool, fileuploadCSV1 *FileuploadCSV) (*FileuploadPool, error) {
|
|
|
|
|
setter := &FileuploadPoolSetter{
|
|
|
|
|
CSVFile: omit.From(fileuploadCSV1.FileID),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := fileuploadPool0.Update(ctx, exec, setter)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("attachFileuploadPoolCSVFileCSV0: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fileuploadPool0, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) InsertCSVFileCSV(ctx context.Context, exec bob.Executor, related *FileuploadCSVSetter) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
fileuploadCSV1, err := FileuploadCSVS.Insert(related).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolCSVFileCSV0(ctx, exec, 1, fileuploadPool0, fileuploadCSV1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.CSVFileCSV = fileuploadCSV1
|
|
|
|
|
|
|
|
|
|
fileuploadCSV1.R.CSVFilePools = append(fileuploadCSV1.R.CSVFilePools, fileuploadPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) AttachCSVFileCSV(ctx context.Context, exec bob.Executor, fileuploadCSV1 *FileuploadCSV) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolCSVFileCSV0(ctx, exec, 1, fileuploadPool0, fileuploadCSV1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.CSVFileCSV = fileuploadCSV1
|
|
|
|
|
|
|
|
|
|
fileuploadCSV1.R.CSVFilePools = append(fileuploadCSV1.R.CSVFilePools, fileuploadPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-14 05:40:27 +00:00
|
|
|
func attachFileuploadPoolPropertyOwnerPhoneE164Phone0(ctx context.Context, exec bob.Executor, count int, fileuploadPool0 *FileuploadPool, commsPhone1 *CommsPhone) (*FileuploadPool, error) {
|
|
|
|
|
setter := &FileuploadPoolSetter{
|
|
|
|
|
PropertyOwnerPhoneE164: omitnull.From(commsPhone1.E164),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := fileuploadPool0.Update(ctx, exec, setter)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("attachFileuploadPoolPropertyOwnerPhoneE164Phone0: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fileuploadPool0, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) InsertPropertyOwnerPhoneE164Phone(ctx context.Context, exec bob.Executor, related *CommsPhoneSetter) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
commsPhone1, err := CommsPhones.Insert(related).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolPropertyOwnerPhoneE164Phone0(ctx, exec, 1, fileuploadPool0, commsPhone1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.PropertyOwnerPhoneE164Phone = commsPhone1
|
|
|
|
|
|
|
|
|
|
commsPhone1.R.PropertyOwnerPhoneE164Pools = append(commsPhone1.R.PropertyOwnerPhoneE164Pools, fileuploadPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) AttachPropertyOwnerPhoneE164Phone(ctx context.Context, exec bob.Executor, commsPhone1 *CommsPhone) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolPropertyOwnerPhoneE164Phone0(ctx, exec, 1, fileuploadPool0, commsPhone1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.PropertyOwnerPhoneE164Phone = commsPhone1
|
|
|
|
|
|
|
|
|
|
commsPhone1.R.PropertyOwnerPhoneE164Pools = append(commsPhone1.R.PropertyOwnerPhoneE164Pools, fileuploadPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func attachFileuploadPoolResidentPhoneE164Phone0(ctx context.Context, exec bob.Executor, count int, fileuploadPool0 *FileuploadPool, commsPhone1 *CommsPhone) (*FileuploadPool, error) {
|
|
|
|
|
setter := &FileuploadPoolSetter{
|
|
|
|
|
ResidentPhoneE164: omitnull.From(commsPhone1.E164),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := fileuploadPool0.Update(ctx, exec, setter)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("attachFileuploadPoolResidentPhoneE164Phone0: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fileuploadPool0, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) InsertResidentPhoneE164Phone(ctx context.Context, exec bob.Executor, related *CommsPhoneSetter) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
commsPhone1, err := CommsPhones.Insert(related).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolResidentPhoneE164Phone0(ctx, exec, 1, fileuploadPool0, commsPhone1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.ResidentPhoneE164Phone = commsPhone1
|
|
|
|
|
|
|
|
|
|
commsPhone1.R.ResidentPhoneE164Pools = append(commsPhone1.R.ResidentPhoneE164Pools, fileuploadPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPool0 *FileuploadPool) AttachResidentPhoneE164Phone(ctx context.Context, exec bob.Executor, commsPhone1 *CommsPhone) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
_, err = attachFileuploadPoolResidentPhoneE164Phone0(ctx, exec, 1, fileuploadPool0, commsPhone1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadPool0.R.ResidentPhoneE164Phone = commsPhone1
|
|
|
|
|
|
|
|
|
|
commsPhone1.R.ResidentPhoneE164Pools = append(commsPhone1.R.ResidentPhoneE164Pools, fileuploadPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 19:03:27 +00:00
|
|
|
type fileuploadPoolWhere[Q psql.Filterable] struct {
|
2026-02-14 05:40:27 +00:00
|
|
|
AddressPostalCode psql.WhereMod[Q, string]
|
|
|
|
|
AddressStreet psql.WhereMod[Q, string]
|
|
|
|
|
Committed psql.WhereMod[Q, bool]
|
|
|
|
|
Created psql.WhereMod[Q, time.Time]
|
|
|
|
|
CreatorID psql.WhereMod[Q, int32]
|
|
|
|
|
CSVFile psql.WhereMod[Q, int32]
|
|
|
|
|
Deleted psql.WhereNullMod[Q, time.Time]
|
2026-02-16 17:59:18 +00:00
|
|
|
Geom psql.WhereNullMod[Q, string]
|
2026-02-14 05:40:27 +00:00
|
|
|
H3cell psql.WhereNullMod[Q, string]
|
|
|
|
|
ID psql.WhereMod[Q, int32]
|
|
|
|
|
IsInDistrict psql.WhereMod[Q, bool]
|
|
|
|
|
IsNew psql.WhereMod[Q, bool]
|
|
|
|
|
Notes psql.WhereMod[Q, string]
|
|
|
|
|
PropertyOwnerName psql.WhereMod[Q, string]
|
|
|
|
|
PropertyOwnerPhoneE164 psql.WhereNullMod[Q, string]
|
2026-02-16 17:59:18 +00:00
|
|
|
ResidentOwned psql.WhereNullMod[Q, bool]
|
2026-02-14 05:40:27 +00:00
|
|
|
ResidentPhoneE164 psql.WhereNullMod[Q, string]
|
2026-02-16 17:59:18 +00:00
|
|
|
LineNumber psql.WhereMod[Q, int32]
|
2026-02-16 16:38:04 +00:00
|
|
|
Tags psql.WhereMod[Q, pgtypes.HStore]
|
2026-03-04 14:52:34 +00:00
|
|
|
AddressNumber psql.WhereMod[Q, string]
|
|
|
|
|
AddressLocality psql.WhereMod[Q, string]
|
|
|
|
|
AddressRegion psql.WhereMod[Q, string]
|
2026-03-05 01:22:21 +00:00
|
|
|
Condition psql.WhereMod[Q, enums.Poolconditiontype]
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fileuploadPoolWhere[Q]) AliasedAs(alias string) fileuploadPoolWhere[Q] {
|
|
|
|
|
return buildFileuploadPoolWhere[Q](buildFileuploadPoolColumns(alias))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildFileuploadPoolWhere[Q psql.Filterable](cols fileuploadPoolColumns) fileuploadPoolWhere[Q] {
|
|
|
|
|
return fileuploadPoolWhere[Q]{
|
2026-02-14 05:40:27 +00:00
|
|
|
AddressPostalCode: psql.Where[Q, string](cols.AddressPostalCode),
|
|
|
|
|
AddressStreet: psql.Where[Q, string](cols.AddressStreet),
|
|
|
|
|
Committed: psql.Where[Q, bool](cols.Committed),
|
|
|
|
|
Created: psql.Where[Q, time.Time](cols.Created),
|
|
|
|
|
CreatorID: psql.Where[Q, int32](cols.CreatorID),
|
|
|
|
|
CSVFile: psql.Where[Q, int32](cols.CSVFile),
|
|
|
|
|
Deleted: psql.WhereNull[Q, time.Time](cols.Deleted),
|
2026-02-16 17:59:18 +00:00
|
|
|
Geom: psql.WhereNull[Q, string](cols.Geom),
|
2026-02-14 05:40:27 +00:00
|
|
|
H3cell: psql.WhereNull[Q, string](cols.H3cell),
|
|
|
|
|
ID: psql.Where[Q, int32](cols.ID),
|
|
|
|
|
IsInDistrict: psql.Where[Q, bool](cols.IsInDistrict),
|
|
|
|
|
IsNew: psql.Where[Q, bool](cols.IsNew),
|
|
|
|
|
Notes: psql.Where[Q, string](cols.Notes),
|
|
|
|
|
PropertyOwnerName: psql.Where[Q, string](cols.PropertyOwnerName),
|
|
|
|
|
PropertyOwnerPhoneE164: psql.WhereNull[Q, string](cols.PropertyOwnerPhoneE164),
|
2026-02-16 17:59:18 +00:00
|
|
|
ResidentOwned: psql.WhereNull[Q, bool](cols.ResidentOwned),
|
2026-02-14 05:40:27 +00:00
|
|
|
ResidentPhoneE164: psql.WhereNull[Q, string](cols.ResidentPhoneE164),
|
2026-02-16 17:59:18 +00:00
|
|
|
LineNumber: psql.Where[Q, int32](cols.LineNumber),
|
2026-02-16 16:38:04 +00:00
|
|
|
Tags: psql.Where[Q, pgtypes.HStore](cols.Tags),
|
2026-03-04 14:52:34 +00:00
|
|
|
AddressNumber: psql.Where[Q, string](cols.AddressNumber),
|
|
|
|
|
AddressLocality: psql.Where[Q, string](cols.AddressLocality),
|
|
|
|
|
AddressRegion: psql.Where[Q, string](cols.AddressRegion),
|
2026-03-05 01:22:21 +00:00
|
|
|
Condition: psql.Where[Q, enums.Poolconditiontype](cols.Condition),
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o *FileuploadPool) Preload(name string, retrieved any) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch name {
|
|
|
|
|
case "CreatorUser":
|
|
|
|
|
rel, ok := retrieved.(*User)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("fileuploadPool cannot load %T as %q", retrieved, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o.R.CreatorUser = rel
|
|
|
|
|
|
|
|
|
|
if rel != nil {
|
2026-02-26 18:18:33 +00:00
|
|
|
rel.R.FileuploadPool = FileuploadPoolSlice{o}
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
case "CSVFileCSV":
|
|
|
|
|
rel, ok := retrieved.(*FileuploadCSV)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("fileuploadPool cannot load %T as %q", retrieved, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o.R.CSVFileCSV = rel
|
|
|
|
|
|
|
|
|
|
if rel != nil {
|
|
|
|
|
rel.R.CSVFilePools = FileuploadPoolSlice{o}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
2026-02-14 05:40:27 +00:00
|
|
|
case "PropertyOwnerPhoneE164Phone":
|
|
|
|
|
rel, ok := retrieved.(*CommsPhone)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("fileuploadPool cannot load %T as %q", retrieved, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o.R.PropertyOwnerPhoneE164Phone = rel
|
|
|
|
|
|
|
|
|
|
if rel != nil {
|
|
|
|
|
rel.R.PropertyOwnerPhoneE164Pools = FileuploadPoolSlice{o}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
case "ResidentPhoneE164Phone":
|
|
|
|
|
rel, ok := retrieved.(*CommsPhone)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("fileuploadPool cannot load %T as %q", retrieved, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o.R.ResidentPhoneE164Phone = rel
|
|
|
|
|
|
|
|
|
|
if rel != nil {
|
|
|
|
|
rel.R.ResidentPhoneE164Pools = FileuploadPoolSlice{o}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
2026-02-09 19:03:27 +00:00
|
|
|
default:
|
|
|
|
|
return fmt.Errorf("fileuploadPool has no relationship %q", name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type fileuploadPoolPreloader struct {
|
2026-02-14 05:40:27 +00:00
|
|
|
CreatorUser func(...psql.PreloadOption) psql.Preloader
|
|
|
|
|
CSVFileCSV func(...psql.PreloadOption) psql.Preloader
|
|
|
|
|
PropertyOwnerPhoneE164Phone func(...psql.PreloadOption) psql.Preloader
|
|
|
|
|
ResidentPhoneE164Phone func(...psql.PreloadOption) psql.Preloader
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildFileuploadPoolPreloader() fileuploadPoolPreloader {
|
|
|
|
|
return fileuploadPoolPreloader{
|
|
|
|
|
CreatorUser: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
|
|
|
return psql.Preload[*User, UserSlice](psql.PreloadRel{
|
|
|
|
|
Name: "CreatorUser",
|
|
|
|
|
Sides: []psql.PreloadSide{
|
|
|
|
|
{
|
|
|
|
|
From: FileuploadPools,
|
|
|
|
|
To: Users,
|
|
|
|
|
FromColumns: []string{"creator_id"},
|
|
|
|
|
ToColumns: []string{"id"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}, Users.Columns.Names(), opts...)
|
|
|
|
|
},
|
|
|
|
|
CSVFileCSV: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
|
|
|
return psql.Preload[*FileuploadCSV, FileuploadCSVSlice](psql.PreloadRel{
|
|
|
|
|
Name: "CSVFileCSV",
|
|
|
|
|
Sides: []psql.PreloadSide{
|
|
|
|
|
{
|
|
|
|
|
From: FileuploadPools,
|
|
|
|
|
To: FileuploadCSVS,
|
|
|
|
|
FromColumns: []string{"csv_file"},
|
|
|
|
|
ToColumns: []string{"file_id"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}, FileuploadCSVS.Columns.Names(), opts...)
|
|
|
|
|
},
|
2026-02-14 05:40:27 +00:00
|
|
|
PropertyOwnerPhoneE164Phone: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
|
|
|
return psql.Preload[*CommsPhone, CommsPhoneSlice](psql.PreloadRel{
|
|
|
|
|
Name: "PropertyOwnerPhoneE164Phone",
|
|
|
|
|
Sides: []psql.PreloadSide{
|
|
|
|
|
{
|
|
|
|
|
From: FileuploadPools,
|
|
|
|
|
To: CommsPhones,
|
|
|
|
|
FromColumns: []string{"property_owner_phone_e164"},
|
|
|
|
|
ToColumns: []string{"e164"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}, CommsPhones.Columns.Names(), opts...)
|
|
|
|
|
},
|
|
|
|
|
ResidentPhoneE164Phone: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
|
|
|
return psql.Preload[*CommsPhone, CommsPhoneSlice](psql.PreloadRel{
|
|
|
|
|
Name: "ResidentPhoneE164Phone",
|
|
|
|
|
Sides: []psql.PreloadSide{
|
|
|
|
|
{
|
|
|
|
|
From: FileuploadPools,
|
|
|
|
|
To: CommsPhones,
|
|
|
|
|
FromColumns: []string{"resident_phone_e164"},
|
|
|
|
|
ToColumns: []string{"e164"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}, CommsPhones.Columns.Names(), opts...)
|
|
|
|
|
},
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type fileuploadPoolThenLoader[Q orm.Loadable] struct {
|
2026-02-14 05:40:27 +00:00
|
|
|
CreatorUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
|
|
|
CSVFileCSV func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
|
|
|
PropertyOwnerPhoneE164Phone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
|
|
|
ResidentPhoneE164Phone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildFileuploadPoolThenLoader[Q orm.Loadable]() fileuploadPoolThenLoader[Q] {
|
|
|
|
|
type CreatorUserLoadInterface interface {
|
|
|
|
|
LoadCreatorUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
|
|
|
}
|
|
|
|
|
type CSVFileCSVLoadInterface interface {
|
|
|
|
|
LoadCSVFileCSV(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
|
|
|
}
|
2026-02-14 05:40:27 +00:00
|
|
|
type PropertyOwnerPhoneE164PhoneLoadInterface interface {
|
|
|
|
|
LoadPropertyOwnerPhoneE164Phone(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
|
|
|
}
|
|
|
|
|
type ResidentPhoneE164PhoneLoadInterface interface {
|
|
|
|
|
LoadResidentPhoneE164Phone(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
|
|
|
}
|
2026-02-09 19:03:27 +00:00
|
|
|
|
|
|
|
|
return fileuploadPoolThenLoader[Q]{
|
|
|
|
|
CreatorUser: thenLoadBuilder[Q](
|
|
|
|
|
"CreatorUser",
|
|
|
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
return retrieved.LoadCreatorUser(ctx, exec, mods...)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
CSVFileCSV: thenLoadBuilder[Q](
|
|
|
|
|
"CSVFileCSV",
|
|
|
|
|
func(ctx context.Context, exec bob.Executor, retrieved CSVFileCSVLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
return retrieved.LoadCSVFileCSV(ctx, exec, mods...)
|
|
|
|
|
},
|
|
|
|
|
),
|
2026-02-14 05:40:27 +00:00
|
|
|
PropertyOwnerPhoneE164Phone: thenLoadBuilder[Q](
|
|
|
|
|
"PropertyOwnerPhoneE164Phone",
|
|
|
|
|
func(ctx context.Context, exec bob.Executor, retrieved PropertyOwnerPhoneE164PhoneLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
return retrieved.LoadPropertyOwnerPhoneE164Phone(ctx, exec, mods...)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ResidentPhoneE164Phone: thenLoadBuilder[Q](
|
|
|
|
|
"ResidentPhoneE164Phone",
|
|
|
|
|
func(ctx context.Context, exec bob.Executor, retrieved ResidentPhoneE164PhoneLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
return retrieved.LoadResidentPhoneE164Phone(ctx, exec, mods...)
|
|
|
|
|
},
|
|
|
|
|
),
|
2026-02-09 19:03:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadCreatorUser loads the fileuploadPool's CreatorUser into the .R struct
|
|
|
|
|
func (o *FileuploadPool) LoadCreatorUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the relationship
|
|
|
|
|
o.R.CreatorUser = nil
|
|
|
|
|
|
|
|
|
|
related, err := o.CreatorUser(mods...).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-26 18:18:33 +00:00
|
|
|
related.R.FileuploadPool = FileuploadPoolSlice{o}
|
2026-02-09 19:03:27 +00:00
|
|
|
|
|
|
|
|
o.R.CreatorUser = related
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadCreatorUser loads the fileuploadPool's CreatorUser into the .R struct
|
|
|
|
|
func (os FileuploadPoolSlice) LoadCreatorUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if len(os) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
users, err := os.CreatorUser(mods...).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, rel := range users {
|
|
|
|
|
|
|
|
|
|
if !(o.CreatorID == rel.ID) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-26 18:18:33 +00:00
|
|
|
rel.R.FileuploadPool = append(rel.R.FileuploadPool, o)
|
2026-02-09 19:03:27 +00:00
|
|
|
|
|
|
|
|
o.R.CreatorUser = rel
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadCSVFileCSV loads the fileuploadPool's CSVFileCSV into the .R struct
|
|
|
|
|
func (o *FileuploadPool) LoadCSVFileCSV(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the relationship
|
|
|
|
|
o.R.CSVFileCSV = nil
|
|
|
|
|
|
|
|
|
|
related, err := o.CSVFileCSV(mods...).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
related.R.CSVFilePools = FileuploadPoolSlice{o}
|
|
|
|
|
|
|
|
|
|
o.R.CSVFileCSV = related
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadCSVFileCSV loads the fileuploadPool's CSVFileCSV into the .R struct
|
|
|
|
|
func (os FileuploadPoolSlice) LoadCSVFileCSV(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if len(os) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileuploadCSVS, err := os.CSVFileCSV(mods...).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, rel := range fileuploadCSVS {
|
|
|
|
|
|
|
|
|
|
if !(o.CSVFile == rel.FileID) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rel.R.CSVFilePools = append(rel.R.CSVFilePools, o)
|
|
|
|
|
|
|
|
|
|
o.R.CSVFileCSV = rel
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-14 05:40:27 +00:00
|
|
|
// LoadPropertyOwnerPhoneE164Phone loads the fileuploadPool's PropertyOwnerPhoneE164Phone into the .R struct
|
|
|
|
|
func (o *FileuploadPool) LoadPropertyOwnerPhoneE164Phone(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the relationship
|
|
|
|
|
o.R.PropertyOwnerPhoneE164Phone = nil
|
|
|
|
|
|
|
|
|
|
related, err := o.PropertyOwnerPhoneE164Phone(mods...).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
related.R.PropertyOwnerPhoneE164Pools = FileuploadPoolSlice{o}
|
|
|
|
|
|
|
|
|
|
o.R.PropertyOwnerPhoneE164Phone = related
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadPropertyOwnerPhoneE164Phone loads the fileuploadPool's PropertyOwnerPhoneE164Phone into the .R struct
|
|
|
|
|
func (os FileuploadPoolSlice) LoadPropertyOwnerPhoneE164Phone(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if len(os) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commsPhones, err := os.PropertyOwnerPhoneE164Phone(mods...).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, rel := range commsPhones {
|
|
|
|
|
if !o.PropertyOwnerPhoneE164.IsValue() {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !(o.PropertyOwnerPhoneE164.IsValue() && o.PropertyOwnerPhoneE164.MustGet() == rel.E164) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rel.R.PropertyOwnerPhoneE164Pools = append(rel.R.PropertyOwnerPhoneE164Pools, o)
|
|
|
|
|
|
|
|
|
|
o.R.PropertyOwnerPhoneE164Phone = rel
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadResidentPhoneE164Phone loads the fileuploadPool's ResidentPhoneE164Phone into the .R struct
|
|
|
|
|
func (o *FileuploadPool) LoadResidentPhoneE164Phone(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the relationship
|
|
|
|
|
o.R.ResidentPhoneE164Phone = nil
|
|
|
|
|
|
|
|
|
|
related, err := o.ResidentPhoneE164Phone(mods...).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
related.R.ResidentPhoneE164Pools = FileuploadPoolSlice{o}
|
|
|
|
|
|
|
|
|
|
o.R.ResidentPhoneE164Phone = related
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadResidentPhoneE164Phone loads the fileuploadPool's ResidentPhoneE164Phone into the .R struct
|
|
|
|
|
func (os FileuploadPoolSlice) LoadResidentPhoneE164Phone(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if len(os) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commsPhones, err := os.ResidentPhoneE164Phone(mods...).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, rel := range commsPhones {
|
|
|
|
|
if !o.ResidentPhoneE164.IsValue() {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !(o.ResidentPhoneE164.IsValue() && o.ResidentPhoneE164.MustGet() == rel.E164) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rel.R.ResidentPhoneE164Pools = append(rel.R.ResidentPhoneE164Pools, o)
|
|
|
|
|
|
|
|
|
|
o.R.ResidentPhoneE164Phone = rel
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|