2026-01-27 18:44:02 +00:00
|
|
|
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
2026-01-09 19:43:19 +00:00
|
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
|
|
|
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
2026-01-16 14:52:11 +00:00
|
|
|
"strconv"
|
2026-01-09 19:43:19 +00:00
|
|
|
"time"
|
|
|
|
|
|
2026-01-27 18:44:02 +00:00
|
|
|
"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/mods"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/orm"
|
|
|
|
|
"github.com/Gleipnir-Technology/bob/types/pgtypes"
|
2026-01-13 19:47:19 +00:00
|
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
2026-01-09 19:43:19 +00:00
|
|
|
"github.com/aarondl/opt/null"
|
|
|
|
|
"github.com/aarondl/opt/omit"
|
|
|
|
|
"github.com/aarondl/opt/omitnull"
|
2026-01-16 14:52:11 +00:00
|
|
|
"github.com/stephenafamo/scan"
|
2026-01-09 19:43:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// PublicreportPool is an object representing the database table.
|
|
|
|
|
type PublicreportPool struct {
|
2026-02-05 21:43:29 +00:00
|
|
|
ID int32 `db:"id,pk" `
|
|
|
|
|
AccessComments string `db:"access_comments" `
|
|
|
|
|
AccessGate bool `db:"access_gate" `
|
|
|
|
|
AccessFence bool `db:"access_fence" `
|
|
|
|
|
AccessLocked bool `db:"access_locked" `
|
|
|
|
|
AccessDog bool `db:"access_dog" `
|
|
|
|
|
AccessOther bool `db:"access_other" `
|
|
|
|
|
Address string `db:"address" `
|
|
|
|
|
AddressCountry string `db:"address_country" `
|
|
|
|
|
AddressPostCode string `db:"address_post_code" `
|
|
|
|
|
AddressPlace string `db:"address_place" `
|
|
|
|
|
AddressStreet string `db:"address_street" `
|
|
|
|
|
AddressRegion string `db:"address_region" `
|
|
|
|
|
Comments string `db:"comments" `
|
|
|
|
|
Created time.Time `db:"created" `
|
|
|
|
|
H3cell null.Val[string] `db:"h3cell" `
|
|
|
|
|
HasAdult bool `db:"has_adult" `
|
|
|
|
|
HasLarvae bool `db:"has_larvae" `
|
|
|
|
|
HasPupae bool `db:"has_pupae" `
|
|
|
|
|
Location null.Val[string] `db:"location" `
|
|
|
|
|
MapZoom float32 `db:"map_zoom" `
|
|
|
|
|
OwnerEmail string `db:"owner_email" `
|
|
|
|
|
OwnerName string `db:"owner_name" `
|
|
|
|
|
OwnerPhone string `db:"owner_phone" `
|
|
|
|
|
PublicID string `db:"public_id" `
|
|
|
|
|
ReporterEmail string `db:"reporter_email" `
|
|
|
|
|
ReporterName string `db:"reporter_name" `
|
|
|
|
|
ReporterPhone string `db:"reporter_phone" `
|
|
|
|
|
Status enums.PublicreportReportstatustype `db:"status" `
|
|
|
|
|
OrganizationID null.Val[int32] `db:"organization_id" `
|
|
|
|
|
HasBackyardPermission bool `db:"has_backyard_permission" `
|
|
|
|
|
IsReporterConfidential bool `db:"is_reporter_confidential" `
|
|
|
|
|
IsReporterOwner bool `db:"is_reporter_owner" `
|
2026-01-09 19:43:19 +00:00
|
|
|
|
|
|
|
|
R publicreportPoolR `db:"-" `
|
2026-01-15 19:18:34 +00:00
|
|
|
|
|
|
|
|
C publicreportPoolC `db:"-" `
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PublicreportPoolSlice is an alias for a slice of pointers to PublicreportPool.
|
|
|
|
|
// This should almost always be used instead of []*PublicreportPool.
|
|
|
|
|
type PublicreportPoolSlice []*PublicreportPool
|
|
|
|
|
|
|
|
|
|
// PublicreportPools contains methods to work with the pool table
|
|
|
|
|
var PublicreportPools = psql.NewTablex[*PublicreportPool, PublicreportPoolSlice, *PublicreportPoolSetter]("publicreport", "pool", buildPublicreportPoolColumns("publicreport.pool"))
|
|
|
|
|
|
|
|
|
|
// PublicreportPoolsQuery is a query on the pool table
|
|
|
|
|
type PublicreportPoolsQuery = *psql.ViewQuery[*PublicreportPool, PublicreportPoolSlice]
|
|
|
|
|
|
|
|
|
|
// publicreportPoolR is where relationships are stored.
|
|
|
|
|
type publicreportPoolR struct {
|
2026-01-22 03:27:32 +00:00
|
|
|
Organization *Organization // publicreport.pool.pool_organization_id_fkey
|
|
|
|
|
Images PublicreportImageSlice // publicreport.pool_image.pool_image_image_id_fkeypublicreport.pool_image.pool_image_pool_id_fkey
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
|
|
|
|
|
return publicreportPoolColumns{
|
|
|
|
|
ColumnsExpr: expr.NewColumnsExpr(
|
2026-02-05 21:43:29 +00:00
|
|
|
"id", "access_comments", "access_gate", "access_fence", "access_locked", "access_dog", "access_other", "address", "address_country", "address_post_code", "address_place", "address_street", "address_region", "comments", "created", "h3cell", "has_adult", "has_larvae", "has_pupae", "location", "map_zoom", "owner_email", "owner_name", "owner_phone", "public_id", "reporter_email", "reporter_name", "reporter_phone", "status", "organization_id", "has_backyard_permission", "is_reporter_confidential", "is_reporter_owner",
|
2026-01-09 19:43:19 +00:00
|
|
|
).WithParent("publicreport.pool"),
|
2026-02-05 21:43:29 +00:00
|
|
|
tableAlias: alias,
|
|
|
|
|
ID: psql.Quote(alias, "id"),
|
|
|
|
|
AccessComments: psql.Quote(alias, "access_comments"),
|
|
|
|
|
AccessGate: psql.Quote(alias, "access_gate"),
|
|
|
|
|
AccessFence: psql.Quote(alias, "access_fence"),
|
|
|
|
|
AccessLocked: psql.Quote(alias, "access_locked"),
|
|
|
|
|
AccessDog: psql.Quote(alias, "access_dog"),
|
|
|
|
|
AccessOther: psql.Quote(alias, "access_other"),
|
|
|
|
|
Address: psql.Quote(alias, "address"),
|
|
|
|
|
AddressCountry: psql.Quote(alias, "address_country"),
|
|
|
|
|
AddressPostCode: psql.Quote(alias, "address_post_code"),
|
|
|
|
|
AddressPlace: psql.Quote(alias, "address_place"),
|
|
|
|
|
AddressStreet: psql.Quote(alias, "address_street"),
|
|
|
|
|
AddressRegion: psql.Quote(alias, "address_region"),
|
|
|
|
|
Comments: psql.Quote(alias, "comments"),
|
|
|
|
|
Created: psql.Quote(alias, "created"),
|
|
|
|
|
H3cell: psql.Quote(alias, "h3cell"),
|
|
|
|
|
HasAdult: psql.Quote(alias, "has_adult"),
|
|
|
|
|
HasLarvae: psql.Quote(alias, "has_larvae"),
|
|
|
|
|
HasPupae: psql.Quote(alias, "has_pupae"),
|
|
|
|
|
Location: psql.Quote(alias, "location"),
|
|
|
|
|
MapZoom: psql.Quote(alias, "map_zoom"),
|
|
|
|
|
OwnerEmail: psql.Quote(alias, "owner_email"),
|
|
|
|
|
OwnerName: psql.Quote(alias, "owner_name"),
|
|
|
|
|
OwnerPhone: psql.Quote(alias, "owner_phone"),
|
|
|
|
|
PublicID: psql.Quote(alias, "public_id"),
|
|
|
|
|
ReporterEmail: psql.Quote(alias, "reporter_email"),
|
|
|
|
|
ReporterName: psql.Quote(alias, "reporter_name"),
|
|
|
|
|
ReporterPhone: psql.Quote(alias, "reporter_phone"),
|
|
|
|
|
Status: psql.Quote(alias, "status"),
|
|
|
|
|
OrganizationID: psql.Quote(alias, "organization_id"),
|
|
|
|
|
HasBackyardPermission: psql.Quote(alias, "has_backyard_permission"),
|
|
|
|
|
IsReporterConfidential: psql.Quote(alias, "is_reporter_confidential"),
|
|
|
|
|
IsReporterOwner: psql.Quote(alias, "is_reporter_owner"),
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type publicreportPoolColumns struct {
|
|
|
|
|
expr.ColumnsExpr
|
2026-02-05 21:43:29 +00:00
|
|
|
tableAlias string
|
|
|
|
|
ID psql.Expression
|
|
|
|
|
AccessComments psql.Expression
|
|
|
|
|
AccessGate psql.Expression
|
|
|
|
|
AccessFence psql.Expression
|
|
|
|
|
AccessLocked psql.Expression
|
|
|
|
|
AccessDog psql.Expression
|
|
|
|
|
AccessOther psql.Expression
|
|
|
|
|
Address psql.Expression
|
|
|
|
|
AddressCountry psql.Expression
|
|
|
|
|
AddressPostCode psql.Expression
|
|
|
|
|
AddressPlace psql.Expression
|
|
|
|
|
AddressStreet psql.Expression
|
|
|
|
|
AddressRegion psql.Expression
|
|
|
|
|
Comments psql.Expression
|
|
|
|
|
Created psql.Expression
|
|
|
|
|
H3cell psql.Expression
|
|
|
|
|
HasAdult psql.Expression
|
|
|
|
|
HasLarvae psql.Expression
|
|
|
|
|
HasPupae psql.Expression
|
|
|
|
|
Location psql.Expression
|
|
|
|
|
MapZoom psql.Expression
|
|
|
|
|
OwnerEmail psql.Expression
|
|
|
|
|
OwnerName psql.Expression
|
|
|
|
|
OwnerPhone psql.Expression
|
|
|
|
|
PublicID psql.Expression
|
|
|
|
|
ReporterEmail psql.Expression
|
|
|
|
|
ReporterName psql.Expression
|
|
|
|
|
ReporterPhone psql.Expression
|
|
|
|
|
Status psql.Expression
|
|
|
|
|
OrganizationID psql.Expression
|
|
|
|
|
HasBackyardPermission psql.Expression
|
|
|
|
|
IsReporterConfidential psql.Expression
|
|
|
|
|
IsReporterOwner psql.Expression
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c publicreportPoolColumns) Alias() string {
|
|
|
|
|
return c.tableAlias
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (publicreportPoolColumns) AliasedAs(alias string) publicreportPoolColumns {
|
|
|
|
|
return buildPublicreportPoolColumns(alias)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PublicreportPoolSetter is used for insert/upsert/update operations
|
|
|
|
|
// All values are optional, and do not have to be set
|
|
|
|
|
// Generated columns are not included
|
|
|
|
|
type PublicreportPoolSetter struct {
|
2026-02-05 21:43:29 +00:00
|
|
|
ID omit.Val[int32] `db:"id,pk" `
|
|
|
|
|
AccessComments omit.Val[string] `db:"access_comments" `
|
|
|
|
|
AccessGate omit.Val[bool] `db:"access_gate" `
|
|
|
|
|
AccessFence omit.Val[bool] `db:"access_fence" `
|
|
|
|
|
AccessLocked omit.Val[bool] `db:"access_locked" `
|
|
|
|
|
AccessDog omit.Val[bool] `db:"access_dog" `
|
|
|
|
|
AccessOther omit.Val[bool] `db:"access_other" `
|
|
|
|
|
Address omit.Val[string] `db:"address" `
|
|
|
|
|
AddressCountry omit.Val[string] `db:"address_country" `
|
|
|
|
|
AddressPostCode omit.Val[string] `db:"address_post_code" `
|
|
|
|
|
AddressPlace omit.Val[string] `db:"address_place" `
|
|
|
|
|
AddressStreet omit.Val[string] `db:"address_street" `
|
|
|
|
|
AddressRegion omit.Val[string] `db:"address_region" `
|
|
|
|
|
Comments omit.Val[string] `db:"comments" `
|
|
|
|
|
Created omit.Val[time.Time] `db:"created" `
|
|
|
|
|
H3cell omitnull.Val[string] `db:"h3cell" `
|
|
|
|
|
HasAdult omit.Val[bool] `db:"has_adult" `
|
|
|
|
|
HasLarvae omit.Val[bool] `db:"has_larvae" `
|
|
|
|
|
HasPupae omit.Val[bool] `db:"has_pupae" `
|
|
|
|
|
Location omitnull.Val[string] `db:"location" `
|
|
|
|
|
MapZoom omit.Val[float32] `db:"map_zoom" `
|
|
|
|
|
OwnerEmail omit.Val[string] `db:"owner_email" `
|
|
|
|
|
OwnerName omit.Val[string] `db:"owner_name" `
|
|
|
|
|
OwnerPhone omit.Val[string] `db:"owner_phone" `
|
|
|
|
|
PublicID omit.Val[string] `db:"public_id" `
|
|
|
|
|
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
|
|
|
|
ReporterName omit.Val[string] `db:"reporter_name" `
|
|
|
|
|
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
|
|
|
|
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
|
|
|
|
OrganizationID omitnull.Val[int32] `db:"organization_id" `
|
|
|
|
|
HasBackyardPermission omit.Val[bool] `db:"has_backyard_permission" `
|
|
|
|
|
IsReporterConfidential omit.Val[bool] `db:"is_reporter_confidential" `
|
|
|
|
|
IsReporterOwner omit.Val[bool] `db:"is_reporter_owner" `
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s PublicreportPoolSetter) SetColumns() []string {
|
2026-02-05 21:43:29 +00:00
|
|
|
vals := make([]string, 0, 33)
|
2026-01-09 19:43:19 +00:00
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
vals = append(vals, "id")
|
|
|
|
|
}
|
|
|
|
|
if s.AccessComments.IsValue() {
|
|
|
|
|
vals = append(vals, "access_comments")
|
|
|
|
|
}
|
|
|
|
|
if s.AccessGate.IsValue() {
|
|
|
|
|
vals = append(vals, "access_gate")
|
|
|
|
|
}
|
|
|
|
|
if s.AccessFence.IsValue() {
|
|
|
|
|
vals = append(vals, "access_fence")
|
|
|
|
|
}
|
|
|
|
|
if s.AccessLocked.IsValue() {
|
|
|
|
|
vals = append(vals, "access_locked")
|
|
|
|
|
}
|
|
|
|
|
if s.AccessDog.IsValue() {
|
|
|
|
|
vals = append(vals, "access_dog")
|
|
|
|
|
}
|
|
|
|
|
if s.AccessOther.IsValue() {
|
|
|
|
|
vals = append(vals, "access_other")
|
|
|
|
|
}
|
|
|
|
|
if s.Address.IsValue() {
|
|
|
|
|
vals = append(vals, "address")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressCountry.IsValue() {
|
|
|
|
|
vals = append(vals, "address_country")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressPostCode.IsValue() {
|
|
|
|
|
vals = append(vals, "address_post_code")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressPlace.IsValue() {
|
|
|
|
|
vals = append(vals, "address_place")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
|
|
|
vals = append(vals, "address_street")
|
|
|
|
|
}
|
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
|
|
|
vals = append(vals, "address_region")
|
|
|
|
|
}
|
|
|
|
|
if s.Comments.IsValue() {
|
|
|
|
|
vals = append(vals, "comments")
|
|
|
|
|
}
|
|
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
vals = append(vals, "created")
|
|
|
|
|
}
|
|
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
vals = append(vals, "h3cell")
|
|
|
|
|
}
|
|
|
|
|
if s.HasAdult.IsValue() {
|
|
|
|
|
vals = append(vals, "has_adult")
|
|
|
|
|
}
|
|
|
|
|
if s.HasLarvae.IsValue() {
|
|
|
|
|
vals = append(vals, "has_larvae")
|
|
|
|
|
}
|
|
|
|
|
if s.HasPupae.IsValue() {
|
|
|
|
|
vals = append(vals, "has_pupae")
|
|
|
|
|
}
|
|
|
|
|
if !s.Location.IsUnset() {
|
|
|
|
|
vals = append(vals, "location")
|
|
|
|
|
}
|
|
|
|
|
if s.MapZoom.IsValue() {
|
|
|
|
|
vals = append(vals, "map_zoom")
|
|
|
|
|
}
|
|
|
|
|
if s.OwnerEmail.IsValue() {
|
|
|
|
|
vals = append(vals, "owner_email")
|
|
|
|
|
}
|
|
|
|
|
if s.OwnerName.IsValue() {
|
|
|
|
|
vals = append(vals, "owner_name")
|
|
|
|
|
}
|
|
|
|
|
if s.OwnerPhone.IsValue() {
|
|
|
|
|
vals = append(vals, "owner_phone")
|
|
|
|
|
}
|
|
|
|
|
if s.PublicID.IsValue() {
|
|
|
|
|
vals = append(vals, "public_id")
|
|
|
|
|
}
|
|
|
|
|
if s.ReporterEmail.IsValue() {
|
|
|
|
|
vals = append(vals, "reporter_email")
|
|
|
|
|
}
|
|
|
|
|
if s.ReporterName.IsValue() {
|
|
|
|
|
vals = append(vals, "reporter_name")
|
|
|
|
|
}
|
|
|
|
|
if s.ReporterPhone.IsValue() {
|
|
|
|
|
vals = append(vals, "reporter_phone")
|
|
|
|
|
}
|
2026-01-13 19:47:19 +00:00
|
|
|
if s.Status.IsValue() {
|
|
|
|
|
vals = append(vals, "status")
|
|
|
|
|
}
|
2026-01-22 03:27:32 +00:00
|
|
|
if !s.OrganizationID.IsUnset() {
|
|
|
|
|
vals = append(vals, "organization_id")
|
|
|
|
|
}
|
2026-02-05 21:43:29 +00:00
|
|
|
if s.HasBackyardPermission.IsValue() {
|
|
|
|
|
vals = append(vals, "has_backyard_permission")
|
|
|
|
|
}
|
|
|
|
|
if s.IsReporterConfidential.IsValue() {
|
|
|
|
|
vals = append(vals, "is_reporter_confidential")
|
|
|
|
|
}
|
|
|
|
|
if s.IsReporterOwner.IsValue() {
|
|
|
|
|
vals = append(vals, "is_reporter_owner")
|
|
|
|
|
}
|
2026-01-09 19:43:19 +00:00
|
|
|
return vals
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s PublicreportPoolSetter) Overwrite(t *PublicreportPool) {
|
|
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
t.ID = s.ID.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AccessComments.IsValue() {
|
|
|
|
|
t.AccessComments = s.AccessComments.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AccessGate.IsValue() {
|
|
|
|
|
t.AccessGate = s.AccessGate.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AccessFence.IsValue() {
|
|
|
|
|
t.AccessFence = s.AccessFence.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AccessLocked.IsValue() {
|
|
|
|
|
t.AccessLocked = s.AccessLocked.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AccessDog.IsValue() {
|
|
|
|
|
t.AccessDog = s.AccessDog.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AccessOther.IsValue() {
|
|
|
|
|
t.AccessOther = s.AccessOther.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.Address.IsValue() {
|
|
|
|
|
t.Address = s.Address.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressCountry.IsValue() {
|
|
|
|
|
t.AddressCountry = s.AddressCountry.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressPostCode.IsValue() {
|
|
|
|
|
t.AddressPostCode = s.AddressPostCode.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressPlace.IsValue() {
|
|
|
|
|
t.AddressPlace = s.AddressPlace.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
|
|
|
t.AddressStreet = s.AddressStreet.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
|
|
|
t.AddressRegion = s.AddressRegion.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.Comments.IsValue() {
|
|
|
|
|
t.Comments = s.Comments.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
t.Created = s.Created.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
t.H3cell = s.H3cell.MustGetNull()
|
|
|
|
|
}
|
|
|
|
|
if s.HasAdult.IsValue() {
|
|
|
|
|
t.HasAdult = s.HasAdult.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.HasLarvae.IsValue() {
|
|
|
|
|
t.HasLarvae = s.HasLarvae.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.HasPupae.IsValue() {
|
|
|
|
|
t.HasPupae = s.HasPupae.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if !s.Location.IsUnset() {
|
|
|
|
|
t.Location = s.Location.MustGetNull()
|
|
|
|
|
}
|
|
|
|
|
if s.MapZoom.IsValue() {
|
|
|
|
|
t.MapZoom = s.MapZoom.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.OwnerEmail.IsValue() {
|
|
|
|
|
t.OwnerEmail = s.OwnerEmail.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.OwnerName.IsValue() {
|
|
|
|
|
t.OwnerName = s.OwnerName.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.OwnerPhone.IsValue() {
|
|
|
|
|
t.OwnerPhone = s.OwnerPhone.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.PublicID.IsValue() {
|
|
|
|
|
t.PublicID = s.PublicID.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.ReporterEmail.IsValue() {
|
|
|
|
|
t.ReporterEmail = s.ReporterEmail.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.ReporterName.IsValue() {
|
|
|
|
|
t.ReporterName = s.ReporterName.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.ReporterPhone.IsValue() {
|
|
|
|
|
t.ReporterPhone = s.ReporterPhone.MustGet()
|
|
|
|
|
}
|
2026-01-13 19:47:19 +00:00
|
|
|
if s.Status.IsValue() {
|
|
|
|
|
t.Status = s.Status.MustGet()
|
|
|
|
|
}
|
2026-01-22 03:27:32 +00:00
|
|
|
if !s.OrganizationID.IsUnset() {
|
|
|
|
|
t.OrganizationID = s.OrganizationID.MustGetNull()
|
|
|
|
|
}
|
2026-02-05 21:43:29 +00:00
|
|
|
if s.HasBackyardPermission.IsValue() {
|
|
|
|
|
t.HasBackyardPermission = s.HasBackyardPermission.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.IsReporterConfidential.IsValue() {
|
|
|
|
|
t.IsReporterConfidential = s.IsReporterConfidential.MustGet()
|
|
|
|
|
}
|
|
|
|
|
if s.IsReporterOwner.IsValue() {
|
|
|
|
|
t.IsReporterOwner = s.IsReporterOwner.MustGet()
|
|
|
|
|
}
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
|
|
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
|
|
|
return PublicreportPools.BeforeInsertHooks.RunHooks(ctx, exec, s)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
2026-02-05 21:43:29 +00:00
|
|
|
vals := make([]bob.Expression, 33)
|
2026-01-09 19:43:19 +00:00
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
vals[0] = psql.Arg(s.ID.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[0] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessComments.IsValue() {
|
|
|
|
|
vals[1] = psql.Arg(s.AccessComments.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[1] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessGate.IsValue() {
|
|
|
|
|
vals[2] = psql.Arg(s.AccessGate.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[2] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessFence.IsValue() {
|
|
|
|
|
vals[3] = psql.Arg(s.AccessFence.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[3] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessLocked.IsValue() {
|
|
|
|
|
vals[4] = psql.Arg(s.AccessLocked.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[4] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessDog.IsValue() {
|
|
|
|
|
vals[5] = psql.Arg(s.AccessDog.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[5] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessOther.IsValue() {
|
|
|
|
|
vals[6] = psql.Arg(s.AccessOther.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[6] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Address.IsValue() {
|
|
|
|
|
vals[7] = psql.Arg(s.Address.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[7] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressCountry.IsValue() {
|
|
|
|
|
vals[8] = psql.Arg(s.AddressCountry.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[8] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressPostCode.IsValue() {
|
|
|
|
|
vals[9] = psql.Arg(s.AddressPostCode.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[9] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressPlace.IsValue() {
|
|
|
|
|
vals[10] = psql.Arg(s.AddressPlace.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[10] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
|
|
|
vals[11] = psql.Arg(s.AddressStreet.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[11] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
|
|
|
vals[12] = psql.Arg(s.AddressRegion.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[12] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Comments.IsValue() {
|
|
|
|
|
vals[13] = psql.Arg(s.Comments.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[13] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
vals[14] = psql.Arg(s.Created.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[14] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
vals[15] = psql.Arg(s.H3cell.MustGetNull())
|
|
|
|
|
} else {
|
|
|
|
|
vals[15] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.HasAdult.IsValue() {
|
|
|
|
|
vals[16] = psql.Arg(s.HasAdult.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[16] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.HasLarvae.IsValue() {
|
|
|
|
|
vals[17] = psql.Arg(s.HasLarvae.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[17] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.HasPupae.IsValue() {
|
|
|
|
|
vals[18] = psql.Arg(s.HasPupae.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[18] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !s.Location.IsUnset() {
|
|
|
|
|
vals[19] = psql.Arg(s.Location.MustGetNull())
|
|
|
|
|
} else {
|
|
|
|
|
vals[19] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.MapZoom.IsValue() {
|
|
|
|
|
vals[20] = psql.Arg(s.MapZoom.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[20] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.OwnerEmail.IsValue() {
|
|
|
|
|
vals[21] = psql.Arg(s.OwnerEmail.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[21] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.OwnerName.IsValue() {
|
|
|
|
|
vals[22] = psql.Arg(s.OwnerName.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[22] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.OwnerPhone.IsValue() {
|
|
|
|
|
vals[23] = psql.Arg(s.OwnerPhone.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[23] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.PublicID.IsValue() {
|
|
|
|
|
vals[24] = psql.Arg(s.PublicID.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[24] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ReporterEmail.IsValue() {
|
|
|
|
|
vals[25] = psql.Arg(s.ReporterEmail.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[25] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ReporterName.IsValue() {
|
|
|
|
|
vals[26] = psql.Arg(s.ReporterName.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[26] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ReporterPhone.IsValue() {
|
|
|
|
|
vals[27] = psql.Arg(s.ReporterPhone.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[27] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 21:43:29 +00:00
|
|
|
if s.Status.IsValue() {
|
|
|
|
|
vals[28] = psql.Arg(s.Status.MustGet())
|
2026-01-09 19:43:19 +00:00
|
|
|
} else {
|
|
|
|
|
vals[28] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 21:43:29 +00:00
|
|
|
if !s.OrganizationID.IsUnset() {
|
|
|
|
|
vals[29] = psql.Arg(s.OrganizationID.MustGetNull())
|
2026-01-13 19:47:19 +00:00
|
|
|
} else {
|
|
|
|
|
vals[29] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 21:43:29 +00:00
|
|
|
if s.HasBackyardPermission.IsValue() {
|
|
|
|
|
vals[30] = psql.Arg(s.HasBackyardPermission.MustGet())
|
2026-01-22 03:27:32 +00:00
|
|
|
} else {
|
|
|
|
|
vals[30] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 21:43:29 +00:00
|
|
|
if s.IsReporterConfidential.IsValue() {
|
|
|
|
|
vals[31] = psql.Arg(s.IsReporterConfidential.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[31] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.IsReporterOwner.IsValue() {
|
|
|
|
|
vals[32] = psql.Arg(s.IsReporterOwner.MustGet())
|
|
|
|
|
} else {
|
|
|
|
|
vals[32] = psql.Raw("DEFAULT")
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-09 19:43:19 +00:00
|
|
|
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s PublicreportPoolSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
|
|
|
return um.Set(s.Expressions()...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s PublicreportPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
2026-02-05 21:43:29 +00:00
|
|
|
exprs := make([]bob.Expression, 0, 33)
|
2026-01-09 19:43:19 +00:00
|
|
|
|
|
|
|
|
if s.ID.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "id")...),
|
|
|
|
|
psql.Arg(s.ID),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessComments.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "access_comments")...),
|
|
|
|
|
psql.Arg(s.AccessComments),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessGate.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "access_gate")...),
|
|
|
|
|
psql.Arg(s.AccessGate),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessFence.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "access_fence")...),
|
|
|
|
|
psql.Arg(s.AccessFence),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessLocked.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "access_locked")...),
|
|
|
|
|
psql.Arg(s.AccessLocked),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessDog.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "access_dog")...),
|
|
|
|
|
psql.Arg(s.AccessDog),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AccessOther.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "access_other")...),
|
|
|
|
|
psql.Arg(s.AccessOther),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Address.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address")...),
|
|
|
|
|
psql.Arg(s.Address),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressCountry.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_country")...),
|
|
|
|
|
psql.Arg(s.AddressCountry),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressPostCode.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_post_code")...),
|
|
|
|
|
psql.Arg(s.AddressPostCode),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AddressPlace.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_place")...),
|
|
|
|
|
psql.Arg(s.AddressPlace),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.AddressRegion.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "address_region")...),
|
|
|
|
|
psql.Arg(s.AddressRegion),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Comments.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "comments")...),
|
|
|
|
|
psql.Arg(s.Comments),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Created.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "created")...),
|
|
|
|
|
psql.Arg(s.Created),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !s.H3cell.IsUnset() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "h3cell")...),
|
|
|
|
|
psql.Arg(s.H3cell),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.HasAdult.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "has_adult")...),
|
|
|
|
|
psql.Arg(s.HasAdult),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.HasLarvae.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "has_larvae")...),
|
|
|
|
|
psql.Arg(s.HasLarvae),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.HasPupae.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "has_pupae")...),
|
|
|
|
|
psql.Arg(s.HasPupae),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !s.Location.IsUnset() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "location")...),
|
|
|
|
|
psql.Arg(s.Location),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.MapZoom.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "map_zoom")...),
|
|
|
|
|
psql.Arg(s.MapZoom),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.OwnerEmail.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "owner_email")...),
|
|
|
|
|
psql.Arg(s.OwnerEmail),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.OwnerName.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "owner_name")...),
|
|
|
|
|
psql.Arg(s.OwnerName),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.OwnerPhone.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "owner_phone")...),
|
|
|
|
|
psql.Arg(s.OwnerPhone),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.PublicID.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "public_id")...),
|
|
|
|
|
psql.Arg(s.PublicID),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ReporterEmail.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "reporter_email")...),
|
|
|
|
|
psql.Arg(s.ReporterEmail),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ReporterName.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "reporter_name")...),
|
|
|
|
|
psql.Arg(s.ReporterName),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ReporterPhone.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "reporter_phone")...),
|
|
|
|
|
psql.Arg(s.ReporterPhone),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 19:47:19 +00:00
|
|
|
if s.Status.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "status")...),
|
|
|
|
|
psql.Arg(s.Status),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 03:27:32 +00:00
|
|
|
if !s.OrganizationID.IsUnset() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "organization_id")...),
|
|
|
|
|
psql.Arg(s.OrganizationID),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 21:43:29 +00:00
|
|
|
if s.HasBackyardPermission.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "has_backyard_permission")...),
|
|
|
|
|
psql.Arg(s.HasBackyardPermission),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.IsReporterConfidential.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "is_reporter_confidential")...),
|
|
|
|
|
psql.Arg(s.IsReporterConfidential),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.IsReporterOwner.IsValue() {
|
|
|
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
|
|
|
psql.Quote(append(prefix, "is_reporter_owner")...),
|
|
|
|
|
psql.Arg(s.IsReporterOwner),
|
|
|
|
|
}})
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-09 19:43:19 +00:00
|
|
|
return exprs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FindPublicreportPool retrieves a single record by primary key
|
|
|
|
|
// If cols is empty Find will return all columns.
|
|
|
|
|
func FindPublicreportPool(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*PublicreportPool, error) {
|
|
|
|
|
if len(cols) == 0 {
|
|
|
|
|
return PublicreportPools.Query(
|
|
|
|
|
sm.Where(PublicreportPools.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
|
|
|
).One(ctx, exec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PublicreportPools.Query(
|
|
|
|
|
sm.Where(PublicreportPools.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
|
|
|
sm.Columns(PublicreportPools.Columns.Only(cols...)),
|
|
|
|
|
).One(ctx, exec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PublicreportPoolExists checks the presence of a single record by primary key
|
|
|
|
|
func PublicreportPoolExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
|
|
|
|
|
return PublicreportPools.Query(
|
|
|
|
|
sm.Where(PublicreportPools.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
|
|
|
).Exists(ctx, exec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AfterQueryHook is called after PublicreportPool is retrieved from the database
|
|
|
|
|
func (o *PublicreportPool) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
switch queryType {
|
|
|
|
|
case bob.QueryTypeSelect:
|
|
|
|
|
ctx, err = PublicreportPools.AfterSelectHooks.RunHooks(ctx, exec, PublicreportPoolSlice{o})
|
|
|
|
|
case bob.QueryTypeInsert:
|
|
|
|
|
ctx, err = PublicreportPools.AfterInsertHooks.RunHooks(ctx, exec, PublicreportPoolSlice{o})
|
|
|
|
|
case bob.QueryTypeUpdate:
|
|
|
|
|
ctx, err = PublicreportPools.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportPoolSlice{o})
|
|
|
|
|
case bob.QueryTypeDelete:
|
|
|
|
|
ctx, err = PublicreportPools.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportPoolSlice{o})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// primaryKeyVals returns the primary key values of the PublicreportPool
|
|
|
|
|
func (o *PublicreportPool) primaryKeyVals() bob.Expression {
|
|
|
|
|
return psql.Arg(o.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o *PublicreportPool) pkEQ() dialect.Expression {
|
|
|
|
|
return psql.Quote("publicreport.pool", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
|
|
|
return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update uses an executor to update the PublicreportPool
|
|
|
|
|
func (o *PublicreportPool) Update(ctx context.Context, exec bob.Executor, s *PublicreportPoolSetter) error {
|
|
|
|
|
v, err := PublicreportPools.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 PublicreportPool record with an executor
|
|
|
|
|
func (o *PublicreportPool) Delete(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
_, err := PublicreportPools.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reload refreshes the PublicreportPool using the executor
|
|
|
|
|
func (o *PublicreportPool) Reload(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
o2, err := PublicreportPools.Query(
|
|
|
|
|
sm.Where(PublicreportPools.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 PublicreportPoolSlice is retrieved from the database
|
|
|
|
|
func (o PublicreportPoolSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
switch queryType {
|
|
|
|
|
case bob.QueryTypeSelect:
|
|
|
|
|
ctx, err = PublicreportPools.AfterSelectHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
case bob.QueryTypeInsert:
|
|
|
|
|
ctx, err = PublicreportPools.AfterInsertHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
case bob.QueryTypeUpdate:
|
|
|
|
|
ctx, err = PublicreportPools.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
case bob.QueryTypeDelete:
|
|
|
|
|
ctx, err = PublicreportPools.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o PublicreportPoolSlice) pkIN() dialect.Expression {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return psql.Raw("NULL")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return psql.Quote("publicreport.pool", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
|
|
|
pkPairs := make([]bob.Expression, len(o))
|
|
|
|
|
for i, row := range o {
|
|
|
|
|
pkPairs[i] = row.primaryKeyVals()
|
|
|
|
|
}
|
|
|
|
|
return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// copyMatchingRows finds models in the given slice that have the same primary key
|
|
|
|
|
// then it first copies the existing relationships from the old model to the new model
|
|
|
|
|
// and then replaces the old model in the slice with the new model
|
|
|
|
|
func (o PublicreportPoolSlice) copyMatchingRows(from ...*PublicreportPool) {
|
|
|
|
|
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 PublicreportPoolSlice) 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 PublicreportPools.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 *PublicreportPool:
|
|
|
|
|
o.copyMatchingRows(retrieved)
|
|
|
|
|
case []*PublicreportPool:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
case PublicreportPoolSlice:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
default:
|
|
|
|
|
// If the retrieved value is not a PublicreportPool or a slice of PublicreportPool
|
|
|
|
|
// then run the AfterUpdateHooks on the slice
|
|
|
|
|
_, err = PublicreportPools.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
|
|
|
|
func (o PublicreportPoolSlice) 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 PublicreportPools.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 *PublicreportPool:
|
|
|
|
|
o.copyMatchingRows(retrieved)
|
|
|
|
|
case []*PublicreportPool:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
case PublicreportPoolSlice:
|
|
|
|
|
o.copyMatchingRows(retrieved...)
|
|
|
|
|
default:
|
|
|
|
|
// If the retrieved value is not a PublicreportPool or a slice of PublicreportPool
|
|
|
|
|
// then run the AfterDeleteHooks on the slice
|
|
|
|
|
_, err = PublicreportPools.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o PublicreportPoolSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportPoolSetter) error {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := PublicreportPools.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o PublicreportPoolSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := PublicreportPools.Delete(o.DeleteMod()).Exec(ctx, exec)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o PublicreportPoolSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
|
|
|
|
if len(o) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o2, err := PublicreportPools.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o.copyMatchingRows(o2...)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 03:27:32 +00:00
|
|
|
// Organization starts a query for related objects on organization
|
|
|
|
|
func (o *PublicreportPool) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
|
|
|
return Organizations.Query(append(mods,
|
|
|
|
|
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (os PublicreportPoolSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
|
|
|
pkOrganizationID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
pkOrganizationID = append(pkOrganizationID, o.OrganizationID)
|
|
|
|
|
}
|
|
|
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
|
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkOrganizationID), "integer[]")),
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
return Organizations.Query(append(mods,
|
|
|
|
|
sm.Where(psql.Group(Organizations.Columns.ID).OP("IN", PKArgExpr)),
|
|
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
// Images starts a query for related objects on publicreport.image
|
|
|
|
|
func (o *PublicreportPool) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
|
|
|
|
return PublicreportImages.Query(append(mods,
|
|
|
|
|
sm.InnerJoin(PublicreportPoolImages.NameAs()).On(
|
|
|
|
|
PublicreportImages.Columns.ID.EQ(PublicreportPoolImages.Columns.ImageID)),
|
|
|
|
|
sm.Where(PublicreportPoolImages.Columns.PoolID.EQ(psql.Arg(o.ID))),
|
2026-01-09 19:43:19 +00:00
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
func (os PublicreportPoolSlice) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
2026-01-09 19:43:19 +00:00
|
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
pkID = append(pkID, o.ID)
|
|
|
|
|
}
|
|
|
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
|
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
|
|
|
))
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
return PublicreportImages.Query(append(mods,
|
|
|
|
|
sm.InnerJoin(PublicreportPoolImages.NameAs()).On(
|
|
|
|
|
PublicreportImages.Columns.ID.EQ(PublicreportPoolImages.Columns.ImageID),
|
|
|
|
|
),
|
|
|
|
|
sm.Where(psql.Group(PublicreportPoolImages.Columns.PoolID).OP("IN", PKArgExpr)),
|
2026-01-09 19:43:19 +00:00
|
|
|
)...)
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 03:27:32 +00:00
|
|
|
func attachPublicreportPoolOrganization0(ctx context.Context, exec bob.Executor, count int, publicreportPool0 *PublicreportPool, organization1 *Organization) (*PublicreportPool, error) {
|
|
|
|
|
setter := &PublicreportPoolSetter{
|
|
|
|
|
OrganizationID: omitnull.From(organization1.ID),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := publicreportPool0.Update(ctx, exec, setter)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("attachPublicreportPoolOrganization0: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return publicreportPool0, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (publicreportPool0 *PublicreportPool) InsertOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
organization1, err := Organizations.Insert(related).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = attachPublicreportPoolOrganization0(ctx, exec, 1, publicreportPool0, organization1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
publicreportPool0.R.Organization = organization1
|
|
|
|
|
|
|
|
|
|
organization1.R.PublicreportPool = append(organization1.R.PublicreportPool, publicreportPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (publicreportPool0 *PublicreportPool) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
_, err = attachPublicreportPoolOrganization0(ctx, exec, 1, publicreportPool0, organization1)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
publicreportPool0.R.Organization = organization1
|
|
|
|
|
|
|
|
|
|
organization1.R.PublicreportPool = append(organization1.R.PublicreportPool, publicreportPool0)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
func attachPublicreportPoolImages0(ctx context.Context, exec bob.Executor, count int, publicreportPool0 *PublicreportPool, publicreportImages2 PublicreportImageSlice) (PublicreportPoolImageSlice, error) {
|
|
|
|
|
setters := make([]*PublicreportPoolImageSetter, count)
|
|
|
|
|
for i := range count {
|
|
|
|
|
setters[i] = &PublicreportPoolImageSetter{
|
|
|
|
|
PoolID: omit.From(publicreportPool0.ID),
|
|
|
|
|
ImageID: omit.From(publicreportImages2[i].ID),
|
|
|
|
|
}
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
publicreportPoolImages1, err := PublicreportPoolImages.Insert(bob.ToMods(setters...)).All(ctx, exec)
|
2026-01-09 19:43:19 +00:00
|
|
|
if err != nil {
|
2026-01-16 14:52:11 +00:00
|
|
|
return nil, fmt.Errorf("attachPublicreportPoolImages0: %w", err)
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
return publicreportPoolImages1, nil
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
func (publicreportPool0 *PublicreportPool) InsertImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImageSetter) error {
|
2026-01-09 19:43:19 +00:00
|
|
|
if len(related) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
inserted, err := PublicreportImages.Insert(bob.ToMods(related...)).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
|
|
|
}
|
|
|
|
|
publicreportImages2 := PublicreportImageSlice(inserted)
|
|
|
|
|
|
|
|
|
|
_, err = attachPublicreportPoolImages0(ctx, exec, len(related), publicreportPool0, publicreportImages2)
|
2026-01-09 19:43:19 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
publicreportPool0.R.Images = append(publicreportPool0.R.Images, publicreportImages2...)
|
2026-01-09 19:43:19 +00:00
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
for _, rel := range publicreportImages2 {
|
|
|
|
|
rel.R.Pools = append(rel.R.Pools, publicreportPool0)
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
func (publicreportPool0 *PublicreportPool) AttachImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImage) error {
|
2026-01-09 19:43:19 +00:00
|
|
|
if len(related) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var err error
|
2026-01-16 14:52:11 +00:00
|
|
|
publicreportImages2 := PublicreportImageSlice(related)
|
2026-01-09 19:43:19 +00:00
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
_, err = attachPublicreportPoolImages0(ctx, exec, len(related), publicreportPool0, publicreportImages2)
|
2026-01-09 19:43:19 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
publicreportPool0.R.Images = append(publicreportPool0.R.Images, publicreportImages2...)
|
2026-01-09 19:43:19 +00:00
|
|
|
|
|
|
|
|
for _, rel := range related {
|
2026-01-16 14:52:11 +00:00
|
|
|
rel.R.Pools = append(rel.R.Pools, publicreportPool0)
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type publicreportPoolWhere[Q psql.Filterable] struct {
|
2026-02-05 21:43:29 +00:00
|
|
|
ID psql.WhereMod[Q, int32]
|
|
|
|
|
AccessComments psql.WhereMod[Q, string]
|
|
|
|
|
AccessGate psql.WhereMod[Q, bool]
|
|
|
|
|
AccessFence psql.WhereMod[Q, bool]
|
|
|
|
|
AccessLocked psql.WhereMod[Q, bool]
|
|
|
|
|
AccessDog psql.WhereMod[Q, bool]
|
|
|
|
|
AccessOther psql.WhereMod[Q, bool]
|
|
|
|
|
Address psql.WhereMod[Q, string]
|
|
|
|
|
AddressCountry psql.WhereMod[Q, string]
|
|
|
|
|
AddressPostCode psql.WhereMod[Q, string]
|
|
|
|
|
AddressPlace psql.WhereMod[Q, string]
|
|
|
|
|
AddressStreet psql.WhereMod[Q, string]
|
|
|
|
|
AddressRegion psql.WhereMod[Q, string]
|
|
|
|
|
Comments psql.WhereMod[Q, string]
|
|
|
|
|
Created psql.WhereMod[Q, time.Time]
|
|
|
|
|
H3cell psql.WhereNullMod[Q, string]
|
|
|
|
|
HasAdult psql.WhereMod[Q, bool]
|
|
|
|
|
HasLarvae psql.WhereMod[Q, bool]
|
|
|
|
|
HasPupae psql.WhereMod[Q, bool]
|
|
|
|
|
Location psql.WhereNullMod[Q, string]
|
|
|
|
|
MapZoom psql.WhereMod[Q, float32]
|
|
|
|
|
OwnerEmail psql.WhereMod[Q, string]
|
|
|
|
|
OwnerName psql.WhereMod[Q, string]
|
|
|
|
|
OwnerPhone psql.WhereMod[Q, string]
|
|
|
|
|
PublicID psql.WhereMod[Q, string]
|
|
|
|
|
ReporterEmail psql.WhereMod[Q, string]
|
|
|
|
|
ReporterName psql.WhereMod[Q, string]
|
|
|
|
|
ReporterPhone psql.WhereMod[Q, string]
|
|
|
|
|
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
|
|
|
|
OrganizationID psql.WhereNullMod[Q, int32]
|
|
|
|
|
HasBackyardPermission psql.WhereMod[Q, bool]
|
|
|
|
|
IsReporterConfidential psql.WhereMod[Q, bool]
|
|
|
|
|
IsReporterOwner psql.WhereMod[Q, bool]
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (publicreportPoolWhere[Q]) AliasedAs(alias string) publicreportPoolWhere[Q] {
|
|
|
|
|
return buildPublicreportPoolWhere[Q](buildPublicreportPoolColumns(alias))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildPublicreportPoolWhere[Q psql.Filterable](cols publicreportPoolColumns) publicreportPoolWhere[Q] {
|
|
|
|
|
return publicreportPoolWhere[Q]{
|
2026-02-05 21:43:29 +00:00
|
|
|
ID: psql.Where[Q, int32](cols.ID),
|
|
|
|
|
AccessComments: psql.Where[Q, string](cols.AccessComments),
|
|
|
|
|
AccessGate: psql.Where[Q, bool](cols.AccessGate),
|
|
|
|
|
AccessFence: psql.Where[Q, bool](cols.AccessFence),
|
|
|
|
|
AccessLocked: psql.Where[Q, bool](cols.AccessLocked),
|
|
|
|
|
AccessDog: psql.Where[Q, bool](cols.AccessDog),
|
|
|
|
|
AccessOther: psql.Where[Q, bool](cols.AccessOther),
|
|
|
|
|
Address: psql.Where[Q, string](cols.Address),
|
|
|
|
|
AddressCountry: psql.Where[Q, string](cols.AddressCountry),
|
|
|
|
|
AddressPostCode: psql.Where[Q, string](cols.AddressPostCode),
|
|
|
|
|
AddressPlace: psql.Where[Q, string](cols.AddressPlace),
|
|
|
|
|
AddressStreet: psql.Where[Q, string](cols.AddressStreet),
|
|
|
|
|
AddressRegion: psql.Where[Q, string](cols.AddressRegion),
|
|
|
|
|
Comments: psql.Where[Q, string](cols.Comments),
|
|
|
|
|
Created: psql.Where[Q, time.Time](cols.Created),
|
|
|
|
|
H3cell: psql.WhereNull[Q, string](cols.H3cell),
|
|
|
|
|
HasAdult: psql.Where[Q, bool](cols.HasAdult),
|
|
|
|
|
HasLarvae: psql.Where[Q, bool](cols.HasLarvae),
|
|
|
|
|
HasPupae: psql.Where[Q, bool](cols.HasPupae),
|
|
|
|
|
Location: psql.WhereNull[Q, string](cols.Location),
|
|
|
|
|
MapZoom: psql.Where[Q, float32](cols.MapZoom),
|
|
|
|
|
OwnerEmail: psql.Where[Q, string](cols.OwnerEmail),
|
|
|
|
|
OwnerName: psql.Where[Q, string](cols.OwnerName),
|
|
|
|
|
OwnerPhone: psql.Where[Q, string](cols.OwnerPhone),
|
|
|
|
|
PublicID: psql.Where[Q, string](cols.PublicID),
|
|
|
|
|
ReporterEmail: psql.Where[Q, string](cols.ReporterEmail),
|
|
|
|
|
ReporterName: psql.Where[Q, string](cols.ReporterName),
|
|
|
|
|
ReporterPhone: psql.Where[Q, string](cols.ReporterPhone),
|
|
|
|
|
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
|
|
|
|
OrganizationID: psql.WhereNull[Q, int32](cols.OrganizationID),
|
|
|
|
|
HasBackyardPermission: psql.Where[Q, bool](cols.HasBackyardPermission),
|
|
|
|
|
IsReporterConfidential: psql.Where[Q, bool](cols.IsReporterConfidential),
|
|
|
|
|
IsReporterOwner: psql.Where[Q, bool](cols.IsReporterOwner),
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o *PublicreportPool) Preload(name string, retrieved any) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch name {
|
2026-01-22 03:27:32 +00:00
|
|
|
case "Organization":
|
|
|
|
|
rel, ok := retrieved.(*Organization)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("publicreportPool cannot load %T as %q", retrieved, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o.R.Organization = rel
|
|
|
|
|
|
|
|
|
|
if rel != nil {
|
|
|
|
|
rel.R.PublicreportPool = PublicreportPoolSlice{o}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
2026-01-16 14:52:11 +00:00
|
|
|
case "Images":
|
|
|
|
|
rels, ok := retrieved.(PublicreportImageSlice)
|
2026-01-09 19:43:19 +00:00
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("publicreportPool cannot load %T as %q", retrieved, name)
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
o.R.Images = rels
|
2026-01-09 19:43:19 +00:00
|
|
|
|
|
|
|
|
for _, rel := range rels {
|
|
|
|
|
if rel != nil {
|
2026-01-16 14:52:11 +00:00
|
|
|
rel.R.Pools = PublicreportPoolSlice{o}
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
default:
|
|
|
|
|
return fmt.Errorf("publicreportPool has no relationship %q", name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 03:27:32 +00:00
|
|
|
type publicreportPoolPreloader struct {
|
|
|
|
|
Organization func(...psql.PreloadOption) psql.Preloader
|
|
|
|
|
}
|
2026-01-09 19:43:19 +00:00
|
|
|
|
|
|
|
|
func buildPublicreportPoolPreloader() publicreportPoolPreloader {
|
2026-01-22 03:27:32 +00:00
|
|
|
return publicreportPoolPreloader{
|
|
|
|
|
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
|
|
|
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
|
|
|
|
Name: "Organization",
|
|
|
|
|
Sides: []psql.PreloadSide{
|
|
|
|
|
{
|
|
|
|
|
From: PublicreportPools,
|
|
|
|
|
To: Organizations,
|
|
|
|
|
FromColumns: []string{"organization_id"},
|
|
|
|
|
ToColumns: []string{"id"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}, Organizations.Columns.Names(), opts...)
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type publicreportPoolThenLoader[Q orm.Loadable] struct {
|
2026-01-22 03:27:32 +00:00
|
|
|
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
|
|
|
Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildPublicreportPoolThenLoader[Q orm.Loadable]() publicreportPoolThenLoader[Q] {
|
2026-01-22 03:27:32 +00:00
|
|
|
type OrganizationLoadInterface interface {
|
|
|
|
|
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
|
|
|
}
|
2026-01-16 14:52:11 +00:00
|
|
|
type ImagesLoadInterface interface {
|
|
|
|
|
LoadImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return publicreportPoolThenLoader[Q]{
|
2026-01-22 03:27:32 +00:00
|
|
|
Organization: thenLoadBuilder[Q](
|
|
|
|
|
"Organization",
|
|
|
|
|
func(ctx context.Context, exec bob.Executor, retrieved OrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
return retrieved.LoadOrganization(ctx, exec, mods...)
|
|
|
|
|
},
|
|
|
|
|
),
|
2026-01-16 14:52:11 +00:00
|
|
|
Images: thenLoadBuilder[Q](
|
|
|
|
|
"Images",
|
|
|
|
|
func(ctx context.Context, exec bob.Executor, retrieved ImagesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
return retrieved.LoadImages(ctx, exec, mods...)
|
2026-01-09 19:43:19 +00:00
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 03:27:32 +00:00
|
|
|
// LoadOrganization loads the publicreportPool's Organization into the .R struct
|
|
|
|
|
func (o *PublicreportPool) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the relationship
|
|
|
|
|
o.R.Organization = nil
|
|
|
|
|
|
|
|
|
|
related, err := o.Organization(mods...).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
related.R.PublicreportPool = PublicreportPoolSlice{o}
|
|
|
|
|
|
|
|
|
|
o.R.Organization = related
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadOrganization loads the publicreportPool's Organization into the .R struct
|
|
|
|
|
func (os PublicreportPoolSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
if len(os) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
organizations, err := os.Organization(mods...).All(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
|
|
|
|
if o == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, rel := range organizations {
|
|
|
|
|
if !o.OrganizationID.IsValue() {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !(o.OrganizationID.IsValue() && o.OrganizationID.MustGet() == rel.ID) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rel.R.PublicreportPool = append(rel.R.PublicreportPool, o)
|
|
|
|
|
|
|
|
|
|
o.R.Organization = rel
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
// LoadImages loads the publicreportPool's Images into the .R struct
|
|
|
|
|
func (o *PublicreportPool) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
2026-01-09 19:43:19 +00:00
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the relationship
|
2026-01-16 14:52:11 +00:00
|
|
|
o.R.Images = nil
|
2026-01-09 19:43:19 +00:00
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
related, err := o.Images(mods...).All(ctx, exec)
|
2026-01-09 19:43:19 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, rel := range related {
|
2026-01-16 14:52:11 +00:00
|
|
|
rel.R.Pools = PublicreportPoolSlice{o}
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
o.R.Images = related
|
2026-01-09 19:43:19 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
// LoadImages loads the publicreportPool's Images into the .R struct
|
|
|
|
|
func (os PublicreportPoolSlice) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
2026-01-09 19:43:19 +00:00
|
|
|
if len(os) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
// since we are changing the columns, we need to check if the original columns were set or add the defaults
|
|
|
|
|
sq := dialect.SelectQuery{}
|
|
|
|
|
for _, mod := range mods {
|
|
|
|
|
mod.Apply(&sq)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(sq.SelectList.Columns) == 0 {
|
|
|
|
|
mods = append(mods, sm.Columns(PublicreportImages.Columns))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
q := os.Images(append(
|
|
|
|
|
mods,
|
|
|
|
|
sm.Columns(PublicreportPoolImages.Columns.PoolID.As("related_publicreport.pool.ID")),
|
|
|
|
|
)...)
|
|
|
|
|
|
|
|
|
|
IDSlice := []int32{}
|
|
|
|
|
|
|
|
|
|
mapper := scan.Mod(scan.StructMapper[*PublicreportImage](), func(ctx context.Context, cols []string) (scan.BeforeFunc, func(any, any) error) {
|
|
|
|
|
return func(row *scan.Row) (any, error) {
|
|
|
|
|
IDSlice = append(IDSlice, *new(int32))
|
|
|
|
|
row.ScheduleScanByName("related_publicreport.pool.ID", &IDSlice[len(IDSlice)-1])
|
|
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
|
},
|
|
|
|
|
func(any, any) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
publicreportImages, err := bob.Allx[bob.SliceTransformer[*PublicreportImage, PublicreportImageSlice]](ctx, exec, q, mapper)
|
2026-01-09 19:43:19 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
2026-01-16 14:52:11 +00:00
|
|
|
o.R.Images = nil
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
2026-01-16 14:52:11 +00:00
|
|
|
for i, rel := range publicreportImages {
|
|
|
|
|
if !(o.ID == IDSlice[i]) {
|
2026-01-09 19:43:19 +00:00
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
rel.R.Pools = append(rel.R.Pools, o)
|
2026-01-09 19:43:19 +00:00
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
o.R.Images = append(o.R.Images, rel)
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 19:18:34 +00:00
|
|
|
// publicreportPoolC is where relationship counts are stored.
|
|
|
|
|
type publicreportPoolC struct {
|
2026-01-16 14:52:11 +00:00
|
|
|
Images *int64
|
2026-01-15 19:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PreloadCount sets a count in the C struct by name
|
|
|
|
|
func (o *PublicreportPool) PreloadCount(name string, count int64) error {
|
|
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch name {
|
2026-01-16 14:52:11 +00:00
|
|
|
case "Images":
|
|
|
|
|
o.C.Images = &count
|
2026-01-15 19:18:34 +00:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type publicreportPoolCountPreloader struct {
|
2026-01-16 14:52:11 +00:00
|
|
|
Images func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
2026-01-15 19:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildPublicreportPoolCountPreloader() publicreportPoolCountPreloader {
|
|
|
|
|
return publicreportPoolCountPreloader{
|
2026-01-16 14:52:11 +00:00
|
|
|
Images: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
|
|
|
|
|
return countPreloader[*PublicreportPool]("Images", func(parent string) bob.Expression {
|
2026-01-15 19:18:34 +00:00
|
|
|
// Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
|
|
|
|
|
if parent == "" {
|
|
|
|
|
parent = PublicreportPools.Alias()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
subqueryMods := []bob.Mod[*dialect.SelectQuery]{
|
|
|
|
|
sm.Columns(psql.Raw("count(*)")),
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
sm.From(PublicreportPoolImages.Name()),
|
|
|
|
|
sm.Where(psql.Quote(PublicreportPoolImages.Alias(), "pool_id").EQ(psql.Quote(parent, "id"))),
|
|
|
|
|
sm.InnerJoin(PublicreportImages.Name()).On(
|
|
|
|
|
psql.Quote(PublicreportImages.Alias(), "id").EQ(psql.Quote(PublicreportPoolImages.Alias(), "image_id")),
|
|
|
|
|
),
|
2026-01-15 19:18:34 +00:00
|
|
|
}
|
|
|
|
|
subqueryMods = append(subqueryMods, mods...)
|
|
|
|
|
return psql.Group(psql.Select(subqueryMods...).Expression)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type publicreportPoolCountThenLoader[Q orm.Loadable] struct {
|
2026-01-16 14:52:11 +00:00
|
|
|
Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
2026-01-15 19:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildPublicreportPoolCountThenLoader[Q orm.Loadable]() publicreportPoolCountThenLoader[Q] {
|
2026-01-16 14:52:11 +00:00
|
|
|
type ImagesCountInterface interface {
|
|
|
|
|
LoadCountImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
2026-01-15 19:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return publicreportPoolCountThenLoader[Q]{
|
2026-01-16 14:52:11 +00:00
|
|
|
Images: countThenLoadBuilder[Q](
|
|
|
|
|
"Images",
|
|
|
|
|
func(ctx context.Context, exec bob.Executor, retrieved ImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
|
|
|
return retrieved.LoadCountImages(ctx, exec, mods...)
|
2026-01-15 19:18:34 +00:00
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
// LoadCountImages loads the count of Images into the C struct
|
|
|
|
|
func (o *PublicreportPool) LoadCountImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
2026-01-15 19:18:34 +00:00
|
|
|
if o == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
count, err := o.Images(mods...).Count(ctx, exec)
|
2026-01-15 19:18:34 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
o.C.Images = &count
|
2026-01-15 19:18:34 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:52:11 +00:00
|
|
|
// LoadCountImages loads the count of Images for a slice
|
|
|
|
|
func (os PublicreportPoolSlice) LoadCountImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
2026-01-15 19:18:34 +00:00
|
|
|
if len(os) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, o := range os {
|
2026-01-16 14:52:11 +00:00
|
|
|
if err := o.LoadCountImages(ctx, exec, mods...); err != nil {
|
2026-01-15 19:18:34 +00:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-09 19:43:19 +00:00
|
|
|
type publicreportPoolJoins[Q dialect.Joinable] struct {
|
2026-01-22 03:27:32 +00:00
|
|
|
typ string
|
|
|
|
|
Organization modAs[Q, organizationColumns]
|
|
|
|
|
Images modAs[Q, publicreportImageColumns]
|
2026-01-09 19:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (j publicreportPoolJoins[Q]) aliasedAs(alias string) publicreportPoolJoins[Q] {
|
|
|
|
|
return buildPublicreportPoolJoins[Q](buildPublicreportPoolColumns(alias), j.typ)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func buildPublicreportPoolJoins[Q dialect.Joinable](cols publicreportPoolColumns, typ string) publicreportPoolJoins[Q] {
|
|
|
|
|
return publicreportPoolJoins[Q]{
|
|
|
|
|
typ: typ,
|
2026-01-22 03:27:32 +00:00
|
|
|
Organization: modAs[Q, organizationColumns]{
|
|
|
|
|
c: Organizations.Columns,
|
|
|
|
|
f: func(to organizationColumns) bob.Mod[Q] {
|
|
|
|
|
mods := make(mods.QueryMods[Q], 0, 1)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On(
|
|
|
|
|
to.ID.EQ(cols.OrganizationID),
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mods
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-01-16 14:52:11 +00:00
|
|
|
Images: modAs[Q, publicreportImageColumns]{
|
|
|
|
|
c: PublicreportImages.Columns,
|
|
|
|
|
f: func(to publicreportImageColumns) bob.Mod[Q] {
|
|
|
|
|
random := strconv.FormatInt(randInt(), 10)
|
|
|
|
|
mods := make(mods.QueryMods[Q], 0, 2)
|
2026-01-09 19:43:19 +00:00
|
|
|
|
|
|
|
|
{
|
2026-01-16 14:52:11 +00:00
|
|
|
to := PublicreportPoolImages.Columns.AliasedAs(PublicreportPoolImages.Columns.Alias() + random)
|
|
|
|
|
mods = append(mods, dialect.Join[Q](typ, PublicreportPoolImages.Name().As(to.Alias())).On(
|
2026-01-09 19:43:19 +00:00
|
|
|
to.PoolID.EQ(cols.ID),
|
|
|
|
|
))
|
|
|
|
|
}
|
2026-01-16 14:52:11 +00:00
|
|
|
{
|
|
|
|
|
cols := PublicreportPoolImages.Columns.AliasedAs(PublicreportPoolImages.Columns.Alias() + random)
|
|
|
|
|
mods = append(mods, dialect.Join[Q](typ, PublicreportImages.Name().As(to.Alias())).On(
|
|
|
|
|
to.ID.EQ(cols.ImageID),
|
|
|
|
|
))
|
|
|
|
|
}
|
2026-01-09 19:43:19 +00:00
|
|
|
|
|
|
|
|
return mods
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|