This is a huge change. I was getting really sick of the split between nuisance/water tables when more than half of the data they store is common. I finally bit off the big work of switching it all. This creates a single unified table, publicreport.report and copies the existing report data into it. It also ports existing data from the original tables into the new table. Along with all of this I also overhauled the system for handling asynchronous work to use a LISTEN/NOTIFY connection from the database and a single cache table to avoid ever losing work.
2386 lines
79 KiB
Go
2386 lines
79 KiB
Go
// 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"
|
|
"github.com/stephenafamo/scan"
|
|
)
|
|
|
|
// PublicreportNuisanceOld is an object representing the database table.
|
|
type PublicreportNuisanceOld struct {
|
|
ID int32 `db:"id,pk" `
|
|
AdditionalInfo string `db:"additional_info" `
|
|
Created time.Time `db:"created" `
|
|
Duration enums.PublicreportNuisancedurationtype `db:"duration" `
|
|
SourceContainer bool `db:"source_container" `
|
|
SourceDescription string `db:"source_description" `
|
|
SourceStagnant bool `db:"source_stagnant" `
|
|
PublicID string `db:"public_id" `
|
|
ReporterEmail null.Val[string] `db:"reporter_email" `
|
|
ReporterName null.Val[string] `db:"reporter_name" `
|
|
ReporterPhone null.Val[string] `db:"reporter_phone" `
|
|
AddressRaw string `db:"address_raw" `
|
|
Status enums.PublicreportReportstatustype `db:"status" `
|
|
OrganizationID int32 `db:"organization_id" `
|
|
SourceGutter bool `db:"source_gutter" `
|
|
H3cell null.Val[string] `db:"h3cell" `
|
|
AddressCountry string `db:"address_country" `
|
|
AddressLocality string `db:"address_locality" `
|
|
AddressPostalCode string `db:"address_postal_code" `
|
|
AddressRegion string `db:"address_region" `
|
|
AddressStreet string `db:"address_street" `
|
|
IsLocationBackyard bool `db:"is_location_backyard" `
|
|
IsLocationFrontyard bool `db:"is_location_frontyard" `
|
|
IsLocationGarden bool `db:"is_location_garden" `
|
|
IsLocationOther bool `db:"is_location_other" `
|
|
IsLocationPool bool `db:"is_location_pool" `
|
|
MapZoom float32 `db:"map_zoom" `
|
|
TodEarly bool `db:"tod_early" `
|
|
TodDay bool `db:"tod_day" `
|
|
TodEvening bool `db:"tod_evening" `
|
|
TodNight bool `db:"tod_night" `
|
|
LatlngAccuracyType enums.PublicreportAccuracytype `db:"latlng_accuracy_type" `
|
|
LatlngAccuracyValue float32 `db:"latlng_accuracy_value" `
|
|
ReporterContactConsent null.Val[bool] `db:"reporter_contact_consent" `
|
|
Location null.Val[string] `db:"location" `
|
|
AddressNumber string `db:"address_number" `
|
|
AddressID null.Val[int32] `db:"address_id" `
|
|
Reviewed null.Val[time.Time] `db:"reviewed" `
|
|
ReviewerID null.Val[int32] `db:"reviewer_id" `
|
|
|
|
R publicreportNuisanceOldR `db:"-" `
|
|
}
|
|
|
|
// PublicreportNuisanceOldSlice is an alias for a slice of pointers to PublicreportNuisanceOld.
|
|
// This should almost always be used instead of []*PublicreportNuisanceOld.
|
|
type PublicreportNuisanceOldSlice []*PublicreportNuisanceOld
|
|
|
|
// PublicreportNuisanceOlds contains methods to work with the nuisance_old table
|
|
var PublicreportNuisanceOlds = psql.NewTablex[*PublicreportNuisanceOld, PublicreportNuisanceOldSlice, *PublicreportNuisanceOldSetter]("publicreport", "nuisance_old", buildPublicreportNuisanceOldColumns("publicreport.nuisance_old"))
|
|
|
|
// PublicreportNuisanceOldsQuery is a query on the nuisance_old table
|
|
type PublicreportNuisanceOldsQuery = *psql.ViewQuery[*PublicreportNuisanceOld, PublicreportNuisanceOldSlice]
|
|
|
|
// publicreportNuisanceOldR is where relationships are stored.
|
|
type publicreportNuisanceOldR struct {
|
|
NuisanceNotifyEmailNuisanceOlds PublicreportNotifyEmailNuisanceOldSlice // publicreport.notify_email_nuisance_old.notify_email_nuisance_nuisance_id_fkey
|
|
NuisanceNotifyPhoneNuisanceOlds PublicreportNotifyPhoneNuisanceOldSlice // publicreport.notify_phone_nuisance_old.notify_phone_nuisance_nuisance_id_fkey
|
|
Images PublicreportImageSlice // publicreport.nuisance_image_old.nuisance_image_image_id_fkeypublicreport.nuisance_image_old.nuisance_image_nuisance_id_fkey
|
|
Address *Address // publicreport.nuisance_old.nuisance_address_id_fkey
|
|
Organization *Organization // publicreport.nuisance_old.nuisance_organization_id_fkey
|
|
ReviewerUser *User // publicreport.nuisance_old.nuisance_reviewer_id_fkey
|
|
}
|
|
|
|
func buildPublicreportNuisanceOldColumns(alias string) publicreportNuisanceOldColumns {
|
|
return publicreportNuisanceOldColumns{
|
|
ColumnsExpr: expr.NewColumnsExpr(
|
|
"id", "additional_info", "created", "duration", "source_container", "source_description", "source_stagnant", "public_id", "reporter_email", "reporter_name", "reporter_phone", "address_raw", "status", "organization_id", "source_gutter", "h3cell", "address_country", "address_locality", "address_postal_code", "address_region", "address_street", "is_location_backyard", "is_location_frontyard", "is_location_garden", "is_location_other", "is_location_pool", "map_zoom", "tod_early", "tod_day", "tod_evening", "tod_night", "latlng_accuracy_type", "latlng_accuracy_value", "reporter_contact_consent", "location", "address_number", "address_id", "reviewed", "reviewer_id",
|
|
).WithParent("publicreport.nuisance_old"),
|
|
tableAlias: alias,
|
|
ID: psql.Quote(alias, "id"),
|
|
AdditionalInfo: psql.Quote(alias, "additional_info"),
|
|
Created: psql.Quote(alias, "created"),
|
|
Duration: psql.Quote(alias, "duration"),
|
|
SourceContainer: psql.Quote(alias, "source_container"),
|
|
SourceDescription: psql.Quote(alias, "source_description"),
|
|
SourceStagnant: psql.Quote(alias, "source_stagnant"),
|
|
PublicID: psql.Quote(alias, "public_id"),
|
|
ReporterEmail: psql.Quote(alias, "reporter_email"),
|
|
ReporterName: psql.Quote(alias, "reporter_name"),
|
|
ReporterPhone: psql.Quote(alias, "reporter_phone"),
|
|
AddressRaw: psql.Quote(alias, "address_raw"),
|
|
Status: psql.Quote(alias, "status"),
|
|
OrganizationID: psql.Quote(alias, "organization_id"),
|
|
SourceGutter: psql.Quote(alias, "source_gutter"),
|
|
H3cell: psql.Quote(alias, "h3cell"),
|
|
AddressCountry: psql.Quote(alias, "address_country"),
|
|
AddressLocality: psql.Quote(alias, "address_locality"),
|
|
AddressPostalCode: psql.Quote(alias, "address_postal_code"),
|
|
AddressRegion: psql.Quote(alias, "address_region"),
|
|
AddressStreet: psql.Quote(alias, "address_street"),
|
|
IsLocationBackyard: psql.Quote(alias, "is_location_backyard"),
|
|
IsLocationFrontyard: psql.Quote(alias, "is_location_frontyard"),
|
|
IsLocationGarden: psql.Quote(alias, "is_location_garden"),
|
|
IsLocationOther: psql.Quote(alias, "is_location_other"),
|
|
IsLocationPool: psql.Quote(alias, "is_location_pool"),
|
|
MapZoom: psql.Quote(alias, "map_zoom"),
|
|
TodEarly: psql.Quote(alias, "tod_early"),
|
|
TodDay: psql.Quote(alias, "tod_day"),
|
|
TodEvening: psql.Quote(alias, "tod_evening"),
|
|
TodNight: psql.Quote(alias, "tod_night"),
|
|
LatlngAccuracyType: psql.Quote(alias, "latlng_accuracy_type"),
|
|
LatlngAccuracyValue: psql.Quote(alias, "latlng_accuracy_value"),
|
|
ReporterContactConsent: psql.Quote(alias, "reporter_contact_consent"),
|
|
Location: psql.Quote(alias, "location"),
|
|
AddressNumber: psql.Quote(alias, "address_number"),
|
|
AddressID: psql.Quote(alias, "address_id"),
|
|
Reviewed: psql.Quote(alias, "reviewed"),
|
|
ReviewerID: psql.Quote(alias, "reviewer_id"),
|
|
}
|
|
}
|
|
|
|
type publicreportNuisanceOldColumns struct {
|
|
expr.ColumnsExpr
|
|
tableAlias string
|
|
ID psql.Expression
|
|
AdditionalInfo psql.Expression
|
|
Created psql.Expression
|
|
Duration psql.Expression
|
|
SourceContainer psql.Expression
|
|
SourceDescription psql.Expression
|
|
SourceStagnant psql.Expression
|
|
PublicID psql.Expression
|
|
ReporterEmail psql.Expression
|
|
ReporterName psql.Expression
|
|
ReporterPhone psql.Expression
|
|
AddressRaw psql.Expression
|
|
Status psql.Expression
|
|
OrganizationID psql.Expression
|
|
SourceGutter psql.Expression
|
|
H3cell psql.Expression
|
|
AddressCountry psql.Expression
|
|
AddressLocality psql.Expression
|
|
AddressPostalCode psql.Expression
|
|
AddressRegion psql.Expression
|
|
AddressStreet psql.Expression
|
|
IsLocationBackyard psql.Expression
|
|
IsLocationFrontyard psql.Expression
|
|
IsLocationGarden psql.Expression
|
|
IsLocationOther psql.Expression
|
|
IsLocationPool psql.Expression
|
|
MapZoom psql.Expression
|
|
TodEarly psql.Expression
|
|
TodDay psql.Expression
|
|
TodEvening psql.Expression
|
|
TodNight psql.Expression
|
|
LatlngAccuracyType psql.Expression
|
|
LatlngAccuracyValue psql.Expression
|
|
ReporterContactConsent psql.Expression
|
|
Location psql.Expression
|
|
AddressNumber psql.Expression
|
|
AddressID psql.Expression
|
|
Reviewed psql.Expression
|
|
ReviewerID psql.Expression
|
|
}
|
|
|
|
func (c publicreportNuisanceOldColumns) Alias() string {
|
|
return c.tableAlias
|
|
}
|
|
|
|
func (publicreportNuisanceOldColumns) AliasedAs(alias string) publicreportNuisanceOldColumns {
|
|
return buildPublicreportNuisanceOldColumns(alias)
|
|
}
|
|
|
|
// PublicreportNuisanceOldSetter is used for insert/upsert/update operations
|
|
// All values are optional, and do not have to be set
|
|
// Generated columns are not included
|
|
type PublicreportNuisanceOldSetter struct {
|
|
ID omit.Val[int32] `db:"id,pk" `
|
|
AdditionalInfo omit.Val[string] `db:"additional_info" `
|
|
Created omit.Val[time.Time] `db:"created" `
|
|
Duration omit.Val[enums.PublicreportNuisancedurationtype] `db:"duration" `
|
|
SourceContainer omit.Val[bool] `db:"source_container" `
|
|
SourceDescription omit.Val[string] `db:"source_description" `
|
|
SourceStagnant omit.Val[bool] `db:"source_stagnant" `
|
|
PublicID omit.Val[string] `db:"public_id" `
|
|
ReporterEmail omitnull.Val[string] `db:"reporter_email" `
|
|
ReporterName omitnull.Val[string] `db:"reporter_name" `
|
|
ReporterPhone omitnull.Val[string] `db:"reporter_phone" `
|
|
AddressRaw omit.Val[string] `db:"address_raw" `
|
|
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
|
OrganizationID omit.Val[int32] `db:"organization_id" `
|
|
SourceGutter omit.Val[bool] `db:"source_gutter" `
|
|
H3cell omitnull.Val[string] `db:"h3cell" `
|
|
AddressCountry omit.Val[string] `db:"address_country" `
|
|
AddressLocality omit.Val[string] `db:"address_locality" `
|
|
AddressPostalCode omit.Val[string] `db:"address_postal_code" `
|
|
AddressRegion omit.Val[string] `db:"address_region" `
|
|
AddressStreet omit.Val[string] `db:"address_street" `
|
|
IsLocationBackyard omit.Val[bool] `db:"is_location_backyard" `
|
|
IsLocationFrontyard omit.Val[bool] `db:"is_location_frontyard" `
|
|
IsLocationGarden omit.Val[bool] `db:"is_location_garden" `
|
|
IsLocationOther omit.Val[bool] `db:"is_location_other" `
|
|
IsLocationPool omit.Val[bool] `db:"is_location_pool" `
|
|
MapZoom omit.Val[float32] `db:"map_zoom" `
|
|
TodEarly omit.Val[bool] `db:"tod_early" `
|
|
TodDay omit.Val[bool] `db:"tod_day" `
|
|
TodEvening omit.Val[bool] `db:"tod_evening" `
|
|
TodNight omit.Val[bool] `db:"tod_night" `
|
|
LatlngAccuracyType omit.Val[enums.PublicreportAccuracytype] `db:"latlng_accuracy_type" `
|
|
LatlngAccuracyValue omit.Val[float32] `db:"latlng_accuracy_value" `
|
|
ReporterContactConsent omitnull.Val[bool] `db:"reporter_contact_consent" `
|
|
Location omitnull.Val[string] `db:"location" `
|
|
AddressNumber omit.Val[string] `db:"address_number" `
|
|
AddressID omitnull.Val[int32] `db:"address_id" `
|
|
Reviewed omitnull.Val[time.Time] `db:"reviewed" `
|
|
ReviewerID omitnull.Val[int32] `db:"reviewer_id" `
|
|
}
|
|
|
|
func (s PublicreportNuisanceOldSetter) SetColumns() []string {
|
|
vals := make([]string, 0, 39)
|
|
if s.ID.IsValue() {
|
|
vals = append(vals, "id")
|
|
}
|
|
if s.AdditionalInfo.IsValue() {
|
|
vals = append(vals, "additional_info")
|
|
}
|
|
if s.Created.IsValue() {
|
|
vals = append(vals, "created")
|
|
}
|
|
if s.Duration.IsValue() {
|
|
vals = append(vals, "duration")
|
|
}
|
|
if s.SourceContainer.IsValue() {
|
|
vals = append(vals, "source_container")
|
|
}
|
|
if s.SourceDescription.IsValue() {
|
|
vals = append(vals, "source_description")
|
|
}
|
|
if s.SourceStagnant.IsValue() {
|
|
vals = append(vals, "source_stagnant")
|
|
}
|
|
if s.PublicID.IsValue() {
|
|
vals = append(vals, "public_id")
|
|
}
|
|
if !s.ReporterEmail.IsUnset() {
|
|
vals = append(vals, "reporter_email")
|
|
}
|
|
if !s.ReporterName.IsUnset() {
|
|
vals = append(vals, "reporter_name")
|
|
}
|
|
if !s.ReporterPhone.IsUnset() {
|
|
vals = append(vals, "reporter_phone")
|
|
}
|
|
if s.AddressRaw.IsValue() {
|
|
vals = append(vals, "address_raw")
|
|
}
|
|
if s.Status.IsValue() {
|
|
vals = append(vals, "status")
|
|
}
|
|
if s.OrganizationID.IsValue() {
|
|
vals = append(vals, "organization_id")
|
|
}
|
|
if s.SourceGutter.IsValue() {
|
|
vals = append(vals, "source_gutter")
|
|
}
|
|
if !s.H3cell.IsUnset() {
|
|
vals = append(vals, "h3cell")
|
|
}
|
|
if s.AddressCountry.IsValue() {
|
|
vals = append(vals, "address_country")
|
|
}
|
|
if s.AddressLocality.IsValue() {
|
|
vals = append(vals, "address_locality")
|
|
}
|
|
if s.AddressPostalCode.IsValue() {
|
|
vals = append(vals, "address_postal_code")
|
|
}
|
|
if s.AddressRegion.IsValue() {
|
|
vals = append(vals, "address_region")
|
|
}
|
|
if s.AddressStreet.IsValue() {
|
|
vals = append(vals, "address_street")
|
|
}
|
|
if s.IsLocationBackyard.IsValue() {
|
|
vals = append(vals, "is_location_backyard")
|
|
}
|
|
if s.IsLocationFrontyard.IsValue() {
|
|
vals = append(vals, "is_location_frontyard")
|
|
}
|
|
if s.IsLocationGarden.IsValue() {
|
|
vals = append(vals, "is_location_garden")
|
|
}
|
|
if s.IsLocationOther.IsValue() {
|
|
vals = append(vals, "is_location_other")
|
|
}
|
|
if s.IsLocationPool.IsValue() {
|
|
vals = append(vals, "is_location_pool")
|
|
}
|
|
if s.MapZoom.IsValue() {
|
|
vals = append(vals, "map_zoom")
|
|
}
|
|
if s.TodEarly.IsValue() {
|
|
vals = append(vals, "tod_early")
|
|
}
|
|
if s.TodDay.IsValue() {
|
|
vals = append(vals, "tod_day")
|
|
}
|
|
if s.TodEvening.IsValue() {
|
|
vals = append(vals, "tod_evening")
|
|
}
|
|
if s.TodNight.IsValue() {
|
|
vals = append(vals, "tod_night")
|
|
}
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
vals = append(vals, "latlng_accuracy_type")
|
|
}
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
vals = append(vals, "latlng_accuracy_value")
|
|
}
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
vals = append(vals, "reporter_contact_consent")
|
|
}
|
|
if !s.Location.IsUnset() {
|
|
vals = append(vals, "location")
|
|
}
|
|
if s.AddressNumber.IsValue() {
|
|
vals = append(vals, "address_number")
|
|
}
|
|
if !s.AddressID.IsUnset() {
|
|
vals = append(vals, "address_id")
|
|
}
|
|
if !s.Reviewed.IsUnset() {
|
|
vals = append(vals, "reviewed")
|
|
}
|
|
if !s.ReviewerID.IsUnset() {
|
|
vals = append(vals, "reviewer_id")
|
|
}
|
|
return vals
|
|
}
|
|
|
|
func (s PublicreportNuisanceOldSetter) Overwrite(t *PublicreportNuisanceOld) {
|
|
if s.ID.IsValue() {
|
|
t.ID = s.ID.MustGet()
|
|
}
|
|
if s.AdditionalInfo.IsValue() {
|
|
t.AdditionalInfo = s.AdditionalInfo.MustGet()
|
|
}
|
|
if s.Created.IsValue() {
|
|
t.Created = s.Created.MustGet()
|
|
}
|
|
if s.Duration.IsValue() {
|
|
t.Duration = s.Duration.MustGet()
|
|
}
|
|
if s.SourceContainer.IsValue() {
|
|
t.SourceContainer = s.SourceContainer.MustGet()
|
|
}
|
|
if s.SourceDescription.IsValue() {
|
|
t.SourceDescription = s.SourceDescription.MustGet()
|
|
}
|
|
if s.SourceStagnant.IsValue() {
|
|
t.SourceStagnant = s.SourceStagnant.MustGet()
|
|
}
|
|
if s.PublicID.IsValue() {
|
|
t.PublicID = s.PublicID.MustGet()
|
|
}
|
|
if !s.ReporterEmail.IsUnset() {
|
|
t.ReporterEmail = s.ReporterEmail.MustGetNull()
|
|
}
|
|
if !s.ReporterName.IsUnset() {
|
|
t.ReporterName = s.ReporterName.MustGetNull()
|
|
}
|
|
if !s.ReporterPhone.IsUnset() {
|
|
t.ReporterPhone = s.ReporterPhone.MustGetNull()
|
|
}
|
|
if s.AddressRaw.IsValue() {
|
|
t.AddressRaw = s.AddressRaw.MustGet()
|
|
}
|
|
if s.Status.IsValue() {
|
|
t.Status = s.Status.MustGet()
|
|
}
|
|
if s.OrganizationID.IsValue() {
|
|
t.OrganizationID = s.OrganizationID.MustGet()
|
|
}
|
|
if s.SourceGutter.IsValue() {
|
|
t.SourceGutter = s.SourceGutter.MustGet()
|
|
}
|
|
if !s.H3cell.IsUnset() {
|
|
t.H3cell = s.H3cell.MustGetNull()
|
|
}
|
|
if s.AddressCountry.IsValue() {
|
|
t.AddressCountry = s.AddressCountry.MustGet()
|
|
}
|
|
if s.AddressLocality.IsValue() {
|
|
t.AddressLocality = s.AddressLocality.MustGet()
|
|
}
|
|
if s.AddressPostalCode.IsValue() {
|
|
t.AddressPostalCode = s.AddressPostalCode.MustGet()
|
|
}
|
|
if s.AddressRegion.IsValue() {
|
|
t.AddressRegion = s.AddressRegion.MustGet()
|
|
}
|
|
if s.AddressStreet.IsValue() {
|
|
t.AddressStreet = s.AddressStreet.MustGet()
|
|
}
|
|
if s.IsLocationBackyard.IsValue() {
|
|
t.IsLocationBackyard = s.IsLocationBackyard.MustGet()
|
|
}
|
|
if s.IsLocationFrontyard.IsValue() {
|
|
t.IsLocationFrontyard = s.IsLocationFrontyard.MustGet()
|
|
}
|
|
if s.IsLocationGarden.IsValue() {
|
|
t.IsLocationGarden = s.IsLocationGarden.MustGet()
|
|
}
|
|
if s.IsLocationOther.IsValue() {
|
|
t.IsLocationOther = s.IsLocationOther.MustGet()
|
|
}
|
|
if s.IsLocationPool.IsValue() {
|
|
t.IsLocationPool = s.IsLocationPool.MustGet()
|
|
}
|
|
if s.MapZoom.IsValue() {
|
|
t.MapZoom = s.MapZoom.MustGet()
|
|
}
|
|
if s.TodEarly.IsValue() {
|
|
t.TodEarly = s.TodEarly.MustGet()
|
|
}
|
|
if s.TodDay.IsValue() {
|
|
t.TodDay = s.TodDay.MustGet()
|
|
}
|
|
if s.TodEvening.IsValue() {
|
|
t.TodEvening = s.TodEvening.MustGet()
|
|
}
|
|
if s.TodNight.IsValue() {
|
|
t.TodNight = s.TodNight.MustGet()
|
|
}
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
t.LatlngAccuracyType = s.LatlngAccuracyType.MustGet()
|
|
}
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
t.LatlngAccuracyValue = s.LatlngAccuracyValue.MustGet()
|
|
}
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
t.ReporterContactConsent = s.ReporterContactConsent.MustGetNull()
|
|
}
|
|
if !s.Location.IsUnset() {
|
|
t.Location = s.Location.MustGetNull()
|
|
}
|
|
if s.AddressNumber.IsValue() {
|
|
t.AddressNumber = s.AddressNumber.MustGet()
|
|
}
|
|
if !s.AddressID.IsUnset() {
|
|
t.AddressID = s.AddressID.MustGetNull()
|
|
}
|
|
if !s.Reviewed.IsUnset() {
|
|
t.Reviewed = s.Reviewed.MustGetNull()
|
|
}
|
|
if !s.ReviewerID.IsUnset() {
|
|
t.ReviewerID = s.ReviewerID.MustGetNull()
|
|
}
|
|
}
|
|
|
|
func (s *PublicreportNuisanceOldSetter) Apply(q *dialect.InsertQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return PublicreportNuisanceOlds.BeforeInsertHooks.RunHooks(ctx, exec, s)
|
|
})
|
|
|
|
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
vals := make([]bob.Expression, 39)
|
|
if s.ID.IsValue() {
|
|
vals[0] = psql.Arg(s.ID.MustGet())
|
|
} else {
|
|
vals[0] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AdditionalInfo.IsValue() {
|
|
vals[1] = psql.Arg(s.AdditionalInfo.MustGet())
|
|
} else {
|
|
vals[1] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Created.IsValue() {
|
|
vals[2] = psql.Arg(s.Created.MustGet())
|
|
} else {
|
|
vals[2] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Duration.IsValue() {
|
|
vals[3] = psql.Arg(s.Duration.MustGet())
|
|
} else {
|
|
vals[3] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.SourceContainer.IsValue() {
|
|
vals[4] = psql.Arg(s.SourceContainer.MustGet())
|
|
} else {
|
|
vals[4] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.SourceDescription.IsValue() {
|
|
vals[5] = psql.Arg(s.SourceDescription.MustGet())
|
|
} else {
|
|
vals[5] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.SourceStagnant.IsValue() {
|
|
vals[6] = psql.Arg(s.SourceStagnant.MustGet())
|
|
} else {
|
|
vals[6] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.PublicID.IsValue() {
|
|
vals[7] = psql.Arg(s.PublicID.MustGet())
|
|
} else {
|
|
vals[7] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ReporterEmail.IsUnset() {
|
|
vals[8] = psql.Arg(s.ReporterEmail.MustGetNull())
|
|
} else {
|
|
vals[8] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ReporterName.IsUnset() {
|
|
vals[9] = psql.Arg(s.ReporterName.MustGetNull())
|
|
} else {
|
|
vals[9] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ReporterPhone.IsUnset() {
|
|
vals[10] = psql.Arg(s.ReporterPhone.MustGetNull())
|
|
} else {
|
|
vals[10] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressRaw.IsValue() {
|
|
vals[11] = psql.Arg(s.AddressRaw.MustGet())
|
|
} else {
|
|
vals[11] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Status.IsValue() {
|
|
vals[12] = psql.Arg(s.Status.MustGet())
|
|
} else {
|
|
vals[12] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.OrganizationID.IsValue() {
|
|
vals[13] = psql.Arg(s.OrganizationID.MustGet())
|
|
} else {
|
|
vals[13] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.SourceGutter.IsValue() {
|
|
vals[14] = psql.Arg(s.SourceGutter.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.AddressCountry.IsValue() {
|
|
vals[16] = psql.Arg(s.AddressCountry.MustGet())
|
|
} else {
|
|
vals[16] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressLocality.IsValue() {
|
|
vals[17] = psql.Arg(s.AddressLocality.MustGet())
|
|
} else {
|
|
vals[17] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressPostalCode.IsValue() {
|
|
vals[18] = psql.Arg(s.AddressPostalCode.MustGet())
|
|
} else {
|
|
vals[18] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressRegion.IsValue() {
|
|
vals[19] = psql.Arg(s.AddressRegion.MustGet())
|
|
} else {
|
|
vals[19] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressStreet.IsValue() {
|
|
vals[20] = psql.Arg(s.AddressStreet.MustGet())
|
|
} else {
|
|
vals[20] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsLocationBackyard.IsValue() {
|
|
vals[21] = psql.Arg(s.IsLocationBackyard.MustGet())
|
|
} else {
|
|
vals[21] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsLocationFrontyard.IsValue() {
|
|
vals[22] = psql.Arg(s.IsLocationFrontyard.MustGet())
|
|
} else {
|
|
vals[22] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsLocationGarden.IsValue() {
|
|
vals[23] = psql.Arg(s.IsLocationGarden.MustGet())
|
|
} else {
|
|
vals[23] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsLocationOther.IsValue() {
|
|
vals[24] = psql.Arg(s.IsLocationOther.MustGet())
|
|
} else {
|
|
vals[24] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsLocationPool.IsValue() {
|
|
vals[25] = psql.Arg(s.IsLocationPool.MustGet())
|
|
} else {
|
|
vals[25] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.MapZoom.IsValue() {
|
|
vals[26] = psql.Arg(s.MapZoom.MustGet())
|
|
} else {
|
|
vals[26] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.TodEarly.IsValue() {
|
|
vals[27] = psql.Arg(s.TodEarly.MustGet())
|
|
} else {
|
|
vals[27] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.TodDay.IsValue() {
|
|
vals[28] = psql.Arg(s.TodDay.MustGet())
|
|
} else {
|
|
vals[28] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.TodEvening.IsValue() {
|
|
vals[29] = psql.Arg(s.TodEvening.MustGet())
|
|
} else {
|
|
vals[29] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.TodNight.IsValue() {
|
|
vals[30] = psql.Arg(s.TodNight.MustGet())
|
|
} else {
|
|
vals[30] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
vals[31] = psql.Arg(s.LatlngAccuracyType.MustGet())
|
|
} else {
|
|
vals[31] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
vals[32] = psql.Arg(s.LatlngAccuracyValue.MustGet())
|
|
} else {
|
|
vals[32] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
vals[33] = psql.Arg(s.ReporterContactConsent.MustGetNull())
|
|
} else {
|
|
vals[33] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Location.IsUnset() {
|
|
vals[34] = psql.Arg(s.Location.MustGetNull())
|
|
} else {
|
|
vals[34] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.AddressNumber.IsValue() {
|
|
vals[35] = psql.Arg(s.AddressNumber.MustGet())
|
|
} else {
|
|
vals[35] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.AddressID.IsUnset() {
|
|
vals[36] = psql.Arg(s.AddressID.MustGetNull())
|
|
} else {
|
|
vals[36] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Reviewed.IsUnset() {
|
|
vals[37] = psql.Arg(s.Reviewed.MustGetNull())
|
|
} else {
|
|
vals[37] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ReviewerID.IsUnset() {
|
|
vals[38] = psql.Arg(s.ReviewerID.MustGetNull())
|
|
} else {
|
|
vals[38] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
|
}))
|
|
}
|
|
|
|
func (s PublicreportNuisanceOldSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
return um.Set(s.Expressions()...)
|
|
}
|
|
|
|
func (s PublicreportNuisanceOldSetter) Expressions(prefix ...string) []bob.Expression {
|
|
exprs := make([]bob.Expression, 0, 39)
|
|
|
|
if s.ID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "id")...),
|
|
psql.Arg(s.ID),
|
|
}})
|
|
}
|
|
|
|
if s.AdditionalInfo.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "additional_info")...),
|
|
psql.Arg(s.AdditionalInfo),
|
|
}})
|
|
}
|
|
|
|
if s.Created.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "created")...),
|
|
psql.Arg(s.Created),
|
|
}})
|
|
}
|
|
|
|
if s.Duration.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "duration")...),
|
|
psql.Arg(s.Duration),
|
|
}})
|
|
}
|
|
|
|
if s.SourceContainer.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "source_container")...),
|
|
psql.Arg(s.SourceContainer),
|
|
}})
|
|
}
|
|
|
|
if s.SourceDescription.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "source_description")...),
|
|
psql.Arg(s.SourceDescription),
|
|
}})
|
|
}
|
|
|
|
if s.SourceStagnant.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "source_stagnant")...),
|
|
psql.Arg(s.SourceStagnant),
|
|
}})
|
|
}
|
|
|
|
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.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_email")...),
|
|
psql.Arg(s.ReporterEmail),
|
|
}})
|
|
}
|
|
|
|
if !s.ReporterName.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_name")...),
|
|
psql.Arg(s.ReporterName),
|
|
}})
|
|
}
|
|
|
|
if !s.ReporterPhone.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_phone")...),
|
|
psql.Arg(s.ReporterPhone),
|
|
}})
|
|
}
|
|
|
|
if s.AddressRaw.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_raw")...),
|
|
psql.Arg(s.AddressRaw),
|
|
}})
|
|
}
|
|
|
|
if s.Status.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "status")...),
|
|
psql.Arg(s.Status),
|
|
}})
|
|
}
|
|
|
|
if s.OrganizationID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "organization_id")...),
|
|
psql.Arg(s.OrganizationID),
|
|
}})
|
|
}
|
|
|
|
if s.SourceGutter.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "source_gutter")...),
|
|
psql.Arg(s.SourceGutter),
|
|
}})
|
|
}
|
|
|
|
if !s.H3cell.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "h3cell")...),
|
|
psql.Arg(s.H3cell),
|
|
}})
|
|
}
|
|
|
|
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.AddressLocality.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_locality")...),
|
|
psql.Arg(s.AddressLocality),
|
|
}})
|
|
}
|
|
|
|
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.AddressRegion.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_region")...),
|
|
psql.Arg(s.AddressRegion),
|
|
}})
|
|
}
|
|
|
|
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.IsLocationBackyard.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_location_backyard")...),
|
|
psql.Arg(s.IsLocationBackyard),
|
|
}})
|
|
}
|
|
|
|
if s.IsLocationFrontyard.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_location_frontyard")...),
|
|
psql.Arg(s.IsLocationFrontyard),
|
|
}})
|
|
}
|
|
|
|
if s.IsLocationGarden.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_location_garden")...),
|
|
psql.Arg(s.IsLocationGarden),
|
|
}})
|
|
}
|
|
|
|
if s.IsLocationOther.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_location_other")...),
|
|
psql.Arg(s.IsLocationOther),
|
|
}})
|
|
}
|
|
|
|
if s.IsLocationPool.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_location_pool")...),
|
|
psql.Arg(s.IsLocationPool),
|
|
}})
|
|
}
|
|
|
|
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.TodEarly.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "tod_early")...),
|
|
psql.Arg(s.TodEarly),
|
|
}})
|
|
}
|
|
|
|
if s.TodDay.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "tod_day")...),
|
|
psql.Arg(s.TodDay),
|
|
}})
|
|
}
|
|
|
|
if s.TodEvening.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "tod_evening")...),
|
|
psql.Arg(s.TodEvening),
|
|
}})
|
|
}
|
|
|
|
if s.TodNight.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "tod_night")...),
|
|
psql.Arg(s.TodNight),
|
|
}})
|
|
}
|
|
|
|
if s.LatlngAccuracyType.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "latlng_accuracy_type")...),
|
|
psql.Arg(s.LatlngAccuracyType),
|
|
}})
|
|
}
|
|
|
|
if s.LatlngAccuracyValue.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "latlng_accuracy_value")...),
|
|
psql.Arg(s.LatlngAccuracyValue),
|
|
}})
|
|
}
|
|
|
|
if !s.ReporterContactConsent.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reporter_contact_consent")...),
|
|
psql.Arg(s.ReporterContactConsent),
|
|
}})
|
|
}
|
|
|
|
if !s.Location.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "location")...),
|
|
psql.Arg(s.Location),
|
|
}})
|
|
}
|
|
|
|
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.AddressID.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "address_id")...),
|
|
psql.Arg(s.AddressID),
|
|
}})
|
|
}
|
|
|
|
if !s.Reviewed.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reviewed")...),
|
|
psql.Arg(s.Reviewed),
|
|
}})
|
|
}
|
|
|
|
if !s.ReviewerID.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "reviewer_id")...),
|
|
psql.Arg(s.ReviewerID),
|
|
}})
|
|
}
|
|
|
|
return exprs
|
|
}
|
|
|
|
// FindPublicreportNuisanceOld retrieves a single record by primary key
|
|
// If cols is empty Find will return all columns.
|
|
func FindPublicreportNuisanceOld(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*PublicreportNuisanceOld, error) {
|
|
if len(cols) == 0 {
|
|
return PublicreportNuisanceOlds.Query(
|
|
sm.Where(PublicreportNuisanceOlds.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
return PublicreportNuisanceOlds.Query(
|
|
sm.Where(PublicreportNuisanceOlds.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
sm.Columns(PublicreportNuisanceOlds.Columns.Only(cols...)),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
// PublicreportNuisanceOldExists checks the presence of a single record by primary key
|
|
func PublicreportNuisanceOldExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
|
|
return PublicreportNuisanceOlds.Query(
|
|
sm.Where(PublicreportNuisanceOlds.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
).Exists(ctx, exec)
|
|
}
|
|
|
|
// AfterQueryHook is called after PublicreportNuisanceOld is retrieved from the database
|
|
func (o *PublicreportNuisanceOld) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = PublicreportNuisanceOlds.AfterSelectHooks.RunHooks(ctx, exec, PublicreportNuisanceOldSlice{o})
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = PublicreportNuisanceOlds.AfterInsertHooks.RunHooks(ctx, exec, PublicreportNuisanceOldSlice{o})
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = PublicreportNuisanceOlds.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportNuisanceOldSlice{o})
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = PublicreportNuisanceOlds.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportNuisanceOldSlice{o})
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// primaryKeyVals returns the primary key values of the PublicreportNuisanceOld
|
|
func (o *PublicreportNuisanceOld) primaryKeyVals() bob.Expression {
|
|
return psql.Arg(o.ID)
|
|
}
|
|
|
|
func (o *PublicreportNuisanceOld) pkEQ() dialect.Expression {
|
|
return psql.Quote("publicreport.nuisance_old", "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 PublicreportNuisanceOld
|
|
func (o *PublicreportNuisanceOld) Update(ctx context.Context, exec bob.Executor, s *PublicreportNuisanceOldSetter) error {
|
|
v, err := PublicreportNuisanceOlds.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 PublicreportNuisanceOld record with an executor
|
|
func (o *PublicreportNuisanceOld) Delete(ctx context.Context, exec bob.Executor) error {
|
|
_, err := PublicreportNuisanceOlds.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
// Reload refreshes the PublicreportNuisanceOld using the executor
|
|
func (o *PublicreportNuisanceOld) Reload(ctx context.Context, exec bob.Executor) error {
|
|
o2, err := PublicreportNuisanceOlds.Query(
|
|
sm.Where(PublicreportNuisanceOlds.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 PublicreportNuisanceOldSlice is retrieved from the database
|
|
func (o PublicreportNuisanceOldSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = PublicreportNuisanceOlds.AfterSelectHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = PublicreportNuisanceOlds.AfterInsertHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = PublicreportNuisanceOlds.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = PublicreportNuisanceOlds.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func (o PublicreportNuisanceOldSlice) pkIN() dialect.Expression {
|
|
if len(o) == 0 {
|
|
return psql.Raw("NULL")
|
|
}
|
|
|
|
return psql.Quote("publicreport.nuisance_old", "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 PublicreportNuisanceOldSlice) copyMatchingRows(from ...*PublicreportNuisanceOld) {
|
|
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 PublicreportNuisanceOldSlice) 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 PublicreportNuisanceOlds.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 *PublicreportNuisanceOld:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*PublicreportNuisanceOld:
|
|
o.copyMatchingRows(retrieved...)
|
|
case PublicreportNuisanceOldSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a PublicreportNuisanceOld or a slice of PublicreportNuisanceOld
|
|
// then run the AfterUpdateHooks on the slice
|
|
_, err = PublicreportNuisanceOlds.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
|
func (o PublicreportNuisanceOldSlice) 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 PublicreportNuisanceOlds.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 *PublicreportNuisanceOld:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*PublicreportNuisanceOld:
|
|
o.copyMatchingRows(retrieved...)
|
|
case PublicreportNuisanceOldSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a PublicreportNuisanceOld or a slice of PublicreportNuisanceOld
|
|
// then run the AfterDeleteHooks on the slice
|
|
_, err = PublicreportNuisanceOlds.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
func (o PublicreportNuisanceOldSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportNuisanceOldSetter) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := PublicreportNuisanceOlds.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o PublicreportNuisanceOldSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := PublicreportNuisanceOlds.Delete(o.DeleteMod()).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o PublicreportNuisanceOldSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
o2, err := PublicreportNuisanceOlds.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.copyMatchingRows(o2...)
|
|
|
|
return nil
|
|
}
|
|
|
|
// NuisanceNotifyEmailNuisanceOlds starts a query for related objects on publicreport.notify_email_nuisance_old
|
|
func (o *PublicreportNuisanceOld) NuisanceNotifyEmailNuisanceOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyEmailNuisanceOldsQuery {
|
|
return PublicreportNotifyEmailNuisanceOlds.Query(append(mods,
|
|
sm.Where(PublicreportNotifyEmailNuisanceOlds.Columns.NuisanceID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportNuisanceOldSlice) NuisanceNotifyEmailNuisanceOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyEmailNuisanceOldsQuery {
|
|
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[]")),
|
|
))
|
|
|
|
return PublicreportNotifyEmailNuisanceOlds.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportNotifyEmailNuisanceOlds.Columns.NuisanceID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// NuisanceNotifyPhoneNuisanceOlds starts a query for related objects on publicreport.notify_phone_nuisance_old
|
|
func (o *PublicreportNuisanceOld) NuisanceNotifyPhoneNuisanceOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyPhoneNuisanceOldsQuery {
|
|
return PublicreportNotifyPhoneNuisanceOlds.Query(append(mods,
|
|
sm.Where(PublicreportNotifyPhoneNuisanceOlds.Columns.NuisanceID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportNuisanceOldSlice) NuisanceNotifyPhoneNuisanceOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNotifyPhoneNuisanceOldsQuery {
|
|
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[]")),
|
|
))
|
|
|
|
return PublicreportNotifyPhoneNuisanceOlds.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportNotifyPhoneNuisanceOlds.Columns.NuisanceID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Images starts a query for related objects on publicreport.image
|
|
func (o *PublicreportNuisanceOld) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
|
return PublicreportImages.Query(append(mods,
|
|
sm.InnerJoin(PublicreportNuisanceImageOlds.NameAs()).On(
|
|
PublicreportImages.Columns.ID.EQ(PublicreportNuisanceImageOlds.Columns.ImageID)),
|
|
sm.Where(PublicreportNuisanceImageOlds.Columns.NuisanceID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportNuisanceOldSlice) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
|
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[]")),
|
|
))
|
|
|
|
return PublicreportImages.Query(append(mods,
|
|
sm.InnerJoin(PublicreportNuisanceImageOlds.NameAs()).On(
|
|
PublicreportImages.Columns.ID.EQ(PublicreportNuisanceImageOlds.Columns.ImageID),
|
|
),
|
|
sm.Where(psql.Group(PublicreportNuisanceImageOlds.Columns.NuisanceID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Address starts a query for related objects on address
|
|
func (o *PublicreportNuisanceOld) Address(mods ...bob.Mod[*dialect.SelectQuery]) AddressesQuery {
|
|
return Addresses.Query(append(mods,
|
|
sm.Where(Addresses.Columns.ID.EQ(psql.Arg(o.AddressID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportNuisanceOldSlice) Address(mods ...bob.Mod[*dialect.SelectQuery]) AddressesQuery {
|
|
pkAddressID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkAddressID = append(pkAddressID, o.AddressID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkAddressID), "integer[]")),
|
|
))
|
|
|
|
return Addresses.Query(append(mods,
|
|
sm.Where(psql.Group(Addresses.Columns.ID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Organization starts a query for related objects on organization
|
|
func (o *PublicreportNuisanceOld) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
return Organizations.Query(append(mods,
|
|
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportNuisanceOldSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
pkOrganizationID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkOrganizationID = append(pkOrganizationID, o.OrganizationID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkOrganizationID), "integer[]")),
|
|
))
|
|
|
|
return Organizations.Query(append(mods,
|
|
sm.Where(psql.Group(Organizations.Columns.ID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReviewerUser starts a query for related objects on user_
|
|
func (o *PublicreportNuisanceOld) ReviewerUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
|
|
return Users.Query(append(mods,
|
|
sm.Where(Users.Columns.ID.EQ(psql.Arg(o.ReviewerID))),
|
|
)...)
|
|
}
|
|
|
|
func (os PublicreportNuisanceOldSlice) ReviewerUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
|
|
pkReviewerID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkReviewerID = append(pkReviewerID, o.ReviewerID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkReviewerID), "integer[]")),
|
|
))
|
|
|
|
return Users.Query(append(mods,
|
|
sm.Where(psql.Group(Users.Columns.ID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
func insertPublicreportNuisanceOldNuisanceNotifyEmailNuisanceOlds0(ctx context.Context, exec bob.Executor, publicreportNotifyEmailNuisanceOlds1 []*PublicreportNotifyEmailNuisanceOldSetter, publicreportNuisanceOld0 *PublicreportNuisanceOld) (PublicreportNotifyEmailNuisanceOldSlice, error) {
|
|
for i := range publicreportNotifyEmailNuisanceOlds1 {
|
|
publicreportNotifyEmailNuisanceOlds1[i].NuisanceID = omit.From(publicreportNuisanceOld0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportNotifyEmailNuisanceOlds.Insert(bob.ToMods(publicreportNotifyEmailNuisanceOlds1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportNuisanceOldNuisanceNotifyEmailNuisanceOlds0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportNuisanceOldNuisanceNotifyEmailNuisanceOlds0(ctx context.Context, exec bob.Executor, count int, publicreportNotifyEmailNuisanceOlds1 PublicreportNotifyEmailNuisanceOldSlice, publicreportNuisanceOld0 *PublicreportNuisanceOld) (PublicreportNotifyEmailNuisanceOldSlice, error) {
|
|
setter := &PublicreportNotifyEmailNuisanceOldSetter{
|
|
NuisanceID: omit.From(publicreportNuisanceOld0.ID),
|
|
}
|
|
|
|
err := publicreportNotifyEmailNuisanceOlds1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportNuisanceOldNuisanceNotifyEmailNuisanceOlds0: %w", err)
|
|
}
|
|
|
|
return publicreportNotifyEmailNuisanceOlds1, nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) InsertNuisanceNotifyEmailNuisanceOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyEmailNuisanceOldSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportNotifyEmailNuisanceOlds1, err := insertPublicreportNuisanceOldNuisanceNotifyEmailNuisanceOlds0(ctx, exec, related, publicreportNuisanceOld0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.NuisanceNotifyEmailNuisanceOlds = append(publicreportNuisanceOld0.R.NuisanceNotifyEmailNuisanceOlds, publicreportNotifyEmailNuisanceOlds1...)
|
|
|
|
for _, rel := range publicreportNotifyEmailNuisanceOlds1 {
|
|
rel.R.NuisanceNuisanceOld = publicreportNuisanceOld0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) AttachNuisanceNotifyEmailNuisanceOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyEmailNuisanceOld) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportNotifyEmailNuisanceOlds1 := PublicreportNotifyEmailNuisanceOldSlice(related)
|
|
|
|
_, err = attachPublicreportNuisanceOldNuisanceNotifyEmailNuisanceOlds0(ctx, exec, len(related), publicreportNotifyEmailNuisanceOlds1, publicreportNuisanceOld0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.NuisanceNotifyEmailNuisanceOlds = append(publicreportNuisanceOld0.R.NuisanceNotifyEmailNuisanceOlds, publicreportNotifyEmailNuisanceOlds1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.NuisanceNuisanceOld = publicreportNuisanceOld0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertPublicreportNuisanceOldNuisanceNotifyPhoneNuisanceOlds0(ctx context.Context, exec bob.Executor, publicreportNotifyPhoneNuisanceOlds1 []*PublicreportNotifyPhoneNuisanceOldSetter, publicreportNuisanceOld0 *PublicreportNuisanceOld) (PublicreportNotifyPhoneNuisanceOldSlice, error) {
|
|
for i := range publicreportNotifyPhoneNuisanceOlds1 {
|
|
publicreportNotifyPhoneNuisanceOlds1[i].NuisanceID = omit.From(publicreportNuisanceOld0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportNotifyPhoneNuisanceOlds.Insert(bob.ToMods(publicreportNotifyPhoneNuisanceOlds1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertPublicreportNuisanceOldNuisanceNotifyPhoneNuisanceOlds0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachPublicreportNuisanceOldNuisanceNotifyPhoneNuisanceOlds0(ctx context.Context, exec bob.Executor, count int, publicreportNotifyPhoneNuisanceOlds1 PublicreportNotifyPhoneNuisanceOldSlice, publicreportNuisanceOld0 *PublicreportNuisanceOld) (PublicreportNotifyPhoneNuisanceOldSlice, error) {
|
|
setter := &PublicreportNotifyPhoneNuisanceOldSetter{
|
|
NuisanceID: omit.From(publicreportNuisanceOld0.ID),
|
|
}
|
|
|
|
err := publicreportNotifyPhoneNuisanceOlds1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportNuisanceOldNuisanceNotifyPhoneNuisanceOlds0: %w", err)
|
|
}
|
|
|
|
return publicreportNotifyPhoneNuisanceOlds1, nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) InsertNuisanceNotifyPhoneNuisanceOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyPhoneNuisanceOldSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportNotifyPhoneNuisanceOlds1, err := insertPublicreportNuisanceOldNuisanceNotifyPhoneNuisanceOlds0(ctx, exec, related, publicreportNuisanceOld0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.NuisanceNotifyPhoneNuisanceOlds = append(publicreportNuisanceOld0.R.NuisanceNotifyPhoneNuisanceOlds, publicreportNotifyPhoneNuisanceOlds1...)
|
|
|
|
for _, rel := range publicreportNotifyPhoneNuisanceOlds1 {
|
|
rel.R.NuisanceNuisanceOld = publicreportNuisanceOld0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) AttachNuisanceNotifyPhoneNuisanceOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportNotifyPhoneNuisanceOld) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportNotifyPhoneNuisanceOlds1 := PublicreportNotifyPhoneNuisanceOldSlice(related)
|
|
|
|
_, err = attachPublicreportNuisanceOldNuisanceNotifyPhoneNuisanceOlds0(ctx, exec, len(related), publicreportNotifyPhoneNuisanceOlds1, publicreportNuisanceOld0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.NuisanceNotifyPhoneNuisanceOlds = append(publicreportNuisanceOld0.R.NuisanceNotifyPhoneNuisanceOlds, publicreportNotifyPhoneNuisanceOlds1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.NuisanceNuisanceOld = publicreportNuisanceOld0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportNuisanceOldImages0(ctx context.Context, exec bob.Executor, count int, publicreportNuisanceOld0 *PublicreportNuisanceOld, publicreportImages2 PublicreportImageSlice) (PublicreportNuisanceImageOldSlice, error) {
|
|
setters := make([]*PublicreportNuisanceImageOldSetter, count)
|
|
for i := range count {
|
|
setters[i] = &PublicreportNuisanceImageOldSetter{
|
|
NuisanceID: omit.From(publicreportNuisanceOld0.ID),
|
|
ImageID: omit.From(publicreportImages2[i].ID),
|
|
}
|
|
}
|
|
|
|
publicreportNuisanceImageOlds1, err := PublicreportNuisanceImageOlds.Insert(bob.ToMods(setters...)).All(ctx, exec)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportNuisanceOldImages0: %w", err)
|
|
}
|
|
|
|
return publicreportNuisanceImageOlds1, nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) InsertImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImageSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
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 = attachPublicreportNuisanceOldImages0(ctx, exec, len(related), publicreportNuisanceOld0, publicreportImages2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.Images = append(publicreportNuisanceOld0.R.Images, publicreportImages2...)
|
|
|
|
for _, rel := range publicreportImages2 {
|
|
rel.R.NuisanceOlds = append(rel.R.NuisanceOlds, publicreportNuisanceOld0)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) AttachImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImage) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportImages2 := PublicreportImageSlice(related)
|
|
|
|
_, err = attachPublicreportNuisanceOldImages0(ctx, exec, len(related), publicreportNuisanceOld0, publicreportImages2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.Images = append(publicreportNuisanceOld0.R.Images, publicreportImages2...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.NuisanceOlds = append(rel.R.NuisanceOlds, publicreportNuisanceOld0)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportNuisanceOldAddress0(ctx context.Context, exec bob.Executor, count int, publicreportNuisanceOld0 *PublicreportNuisanceOld, address1 *Address) (*PublicreportNuisanceOld, error) {
|
|
setter := &PublicreportNuisanceOldSetter{
|
|
AddressID: omitnull.From(address1.ID),
|
|
}
|
|
|
|
err := publicreportNuisanceOld0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportNuisanceOldAddress0: %w", err)
|
|
}
|
|
|
|
return publicreportNuisanceOld0, nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) InsertAddress(ctx context.Context, exec bob.Executor, related *AddressSetter) error {
|
|
var err error
|
|
|
|
address1, err := Addresses.Insert(related).One(ctx, exec)
|
|
if err != nil {
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
}
|
|
|
|
_, err = attachPublicreportNuisanceOldAddress0(ctx, exec, 1, publicreportNuisanceOld0, address1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.Address = address1
|
|
|
|
address1.R.NuisanceOlds = append(address1.R.NuisanceOlds, publicreportNuisanceOld0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) AttachAddress(ctx context.Context, exec bob.Executor, address1 *Address) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportNuisanceOldAddress0(ctx, exec, 1, publicreportNuisanceOld0, address1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.Address = address1
|
|
|
|
address1.R.NuisanceOlds = append(address1.R.NuisanceOlds, publicreportNuisanceOld0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportNuisanceOldOrganization0(ctx context.Context, exec bob.Executor, count int, publicreportNuisanceOld0 *PublicreportNuisanceOld, organization1 *Organization) (*PublicreportNuisanceOld, error) {
|
|
setter := &PublicreportNuisanceOldSetter{
|
|
OrganizationID: omit.From(organization1.ID),
|
|
}
|
|
|
|
err := publicreportNuisanceOld0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportNuisanceOldOrganization0: %w", err)
|
|
}
|
|
|
|
return publicreportNuisanceOld0, nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) 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 = attachPublicreportNuisanceOldOrganization0(ctx, exec, 1, publicreportNuisanceOld0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.Organization = organization1
|
|
|
|
organization1.R.NuisanceOlds = append(organization1.R.NuisanceOlds, publicreportNuisanceOld0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportNuisanceOldOrganization0(ctx, exec, 1, publicreportNuisanceOld0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.Organization = organization1
|
|
|
|
organization1.R.NuisanceOlds = append(organization1.R.NuisanceOlds, publicreportNuisanceOld0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachPublicreportNuisanceOldReviewerUser0(ctx context.Context, exec bob.Executor, count int, publicreportNuisanceOld0 *PublicreportNuisanceOld, user1 *User) (*PublicreportNuisanceOld, error) {
|
|
setter := &PublicreportNuisanceOldSetter{
|
|
ReviewerID: omitnull.From(user1.ID),
|
|
}
|
|
|
|
err := publicreportNuisanceOld0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachPublicreportNuisanceOldReviewerUser0: %w", err)
|
|
}
|
|
|
|
return publicreportNuisanceOld0, nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) InsertReviewerUser(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 = attachPublicreportNuisanceOldReviewerUser0(ctx, exec, 1, publicreportNuisanceOld0, user1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.ReviewerUser = user1
|
|
|
|
user1.R.ReviewerNuisanceOlds = append(user1.R.ReviewerNuisanceOlds, publicreportNuisanceOld0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (publicreportNuisanceOld0 *PublicreportNuisanceOld) AttachReviewerUser(ctx context.Context, exec bob.Executor, user1 *User) error {
|
|
var err error
|
|
|
|
_, err = attachPublicreportNuisanceOldReviewerUser0(ctx, exec, 1, publicreportNuisanceOld0, user1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicreportNuisanceOld0.R.ReviewerUser = user1
|
|
|
|
user1.R.ReviewerNuisanceOlds = append(user1.R.ReviewerNuisanceOlds, publicreportNuisanceOld0)
|
|
|
|
return nil
|
|
}
|
|
|
|
type publicreportNuisanceOldWhere[Q psql.Filterable] struct {
|
|
ID psql.WhereMod[Q, int32]
|
|
AdditionalInfo psql.WhereMod[Q, string]
|
|
Created psql.WhereMod[Q, time.Time]
|
|
Duration psql.WhereMod[Q, enums.PublicreportNuisancedurationtype]
|
|
SourceContainer psql.WhereMod[Q, bool]
|
|
SourceDescription psql.WhereMod[Q, string]
|
|
SourceStagnant psql.WhereMod[Q, bool]
|
|
PublicID psql.WhereMod[Q, string]
|
|
ReporterEmail psql.WhereNullMod[Q, string]
|
|
ReporterName psql.WhereNullMod[Q, string]
|
|
ReporterPhone psql.WhereNullMod[Q, string]
|
|
AddressRaw psql.WhereMod[Q, string]
|
|
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
|
OrganizationID psql.WhereMod[Q, int32]
|
|
SourceGutter psql.WhereMod[Q, bool]
|
|
H3cell psql.WhereNullMod[Q, string]
|
|
AddressCountry psql.WhereMod[Q, string]
|
|
AddressLocality psql.WhereMod[Q, string]
|
|
AddressPostalCode psql.WhereMod[Q, string]
|
|
AddressRegion psql.WhereMod[Q, string]
|
|
AddressStreet psql.WhereMod[Q, string]
|
|
IsLocationBackyard psql.WhereMod[Q, bool]
|
|
IsLocationFrontyard psql.WhereMod[Q, bool]
|
|
IsLocationGarden psql.WhereMod[Q, bool]
|
|
IsLocationOther psql.WhereMod[Q, bool]
|
|
IsLocationPool psql.WhereMod[Q, bool]
|
|
MapZoom psql.WhereMod[Q, float32]
|
|
TodEarly psql.WhereMod[Q, bool]
|
|
TodDay psql.WhereMod[Q, bool]
|
|
TodEvening psql.WhereMod[Q, bool]
|
|
TodNight psql.WhereMod[Q, bool]
|
|
LatlngAccuracyType psql.WhereMod[Q, enums.PublicreportAccuracytype]
|
|
LatlngAccuracyValue psql.WhereMod[Q, float32]
|
|
ReporterContactConsent psql.WhereNullMod[Q, bool]
|
|
Location psql.WhereNullMod[Q, string]
|
|
AddressNumber psql.WhereMod[Q, string]
|
|
AddressID psql.WhereNullMod[Q, int32]
|
|
Reviewed psql.WhereNullMod[Q, time.Time]
|
|
ReviewerID psql.WhereNullMod[Q, int32]
|
|
}
|
|
|
|
func (publicreportNuisanceOldWhere[Q]) AliasedAs(alias string) publicreportNuisanceOldWhere[Q] {
|
|
return buildPublicreportNuisanceOldWhere[Q](buildPublicreportNuisanceOldColumns(alias))
|
|
}
|
|
|
|
func buildPublicreportNuisanceOldWhere[Q psql.Filterable](cols publicreportNuisanceOldColumns) publicreportNuisanceOldWhere[Q] {
|
|
return publicreportNuisanceOldWhere[Q]{
|
|
ID: psql.Where[Q, int32](cols.ID),
|
|
AdditionalInfo: psql.Where[Q, string](cols.AdditionalInfo),
|
|
Created: psql.Where[Q, time.Time](cols.Created),
|
|
Duration: psql.Where[Q, enums.PublicreportNuisancedurationtype](cols.Duration),
|
|
SourceContainer: psql.Where[Q, bool](cols.SourceContainer),
|
|
SourceDescription: psql.Where[Q, string](cols.SourceDescription),
|
|
SourceStagnant: psql.Where[Q, bool](cols.SourceStagnant),
|
|
PublicID: psql.Where[Q, string](cols.PublicID),
|
|
ReporterEmail: psql.WhereNull[Q, string](cols.ReporterEmail),
|
|
ReporterName: psql.WhereNull[Q, string](cols.ReporterName),
|
|
ReporterPhone: psql.WhereNull[Q, string](cols.ReporterPhone),
|
|
AddressRaw: psql.Where[Q, string](cols.AddressRaw),
|
|
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
|
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
|
|
SourceGutter: psql.Where[Q, bool](cols.SourceGutter),
|
|
H3cell: psql.WhereNull[Q, string](cols.H3cell),
|
|
AddressCountry: psql.Where[Q, string](cols.AddressCountry),
|
|
AddressLocality: psql.Where[Q, string](cols.AddressLocality),
|
|
AddressPostalCode: psql.Where[Q, string](cols.AddressPostalCode),
|
|
AddressRegion: psql.Where[Q, string](cols.AddressRegion),
|
|
AddressStreet: psql.Where[Q, string](cols.AddressStreet),
|
|
IsLocationBackyard: psql.Where[Q, bool](cols.IsLocationBackyard),
|
|
IsLocationFrontyard: psql.Where[Q, bool](cols.IsLocationFrontyard),
|
|
IsLocationGarden: psql.Where[Q, bool](cols.IsLocationGarden),
|
|
IsLocationOther: psql.Where[Q, bool](cols.IsLocationOther),
|
|
IsLocationPool: psql.Where[Q, bool](cols.IsLocationPool),
|
|
MapZoom: psql.Where[Q, float32](cols.MapZoom),
|
|
TodEarly: psql.Where[Q, bool](cols.TodEarly),
|
|
TodDay: psql.Where[Q, bool](cols.TodDay),
|
|
TodEvening: psql.Where[Q, bool](cols.TodEvening),
|
|
TodNight: psql.Where[Q, bool](cols.TodNight),
|
|
LatlngAccuracyType: psql.Where[Q, enums.PublicreportAccuracytype](cols.LatlngAccuracyType),
|
|
LatlngAccuracyValue: psql.Where[Q, float32](cols.LatlngAccuracyValue),
|
|
ReporterContactConsent: psql.WhereNull[Q, bool](cols.ReporterContactConsent),
|
|
Location: psql.WhereNull[Q, string](cols.Location),
|
|
AddressNumber: psql.Where[Q, string](cols.AddressNumber),
|
|
AddressID: psql.WhereNull[Q, int32](cols.AddressID),
|
|
Reviewed: psql.WhereNull[Q, time.Time](cols.Reviewed),
|
|
ReviewerID: psql.WhereNull[Q, int32](cols.ReviewerID),
|
|
}
|
|
}
|
|
|
|
func (o *PublicreportNuisanceOld) Preload(name string, retrieved any) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
switch name {
|
|
case "NuisanceNotifyEmailNuisanceOlds":
|
|
rels, ok := retrieved.(PublicreportNotifyEmailNuisanceOldSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportNuisanceOld cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.NuisanceNotifyEmailNuisanceOlds = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.NuisanceNuisanceOld = o
|
|
}
|
|
}
|
|
return nil
|
|
case "NuisanceNotifyPhoneNuisanceOlds":
|
|
rels, ok := retrieved.(PublicreportNotifyPhoneNuisanceOldSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportNuisanceOld cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.NuisanceNotifyPhoneNuisanceOlds = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.NuisanceNuisanceOld = o
|
|
}
|
|
}
|
|
return nil
|
|
case "Images":
|
|
rels, ok := retrieved.(PublicreportImageSlice)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportNuisanceOld cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Images = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.NuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
}
|
|
}
|
|
return nil
|
|
case "Address":
|
|
rel, ok := retrieved.(*Address)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportNuisanceOld cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Address = rel
|
|
|
|
if rel != nil {
|
|
rel.R.NuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
}
|
|
return nil
|
|
case "Organization":
|
|
rel, ok := retrieved.(*Organization)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportNuisanceOld cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Organization = rel
|
|
|
|
if rel != nil {
|
|
rel.R.NuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
}
|
|
return nil
|
|
case "ReviewerUser":
|
|
rel, ok := retrieved.(*User)
|
|
if !ok {
|
|
return fmt.Errorf("publicreportNuisanceOld cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReviewerUser = rel
|
|
|
|
if rel != nil {
|
|
rel.R.ReviewerNuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
}
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("publicreportNuisanceOld has no relationship %q", name)
|
|
}
|
|
}
|
|
|
|
type publicreportNuisanceOldPreloader struct {
|
|
Address func(...psql.PreloadOption) psql.Preloader
|
|
Organization func(...psql.PreloadOption) psql.Preloader
|
|
ReviewerUser func(...psql.PreloadOption) psql.Preloader
|
|
}
|
|
|
|
func buildPublicreportNuisanceOldPreloader() publicreportNuisanceOldPreloader {
|
|
return publicreportNuisanceOldPreloader{
|
|
Address: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*Address, AddressSlice](psql.PreloadRel{
|
|
Name: "Address",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportNuisanceOlds,
|
|
To: Addresses,
|
|
FromColumns: []string{"address_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Addresses.Columns.Names(), opts...)
|
|
},
|
|
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
|
Name: "Organization",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportNuisanceOlds,
|
|
To: Organizations,
|
|
FromColumns: []string{"organization_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Organizations.Columns.Names(), opts...)
|
|
},
|
|
ReviewerUser: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*User, UserSlice](psql.PreloadRel{
|
|
Name: "ReviewerUser",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: PublicreportNuisanceOlds,
|
|
To: Users,
|
|
FromColumns: []string{"reviewer_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Users.Columns.Names(), opts...)
|
|
},
|
|
}
|
|
}
|
|
|
|
type publicreportNuisanceOldThenLoader[Q orm.Loadable] struct {
|
|
NuisanceNotifyEmailNuisanceOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
NuisanceNotifyPhoneNuisanceOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Address func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReviewerUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
}
|
|
|
|
func buildPublicreportNuisanceOldThenLoader[Q orm.Loadable]() publicreportNuisanceOldThenLoader[Q] {
|
|
type NuisanceNotifyEmailNuisanceOldsLoadInterface interface {
|
|
LoadNuisanceNotifyEmailNuisanceOlds(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type NuisanceNotifyPhoneNuisanceOldsLoadInterface interface {
|
|
LoadNuisanceNotifyPhoneNuisanceOlds(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ImagesLoadInterface interface {
|
|
LoadImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type AddressLoadInterface interface {
|
|
LoadAddress(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type OrganizationLoadInterface interface {
|
|
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReviewerUserLoadInterface interface {
|
|
LoadReviewerUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
|
|
return publicreportNuisanceOldThenLoader[Q]{
|
|
NuisanceNotifyEmailNuisanceOlds: thenLoadBuilder[Q](
|
|
"NuisanceNotifyEmailNuisanceOlds",
|
|
func(ctx context.Context, exec bob.Executor, retrieved NuisanceNotifyEmailNuisanceOldsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadNuisanceNotifyEmailNuisanceOlds(ctx, exec, mods...)
|
|
},
|
|
),
|
|
NuisanceNotifyPhoneNuisanceOlds: thenLoadBuilder[Q](
|
|
"NuisanceNotifyPhoneNuisanceOlds",
|
|
func(ctx context.Context, exec bob.Executor, retrieved NuisanceNotifyPhoneNuisanceOldsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadNuisanceNotifyPhoneNuisanceOlds(ctx, exec, mods...)
|
|
},
|
|
),
|
|
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...)
|
|
},
|
|
),
|
|
Address: thenLoadBuilder[Q](
|
|
"Address",
|
|
func(ctx context.Context, exec bob.Executor, retrieved AddressLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadAddress(ctx, exec, mods...)
|
|
},
|
|
),
|
|
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...)
|
|
},
|
|
),
|
|
ReviewerUser: thenLoadBuilder[Q](
|
|
"ReviewerUser",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReviewerUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReviewerUser(ctx, exec, mods...)
|
|
},
|
|
),
|
|
}
|
|
}
|
|
|
|
// LoadNuisanceNotifyEmailNuisanceOlds loads the publicreportNuisanceOld's NuisanceNotifyEmailNuisanceOlds into the .R struct
|
|
func (o *PublicreportNuisanceOld) LoadNuisanceNotifyEmailNuisanceOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.NuisanceNotifyEmailNuisanceOlds = nil
|
|
|
|
related, err := o.NuisanceNotifyEmailNuisanceOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.NuisanceNuisanceOld = o
|
|
}
|
|
|
|
o.R.NuisanceNotifyEmailNuisanceOlds = related
|
|
return nil
|
|
}
|
|
|
|
// LoadNuisanceNotifyEmailNuisanceOlds loads the publicreportNuisanceOld's NuisanceNotifyEmailNuisanceOlds into the .R struct
|
|
func (os PublicreportNuisanceOldSlice) LoadNuisanceNotifyEmailNuisanceOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportNotifyEmailNuisanceOlds, err := os.NuisanceNotifyEmailNuisanceOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.NuisanceNotifyEmailNuisanceOlds = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportNotifyEmailNuisanceOlds {
|
|
|
|
if !(o.ID == rel.NuisanceID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.NuisanceNuisanceOld = o
|
|
|
|
o.R.NuisanceNotifyEmailNuisanceOlds = append(o.R.NuisanceNotifyEmailNuisanceOlds, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadNuisanceNotifyPhoneNuisanceOlds loads the publicreportNuisanceOld's NuisanceNotifyPhoneNuisanceOlds into the .R struct
|
|
func (o *PublicreportNuisanceOld) LoadNuisanceNotifyPhoneNuisanceOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.NuisanceNotifyPhoneNuisanceOlds = nil
|
|
|
|
related, err := o.NuisanceNotifyPhoneNuisanceOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.NuisanceNuisanceOld = o
|
|
}
|
|
|
|
o.R.NuisanceNotifyPhoneNuisanceOlds = related
|
|
return nil
|
|
}
|
|
|
|
// LoadNuisanceNotifyPhoneNuisanceOlds loads the publicreportNuisanceOld's NuisanceNotifyPhoneNuisanceOlds into the .R struct
|
|
func (os PublicreportNuisanceOldSlice) LoadNuisanceNotifyPhoneNuisanceOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportNotifyPhoneNuisanceOlds, err := os.NuisanceNotifyPhoneNuisanceOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.NuisanceNotifyPhoneNuisanceOlds = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportNotifyPhoneNuisanceOlds {
|
|
|
|
if !(o.ID == rel.NuisanceID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.NuisanceNuisanceOld = o
|
|
|
|
o.R.NuisanceNotifyPhoneNuisanceOlds = append(o.R.NuisanceNotifyPhoneNuisanceOlds, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadImages loads the publicreportNuisanceOld's Images into the .R struct
|
|
func (o *PublicreportNuisanceOld) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Images = nil
|
|
|
|
related, err := o.Images(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.NuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
}
|
|
|
|
o.R.Images = related
|
|
return nil
|
|
}
|
|
|
|
// LoadImages loads the publicreportNuisanceOld's Images into the .R struct
|
|
func (os PublicreportNuisanceOldSlice) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
// 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(PublicreportNuisanceImageOlds.Columns.NuisanceID.As("related_publicreport.nuisance_old.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.nuisance_old.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)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
o.R.Images = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
for i, rel := range publicreportImages {
|
|
if !(o.ID == IDSlice[i]) {
|
|
continue
|
|
}
|
|
|
|
rel.R.NuisanceOlds = append(rel.R.NuisanceOlds, o)
|
|
|
|
o.R.Images = append(o.R.Images, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadAddress loads the publicreportNuisanceOld's Address into the .R struct
|
|
func (o *PublicreportNuisanceOld) LoadAddress(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Address = nil
|
|
|
|
related, err := o.Address(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.NuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
|
|
o.R.Address = related
|
|
return nil
|
|
}
|
|
|
|
// LoadAddress loads the publicreportNuisanceOld's Address into the .R struct
|
|
func (os PublicreportNuisanceOldSlice) LoadAddress(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
addresses, err := os.Address(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range addresses {
|
|
if !o.AddressID.IsValue() {
|
|
continue
|
|
}
|
|
|
|
if !(o.AddressID.IsValue() && o.AddressID.MustGet() == rel.ID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.NuisanceOlds = append(rel.R.NuisanceOlds, o)
|
|
|
|
o.R.Address = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadOrganization loads the publicreportNuisanceOld's Organization into the .R struct
|
|
func (o *PublicreportNuisanceOld) 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.NuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
|
|
o.R.Organization = related
|
|
return nil
|
|
}
|
|
|
|
// LoadOrganization loads the publicreportNuisanceOld's Organization into the .R struct
|
|
func (os PublicreportNuisanceOldSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
organizations, err := os.Organization(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range organizations {
|
|
|
|
if !(o.OrganizationID == rel.ID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.NuisanceOlds = append(rel.R.NuisanceOlds, o)
|
|
|
|
o.R.Organization = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerUser loads the publicreportNuisanceOld's ReviewerUser into the .R struct
|
|
func (o *PublicreportNuisanceOld) LoadReviewerUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReviewerUser = nil
|
|
|
|
related, err := o.ReviewerUser(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.ReviewerNuisanceOlds = PublicreportNuisanceOldSlice{o}
|
|
|
|
o.R.ReviewerUser = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerUser loads the publicreportNuisanceOld's ReviewerUser into the .R struct
|
|
func (os PublicreportNuisanceOldSlice) LoadReviewerUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
users, err := os.ReviewerUser(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range users {
|
|
if !o.ReviewerID.IsValue() {
|
|
continue
|
|
}
|
|
|
|
if !(o.ReviewerID.IsValue() && o.ReviewerID.MustGet() == rel.ID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.ReviewerNuisanceOlds = append(rel.R.ReviewerNuisanceOlds, o)
|
|
|
|
o.R.ReviewerUser = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|