Migrate public report classes to point location
...and drop quick report tables
This commit is contained in:
parent
4972dd05ee
commit
1e80c62701
24 changed files with 189 additions and 2875 deletions
|
|
@ -1,26 +0,0 @@
|
|||
// 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 dberrors
|
||||
|
||||
var PublicreportQuickErrors = &publicreportQuickErrors{
|
||||
ErrUniqueQuickPkey: &UniqueConstraintError{
|
||||
schema: "publicreport",
|
||||
table: "quick",
|
||||
columns: []string{"id"},
|
||||
s: "quick_pkey",
|
||||
},
|
||||
|
||||
ErrUniqueQuickPublicIdKey: &UniqueConstraintError{
|
||||
schema: "publicreport",
|
||||
table: "quick",
|
||||
columns: []string{"public_id"},
|
||||
s: "quick_public_id_key",
|
||||
},
|
||||
}
|
||||
|
||||
type publicreportQuickErrors struct {
|
||||
ErrUniqueQuickPkey *UniqueConstraintError
|
||||
|
||||
ErrUniqueQuickPublicIdKey *UniqueConstraintError
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// 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 dberrors
|
||||
|
||||
var PublicreportQuickImageErrors = &publicreportQuickImageErrors{
|
||||
ErrUniqueQuickImagePkey: &UniqueConstraintError{
|
||||
schema: "publicreport",
|
||||
table: "quick_image",
|
||||
columns: []string{"image_id", "quick_id"},
|
||||
s: "quick_image_pkey",
|
||||
},
|
||||
}
|
||||
|
||||
type publicreportQuickImageErrors struct {
|
||||
ErrUniqueQuickImagePkey *UniqueConstraintError
|
||||
}
|
||||
|
|
@ -123,15 +123,6 @@ var PublicreportNuisances = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geography",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Status: column{
|
||||
Name: "status",
|
||||
DBType: "publicreport.reportstatustype",
|
||||
|
|
@ -330,6 +321,15 @@ var PublicreportNuisances = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geometry",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportNuisanceIndexes{
|
||||
NuisancePkey: index{
|
||||
|
|
@ -407,7 +407,6 @@ type publicreportNuisanceColumns struct {
|
|||
ReporterName column
|
||||
ReporterPhone column
|
||||
Address column
|
||||
Location column
|
||||
Status column
|
||||
OrganizationID column
|
||||
SourceGutter column
|
||||
|
|
@ -430,11 +429,12 @@ type publicreportNuisanceColumns struct {
|
|||
LatlngAccuracyType column
|
||||
LatlngAccuracyValue column
|
||||
ReporterContactConsent column
|
||||
Location column
|
||||
}
|
||||
|
||||
func (c publicreportNuisanceColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.SourceContainer, c.SourceDescription, c.SourceStagnant, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Address, c.Location, c.Status, c.OrganizationID, c.SourceGutter, c.H3cell, c.AddressCountry, c.AddressPlace, c.AddressPostcode, c.AddressRegion, c.AddressStreet, c.IsLocationBackyard, c.IsLocationFrontyard, c.IsLocationGarden, c.IsLocationOther, c.IsLocationPool, c.MapZoom, c.TodEarly, c.TodDay, c.TodEvening, c.TodNight, c.LatlngAccuracyType, c.LatlngAccuracyValue, c.ReporterContactConsent,
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.SourceContainer, c.SourceDescription, c.SourceStagnant, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Address, c.Status, c.OrganizationID, c.SourceGutter, c.H3cell, c.AddressCountry, c.AddressPlace, c.AddressPostcode, c.AddressRegion, c.AddressStreet, c.IsLocationBackyard, c.IsLocationFrontyard, c.IsLocationGarden, c.IsLocationOther, c.IsLocationPool, c.MapZoom, c.TodEarly, c.TodDay, c.TodEvening, c.TodNight, c.LatlngAccuracyType, c.LatlngAccuracyValue, c.ReporterContactConsent, c.Location,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,15 +186,6 @@ var PublicreportPools = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geography",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
MapZoom: column{
|
||||
Name: "map_zoom",
|
||||
DBType: "real",
|
||||
|
|
@ -321,6 +312,15 @@ var PublicreportPools = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geometry",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportPoolIndexes{
|
||||
PoolPkey: index{
|
||||
|
|
@ -405,7 +405,6 @@ type publicreportPoolColumns struct {
|
|||
HasAdult column
|
||||
HasLarvae column
|
||||
HasPupae column
|
||||
Location column
|
||||
MapZoom column
|
||||
OwnerEmail column
|
||||
OwnerName column
|
||||
|
|
@ -420,11 +419,12 @@ type publicreportPoolColumns struct {
|
|||
IsReporterConfidential column
|
||||
IsReporterOwner column
|
||||
ReporterContactConsent column
|
||||
Location column
|
||||
}
|
||||
|
||||
func (c publicreportPoolColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.AccessComments, c.AccessGate, c.AccessFence, c.AccessLocked, c.AccessDog, c.AccessOther, c.Address, c.AddressCountry, c.AddressPostCode, c.AddressPlace, c.AddressStreet, c.AddressRegion, c.Comments, c.Created, c.H3cell, c.HasAdult, c.HasLarvae, c.HasPupae, c.Location, c.MapZoom, c.OwnerEmail, c.OwnerName, c.OwnerPhone, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Status, c.OrganizationID, c.HasBackyardPermission, c.IsReporterConfidential, c.IsReporterOwner, c.ReporterContactConsent,
|
||||
c.ID, c.AccessComments, c.AccessGate, c.AccessFence, c.AccessLocked, c.AccessDog, c.AccessOther, c.Address, c.AddressCountry, c.AddressPostCode, c.AddressPlace, c.AddressStreet, c.AddressRegion, c.Comments, c.Created, c.H3cell, c.HasAdult, c.HasLarvae, c.HasPupae, c.MapZoom, c.OwnerEmail, c.OwnerName, c.OwnerPhone, c.PublicID, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Status, c.OrganizationID, c.HasBackyardPermission, c.IsReporterConfidential, c.IsReporterOwner, c.ReporterContactConsent, c.Location,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,236 +0,0 @@
|
|||
// 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 dbinfo
|
||||
|
||||
import "github.com/aarondl/opt/null"
|
||||
|
||||
var PublicreportQuicks = Table[
|
||||
publicreportQuickColumns,
|
||||
publicreportQuickIndexes,
|
||||
publicreportQuickForeignKeys,
|
||||
publicreportQuickUniques,
|
||||
publicreportQuickChecks,
|
||||
]{
|
||||
Schema: "publicreport",
|
||||
Name: "quick",
|
||||
Columns: publicreportQuickColumns{
|
||||
ID: column{
|
||||
Name: "id",
|
||||
DBType: "integer",
|
||||
Default: "nextval('publicreport.quick_id_seq'::regclass)",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Created: column{
|
||||
Name: "created",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Comments: column{
|
||||
Name: "comments",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geography",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
H3cell: column{
|
||||
Name: "h3cell",
|
||||
DBType: "h3index",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
PublicID: column{
|
||||
Name: "public_id",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ReporterEmail: column{
|
||||
Name: "reporter_email",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ReporterPhone: column{
|
||||
Name: "reporter_phone",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Address: column{
|
||||
Name: "address",
|
||||
DBType: "text",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Status: column{
|
||||
Name: "status",
|
||||
DBType: "publicreport.reportstatustype",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
OrganizationID: column{
|
||||
Name: "organization_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportQuickIndexes{
|
||||
QuickPkey: index{
|
||||
Type: "btree",
|
||||
Name: "quick_pkey",
|
||||
Columns: []indexColumn{
|
||||
{
|
||||
Name: "id",
|
||||
Desc: null.FromCond(false, true),
|
||||
IsExpression: false,
|
||||
},
|
||||
},
|
||||
Unique: true,
|
||||
Comment: "",
|
||||
NullsFirst: []bool{false},
|
||||
NullsDistinct: false,
|
||||
Where: "",
|
||||
Include: []string{},
|
||||
},
|
||||
QuickPublicIDKey: index{
|
||||
Type: "btree",
|
||||
Name: "quick_public_id_key",
|
||||
Columns: []indexColumn{
|
||||
{
|
||||
Name: "public_id",
|
||||
Desc: null.FromCond(false, true),
|
||||
IsExpression: false,
|
||||
},
|
||||
},
|
||||
Unique: true,
|
||||
Comment: "",
|
||||
NullsFirst: []bool{false},
|
||||
NullsDistinct: false,
|
||||
Where: "",
|
||||
Include: []string{},
|
||||
},
|
||||
},
|
||||
PrimaryKey: &constraint{
|
||||
Name: "quick_pkey",
|
||||
Columns: []string{"id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignKeys: publicreportQuickForeignKeys{
|
||||
PublicreportQuickQuickOrganizationIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "publicreport.quick.quick_organization_id_fkey",
|
||||
Columns: []string{"organization_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "organization",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
Uniques: publicreportQuickUniques{
|
||||
QuickPublicIDKey: constraint{
|
||||
Name: "quick_public_id_key",
|
||||
Columns: []string{"public_id"},
|
||||
Comment: "",
|
||||
},
|
||||
},
|
||||
|
||||
Comment: "",
|
||||
}
|
||||
|
||||
type publicreportQuickColumns struct {
|
||||
ID column
|
||||
Created column
|
||||
Comments column
|
||||
Location column
|
||||
H3cell column
|
||||
PublicID column
|
||||
ReporterEmail column
|
||||
ReporterPhone column
|
||||
Address column
|
||||
Status column
|
||||
OrganizationID column
|
||||
}
|
||||
|
||||
func (c publicreportQuickColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.Created, c.Comments, c.Location, c.H3cell, c.PublicID, c.ReporterEmail, c.ReporterPhone, c.Address, c.Status, c.OrganizationID,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickIndexes struct {
|
||||
QuickPkey index
|
||||
QuickPublicIDKey index
|
||||
}
|
||||
|
||||
func (i publicreportQuickIndexes) AsSlice() []index {
|
||||
return []index{
|
||||
i.QuickPkey, i.QuickPublicIDKey,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickForeignKeys struct {
|
||||
PublicreportQuickQuickOrganizationIDFkey foreignKey
|
||||
}
|
||||
|
||||
func (f publicreportQuickForeignKeys) AsSlice() []foreignKey {
|
||||
return []foreignKey{
|
||||
f.PublicreportQuickQuickOrganizationIDFkey,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickUniques struct {
|
||||
QuickPublicIDKey constraint
|
||||
}
|
||||
|
||||
func (u publicreportQuickUniques) AsSlice() []constraint {
|
||||
return []constraint{
|
||||
u.QuickPublicIDKey,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickChecks struct{}
|
||||
|
||||
func (c publicreportQuickChecks) AsSlice() []check {
|
||||
return []check{}
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
// 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 dbinfo
|
||||
|
||||
import "github.com/aarondl/opt/null"
|
||||
|
||||
var PublicreportQuickImages = Table[
|
||||
publicreportQuickImageColumns,
|
||||
publicreportQuickImageIndexes,
|
||||
publicreportQuickImageForeignKeys,
|
||||
publicreportQuickImageUniques,
|
||||
publicreportQuickImageChecks,
|
||||
]{
|
||||
Schema: "publicreport",
|
||||
Name: "quick_image",
|
||||
Columns: publicreportQuickImageColumns{
|
||||
ImageID: column{
|
||||
Name: "image_id",
|
||||
DBType: "integer",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
QuickID: column{
|
||||
Name: "quick_id",
|
||||
DBType: "integer",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportQuickImageIndexes{
|
||||
QuickImagePkey: index{
|
||||
Type: "btree",
|
||||
Name: "quick_image_pkey",
|
||||
Columns: []indexColumn{
|
||||
{
|
||||
Name: "image_id",
|
||||
Desc: null.FromCond(false, true),
|
||||
IsExpression: false,
|
||||
},
|
||||
{
|
||||
Name: "quick_id",
|
||||
Desc: null.FromCond(false, true),
|
||||
IsExpression: false,
|
||||
},
|
||||
},
|
||||
Unique: true,
|
||||
Comment: "",
|
||||
NullsFirst: []bool{false, false},
|
||||
NullsDistinct: false,
|
||||
Where: "",
|
||||
Include: []string{},
|
||||
},
|
||||
},
|
||||
PrimaryKey: &constraint{
|
||||
Name: "quick_image_pkey",
|
||||
Columns: []string{"image_id", "quick_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignKeys: publicreportQuickImageForeignKeys{
|
||||
PublicreportQuickImageQuickImageImageIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "publicreport.quick_image.quick_image_image_id_fkey",
|
||||
Columns: []string{"image_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "publicreport.image",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
PublicreportQuickImageQuickImageQuickIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "publicreport.quick_image.quick_image_quick_id_fkey",
|
||||
Columns: []string{"quick_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "publicreport.quick",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
|
||||
Comment: "",
|
||||
}
|
||||
|
||||
type publicreportQuickImageColumns struct {
|
||||
ImageID column
|
||||
QuickID column
|
||||
}
|
||||
|
||||
func (c publicreportQuickImageColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ImageID, c.QuickID,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickImageIndexes struct {
|
||||
QuickImagePkey index
|
||||
}
|
||||
|
||||
func (i publicreportQuickImageIndexes) AsSlice() []index {
|
||||
return []index{
|
||||
i.QuickImagePkey,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickImageForeignKeys struct {
|
||||
PublicreportQuickImageQuickImageImageIDFkey foreignKey
|
||||
PublicreportQuickImageQuickImageQuickIDFkey foreignKey
|
||||
}
|
||||
|
||||
func (f publicreportQuickImageForeignKeys) AsSlice() []foreignKey {
|
||||
return []foreignKey{
|
||||
f.PublicreportQuickImageQuickImageImageIDFkey, f.PublicreportQuickImageQuickImageQuickIDFkey,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickImageUniques struct{}
|
||||
|
||||
func (u publicreportQuickImageUniques) AsSlice() []constraint {
|
||||
return []constraint{}
|
||||
}
|
||||
|
||||
type publicreportQuickImageChecks struct{}
|
||||
|
||||
func (c publicreportQuickImageChecks) AsSlice() []check {
|
||||
return []check{}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ var PublicreportReportLocations = Table[
|
|||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geography",
|
||||
DBType: "geometry",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
|
|
|
|||
45
db/migrations/00093_publicreport_location_type.sql
Normal file
45
db/migrations/00093_publicreport_location_type.sql
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
-- +goose Up
|
||||
DROP VIEW publicreport.report_location;
|
||||
|
||||
ALTER TABLE publicreport.nuisance ADD COLUMN loc2 geometry(Point, 4326);
|
||||
UPDATE publicreport.nuisance SET loc2 = location::geometry(Point, 4326);
|
||||
ALTER TABLE publicreport.nuisance DROP COLUMN location;
|
||||
ALTER TABLE publicreport.nuisance RENAME COLUMN loc2 TO location;
|
||||
|
||||
ALTER TABLE publicreport.pool ADD COLUMN loc2 geometry(Point, 4326);
|
||||
UPDATE publicreport.pool SET loc2 = location::geometry(Point, 4326);
|
||||
ALTER TABLE publicreport.pool DROP COLUMN location;
|
||||
ALTER TABLE publicreport.pool RENAME COLUMN loc2 TO location;
|
||||
|
||||
DROP TABLE publicreport.quick_image;
|
||||
DROP TABLE publicreport.quick;
|
||||
|
||||
CREATE VIEW publicreport.report_location AS
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY table_name, public_id) AS id,
|
||||
table_name,
|
||||
address,
|
||||
created,
|
||||
location,
|
||||
public_id,
|
||||
status
|
||||
FROM (
|
||||
SELECT
|
||||
'nuisance' AS table_name,
|
||||
address,
|
||||
created,
|
||||
location,
|
||||
public_id,
|
||||
status
|
||||
FROM publicreport.nuisance
|
||||
UNION
|
||||
SELECT
|
||||
'pool' AS table_name,
|
||||
address,
|
||||
created,
|
||||
location,
|
||||
public_id,
|
||||
status
|
||||
FROM publicreport.pool
|
||||
) AS combined_data;
|
||||
-- +goose Down
|
||||
|
|
@ -95,8 +95,6 @@ type preloaders struct {
|
|||
PublicreportNuisanceImage publicreportNuisanceImagePreloader
|
||||
PublicreportPool publicreportPoolPreloader
|
||||
PublicreportPoolImage publicreportPoolImagePreloader
|
||||
PublicreportQuick publicreportQuickPreloader
|
||||
PublicreportQuickImage publicreportQuickImagePreloader
|
||||
PublicreportSubscribeEmail publicreportSubscribeEmailPreloader
|
||||
PublicreportSubscribePhone publicreportSubscribePhonePreloader
|
||||
Resident residentPreloader
|
||||
|
|
@ -188,8 +186,6 @@ func getPreloaders() preloaders {
|
|||
PublicreportNuisanceImage: buildPublicreportNuisanceImagePreloader(),
|
||||
PublicreportPool: buildPublicreportPoolPreloader(),
|
||||
PublicreportPoolImage: buildPublicreportPoolImagePreloader(),
|
||||
PublicreportQuick: buildPublicreportQuickPreloader(),
|
||||
PublicreportQuickImage: buildPublicreportQuickImagePreloader(),
|
||||
PublicreportSubscribeEmail: buildPublicreportSubscribeEmailPreloader(),
|
||||
PublicreportSubscribePhone: buildPublicreportSubscribePhonePreloader(),
|
||||
Resident: buildResidentPreloader(),
|
||||
|
|
@ -287,8 +283,6 @@ type thenLoaders[Q orm.Loadable] struct {
|
|||
PublicreportNuisanceImage publicreportNuisanceImageThenLoader[Q]
|
||||
PublicreportPool publicreportPoolThenLoader[Q]
|
||||
PublicreportPoolImage publicreportPoolImageThenLoader[Q]
|
||||
PublicreportQuick publicreportQuickThenLoader[Q]
|
||||
PublicreportQuickImage publicreportQuickImageThenLoader[Q]
|
||||
PublicreportSubscribeEmail publicreportSubscribeEmailThenLoader[Q]
|
||||
PublicreportSubscribePhone publicreportSubscribePhoneThenLoader[Q]
|
||||
Resident residentThenLoader[Q]
|
||||
|
|
@ -380,8 +374,6 @@ func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] {
|
|||
PublicreportNuisanceImage: buildPublicreportNuisanceImageThenLoader[Q](),
|
||||
PublicreportPool: buildPublicreportPoolThenLoader[Q](),
|
||||
PublicreportPoolImage: buildPublicreportPoolImageThenLoader[Q](),
|
||||
PublicreportQuick: buildPublicreportQuickThenLoader[Q](),
|
||||
PublicreportQuickImage: buildPublicreportQuickImageThenLoader[Q](),
|
||||
PublicreportSubscribeEmail: buildPublicreportSubscribeEmailThenLoader[Q](),
|
||||
PublicreportSubscribePhone: buildPublicreportSubscribePhoneThenLoader[Q](),
|
||||
Resident: buildResidentThenLoader[Q](),
|
||||
|
|
|
|||
|
|
@ -98,8 +98,6 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportNuisanceImages publicreportNuisanceImageWhere[Q]
|
||||
PublicreportPools publicreportPoolWhere[Q]
|
||||
PublicreportPoolImages publicreportPoolImageWhere[Q]
|
||||
PublicreportQuicks publicreportQuickWhere[Q]
|
||||
PublicreportQuickImages publicreportQuickImageWhere[Q]
|
||||
PublicreportReportLocations publicreportReportLocationWhere[Q]
|
||||
PublicreportSubscribeEmails publicreportSubscribeEmailWhere[Q]
|
||||
PublicreportSubscribePhones publicreportSubscribePhoneWhere[Q]
|
||||
|
|
@ -197,8 +195,6 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportNuisanceImages publicreportNuisanceImageWhere[Q]
|
||||
PublicreportPools publicreportPoolWhere[Q]
|
||||
PublicreportPoolImages publicreportPoolImageWhere[Q]
|
||||
PublicreportQuicks publicreportQuickWhere[Q]
|
||||
PublicreportQuickImages publicreportQuickImageWhere[Q]
|
||||
PublicreportReportLocations publicreportReportLocationWhere[Q]
|
||||
PublicreportSubscribeEmails publicreportSubscribeEmailWhere[Q]
|
||||
PublicreportSubscribePhones publicreportSubscribePhoneWhere[Q]
|
||||
|
|
@ -295,8 +291,6 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportNuisanceImages: buildPublicreportNuisanceImageWhere[Q](PublicreportNuisanceImages.Columns),
|
||||
PublicreportPools: buildPublicreportPoolWhere[Q](PublicreportPools.Columns),
|
||||
PublicreportPoolImages: buildPublicreportPoolImageWhere[Q](PublicreportPoolImages.Columns),
|
||||
PublicreportQuicks: buildPublicreportQuickWhere[Q](PublicreportQuicks.Columns),
|
||||
PublicreportQuickImages: buildPublicreportQuickImageWhere[Q](PublicreportQuickImages.Columns),
|
||||
PublicreportReportLocations: buildPublicreportReportLocationWhere[Q](PublicreportReportLocations.Columns),
|
||||
PublicreportSubscribeEmails: buildPublicreportSubscribeEmailWhere[Q](PublicreportSubscribeEmails.Columns),
|
||||
PublicreportSubscribePhones: buildPublicreportSubscribePhoneWhere[Q](PublicreportSubscribePhones.Columns),
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ type organizationR struct {
|
|||
FieldseekerServiceFeatureItemServiceFeature *ArcgisServiceFeature // organization.organization_fieldseeker_service_feature_item_id_fkey
|
||||
Nuisances PublicreportNuisanceSlice // publicreport.nuisance.nuisance_organization_id_fkey
|
||||
PublicreportPool PublicreportPoolSlice // publicreport.pool.pool_organization_id_fkey
|
||||
Quicks PublicreportQuickSlice // publicreport.quick.quick_organization_id_fkey
|
||||
ReviewTasks ReviewTaskSlice // review_task.review_task_organization_id_fkey
|
||||
Signals SignalSlice // signal.signal_organization_id_fkey
|
||||
User UserSlice // user_.user__organization_id_fkey
|
||||
|
|
@ -1998,30 +1997,6 @@ func (os OrganizationSlice) PublicreportPool(mods ...bob.Mod[*dialect.SelectQuer
|
|||
)...)
|
||||
}
|
||||
|
||||
// Quicks starts a query for related objects on publicreport.quick
|
||||
func (o *Organization) Quicks(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
|
||||
return PublicreportQuicks.Query(append(mods,
|
||||
sm.Where(PublicreportQuicks.Columns.OrganizationID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os OrganizationSlice) Quicks(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
|
||||
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 PublicreportQuicks.Query(append(mods,
|
||||
sm.Where(psql.Group(PublicreportQuicks.Columns.OrganizationID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// ReviewTasks starts a query for related objects on review_task
|
||||
func (o *Organization) ReviewTasks(mods ...bob.Mod[*dialect.SelectQuery]) ReviewTasksQuery {
|
||||
return ReviewTasks.Query(append(mods,
|
||||
|
|
@ -5020,74 +4995,6 @@ func (organization0 *Organization) AttachPublicreportPool(ctx context.Context, e
|
|||
return nil
|
||||
}
|
||||
|
||||
func insertOrganizationQuicks0(ctx context.Context, exec bob.Executor, publicreportQuicks1 []*PublicreportQuickSetter, organization0 *Organization) (PublicreportQuickSlice, error) {
|
||||
for i := range publicreportQuicks1 {
|
||||
publicreportQuicks1[i].OrganizationID = omitnull.From(organization0.ID)
|
||||
}
|
||||
|
||||
ret, err := PublicreportQuicks.Insert(bob.ToMods(publicreportQuicks1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertOrganizationQuicks0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachOrganizationQuicks0(ctx context.Context, exec bob.Executor, count int, publicreportQuicks1 PublicreportQuickSlice, organization0 *Organization) (PublicreportQuickSlice, error) {
|
||||
setter := &PublicreportQuickSetter{
|
||||
OrganizationID: omitnull.From(organization0.ID),
|
||||
}
|
||||
|
||||
err := publicreportQuicks1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachOrganizationQuicks0: %w", err)
|
||||
}
|
||||
|
||||
return publicreportQuicks1, nil
|
||||
}
|
||||
|
||||
func (organization0 *Organization) InsertQuicks(ctx context.Context, exec bob.Executor, related ...*PublicreportQuickSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
publicreportQuicks1, err := insertOrganizationQuicks0(ctx, exec, related, organization0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
organization0.R.Quicks = append(organization0.R.Quicks, publicreportQuicks1...)
|
||||
|
||||
for _, rel := range publicreportQuicks1 {
|
||||
rel.R.Organization = organization0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (organization0 *Organization) AttachQuicks(ctx context.Context, exec bob.Executor, related ...*PublicreportQuick) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
publicreportQuicks1 := PublicreportQuickSlice(related)
|
||||
|
||||
_, err = attachOrganizationQuicks0(ctx, exec, len(related), publicreportQuicks1, organization0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
organization0.R.Quicks = append(organization0.R.Quicks, publicreportQuicks1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Organization = organization0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertOrganizationReviewTasks0(ctx context.Context, exec bob.Executor, reviewTasks1 []*ReviewTaskSetter, organization0 *Organization) (ReviewTaskSlice, error) {
|
||||
for i := range reviewTasks1 {
|
||||
reviewTasks1[i].OrganizationID = omit.From(organization0.ID)
|
||||
|
|
@ -5980,20 +5887,6 @@ func (o *Organization) Preload(name string, retrieved any) error {
|
|||
|
||||
o.R.PublicreportPool = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.Organization = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "Quicks":
|
||||
rels, ok := retrieved.(PublicreportQuickSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("organization cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Quicks = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.Organization = o
|
||||
|
|
@ -6142,7 +6035,6 @@ type organizationThenLoader[Q orm.Loadable] struct {
|
|||
FieldseekerServiceFeatureItemServiceFeature func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Nuisances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
PublicreportPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Quicks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewTasks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Signals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
User func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
|
|
@ -6281,9 +6173,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
|
|||
type PublicreportPoolLoadInterface interface {
|
||||
LoadPublicreportPool(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type QuicksLoadInterface interface {
|
||||
LoadQuicks(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type ReviewTasksLoadInterface interface {
|
||||
LoadReviewTasks(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -6559,12 +6448,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
|
|||
return retrieved.LoadPublicreportPool(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
Quicks: thenLoadBuilder[Q](
|
||||
"Quicks",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved QuicksLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadQuicks(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
ReviewTasks: thenLoadBuilder[Q](
|
||||
"ReviewTasks",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ReviewTasksLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -9298,70 +9181,6 @@ func (os OrganizationSlice) LoadPublicreportPool(ctx context.Context, exec bob.E
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadQuicks loads the organization's Quicks into the .R struct
|
||||
func (o *Organization) LoadQuicks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.Quicks = nil
|
||||
|
||||
related, err := o.Quicks(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Organization = o
|
||||
}
|
||||
|
||||
o.R.Quicks = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadQuicks loads the organization's Quicks into the .R struct
|
||||
func (os OrganizationSlice) LoadQuicks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
publicreportQuicks, err := os.Quicks(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.Quicks = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range publicreportQuicks {
|
||||
|
||||
if !rel.OrganizationID.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.OrganizationID.IsValue() && o.ID == rel.OrganizationID.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.Organization = o
|
||||
|
||||
o.R.Quicks = append(o.R.Quicks, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadReviewTasks loads the organization's ReviewTasks into the .R struct
|
||||
func (o *Organization) LoadReviewTasks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ type publicreportImageR struct {
|
|||
ImageExifs PublicreportImageExifSlice // publicreport.image_exif.image_exif_image_id_fkey
|
||||
Nuisances PublicreportNuisanceSlice // publicreport.nuisance_image.nuisance_image_image_id_fkeypublicreport.nuisance_image.nuisance_image_nuisance_id_fkey
|
||||
Pools PublicreportPoolSlice // publicreport.pool_image.pool_image_image_id_fkeypublicreport.pool_image.pool_image_pool_id_fkey
|
||||
Quicks PublicreportQuickSlice // publicreport.quick_image.quick_image_image_id_fkeypublicreport.quick_image.quick_image_quick_id_fkey
|
||||
}
|
||||
|
||||
func buildPublicreportImageColumns(alias string) publicreportImageColumns {
|
||||
|
|
@ -618,35 +617,6 @@ func (os PublicreportImageSlice) Pools(mods ...bob.Mod[*dialect.SelectQuery]) Pu
|
|||
)...)
|
||||
}
|
||||
|
||||
// Quicks starts a query for related objects on publicreport.quick
|
||||
func (o *PublicreportImage) Quicks(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
|
||||
return PublicreportQuicks.Query(append(mods,
|
||||
sm.InnerJoin(PublicreportQuickImages.NameAs()).On(
|
||||
PublicreportQuicks.Columns.ID.EQ(PublicreportQuickImages.Columns.QuickID)),
|
||||
sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os PublicreportImageSlice) Quicks(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
|
||||
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 PublicreportQuicks.Query(append(mods,
|
||||
sm.InnerJoin(PublicreportQuickImages.NameAs()).On(
|
||||
PublicreportQuicks.Columns.ID.EQ(PublicreportQuickImages.Columns.QuickID),
|
||||
),
|
||||
sm.Where(psql.Group(PublicreportQuickImages.Columns.ImageID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
func insertPublicreportImageImageExifs0(ctx context.Context, exec bob.Executor, publicreportImageExifs1 []*PublicreportImageExifSetter, publicreportImage0 *PublicreportImage) (PublicreportImageExifSlice, error) {
|
||||
for i := range publicreportImageExifs1 {
|
||||
publicreportImageExifs1[i].ImageID = omit.From(publicreportImage0.ID)
|
||||
|
|
@ -845,71 +815,6 @@ func (publicreportImage0 *PublicreportImage) AttachPools(ctx context.Context, ex
|
|||
return nil
|
||||
}
|
||||
|
||||
func attachPublicreportImageQuicks0(ctx context.Context, exec bob.Executor, count int, publicreportImage0 *PublicreportImage, publicreportQuicks2 PublicreportQuickSlice) (PublicreportQuickImageSlice, error) {
|
||||
setters := make([]*PublicreportQuickImageSetter, count)
|
||||
for i := range count {
|
||||
setters[i] = &PublicreportQuickImageSetter{
|
||||
ImageID: omit.From(publicreportImage0.ID),
|
||||
QuickID: omit.From(publicreportQuicks2[i].ID),
|
||||
}
|
||||
}
|
||||
|
||||
publicreportQuickImages1, err := PublicreportQuickImages.Insert(bob.ToMods(setters...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachPublicreportImageQuicks0: %w", err)
|
||||
}
|
||||
|
||||
return publicreportQuickImages1, nil
|
||||
}
|
||||
|
||||
func (publicreportImage0 *PublicreportImage) InsertQuicks(ctx context.Context, exec bob.Executor, related ...*PublicreportQuickSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
inserted, err := PublicreportQuicks.Insert(bob.ToMods(related...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return fmt.Errorf("inserting related objects: %w", err)
|
||||
}
|
||||
publicreportQuicks2 := PublicreportQuickSlice(inserted)
|
||||
|
||||
_, err = attachPublicreportImageQuicks0(ctx, exec, len(related), publicreportImage0, publicreportQuicks2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportImage0.R.Quicks = append(publicreportImage0.R.Quicks, publicreportQuicks2...)
|
||||
|
||||
for _, rel := range publicreportQuicks2 {
|
||||
rel.R.Images = append(rel.R.Images, publicreportImage0)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (publicreportImage0 *PublicreportImage) AttachQuicks(ctx context.Context, exec bob.Executor, related ...*PublicreportQuick) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
publicreportQuicks2 := PublicreportQuickSlice(related)
|
||||
|
||||
_, err = attachPublicreportImageQuicks0(ctx, exec, len(related), publicreportImage0, publicreportQuicks2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportImage0.R.Quicks = append(publicreportImage0.R.Quicks, publicreportQuicks2...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Images = append(rel.R.Images, publicreportImage0)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type publicreportImageWhere[Q psql.Filterable] struct {
|
||||
ID psql.WhereMod[Q, int32]
|
||||
ContentType psql.WhereMod[Q, string]
|
||||
|
|
@ -982,20 +887,6 @@ func (o *PublicreportImage) Preload(name string, retrieved any) error {
|
|||
|
||||
o.R.Pools = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.Images = PublicreportImageSlice{o}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "Quicks":
|
||||
rels, ok := retrieved.(PublicreportQuickSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("publicreportImage cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Quicks = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.Images = PublicreportImageSlice{o}
|
||||
|
|
@ -1017,7 +908,6 @@ type publicreportImageThenLoader[Q orm.Loadable] struct {
|
|||
ImageExifs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Nuisances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Quicks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildPublicreportImageThenLoader[Q orm.Loadable]() publicreportImageThenLoader[Q] {
|
||||
|
|
@ -1030,9 +920,6 @@ func buildPublicreportImageThenLoader[Q orm.Loadable]() publicreportImageThenLoa
|
|||
type PoolsLoadInterface interface {
|
||||
LoadPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type QuicksLoadInterface interface {
|
||||
LoadQuicks(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
||||
return publicreportImageThenLoader[Q]{
|
||||
ImageExifs: thenLoadBuilder[Q](
|
||||
|
|
@ -1053,12 +940,6 @@ func buildPublicreportImageThenLoader[Q orm.Loadable]() publicreportImageThenLoa
|
|||
return retrieved.LoadPools(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
Quicks: thenLoadBuilder[Q](
|
||||
"Quicks",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved QuicksLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadQuicks(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1284,84 +1165,3 @@ func (os PublicreportImageSlice) LoadPools(ctx context.Context, exec bob.Executo
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadQuicks loads the publicreportImage's Quicks into the .R struct
|
||||
func (o *PublicreportImage) LoadQuicks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.Quicks = nil
|
||||
|
||||
related, err := o.Quicks(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Images = PublicreportImageSlice{o}
|
||||
}
|
||||
|
||||
o.R.Quicks = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadQuicks loads the publicreportImage's Quicks into the .R struct
|
||||
func (os PublicreportImageSlice) LoadQuicks(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(PublicreportQuicks.Columns))
|
||||
}
|
||||
|
||||
q := os.Quicks(append(
|
||||
mods,
|
||||
sm.Columns(PublicreportQuickImages.Columns.ImageID.As("related_publicreport.image.ID")),
|
||||
)...)
|
||||
|
||||
IDSlice := []int32{}
|
||||
|
||||
mapper := scan.Mod(scan.StructMapper[*PublicreportQuick](), 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.image.ID", &IDSlice[len(IDSlice)-1])
|
||||
|
||||
return nil, nil
|
||||
},
|
||||
func(any, any) error {
|
||||
return nil
|
||||
}
|
||||
})
|
||||
|
||||
publicreportQuicks, err := bob.Allx[bob.SliceTransformer[*PublicreportQuick, PublicreportQuickSlice]](ctx, exec, q, mapper)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
o.R.Quicks = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
for i, rel := range publicreportQuicks {
|
||||
if !(o.ID == IDSlice[i]) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.Images = append(rel.R.Images, o)
|
||||
|
||||
o.R.Quicks = append(o.R.Quicks, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ type PublicreportNuisance struct {
|
|||
ReporterName null.Val[string] `db:"reporter_name" `
|
||||
ReporterPhone null.Val[string] `db:"reporter_phone" `
|
||||
Address string `db:"address" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
Status enums.PublicreportReportstatustype `db:"status" `
|
||||
OrganizationID null.Val[int32] `db:"organization_id" `
|
||||
SourceGutter bool `db:"source_gutter" `
|
||||
|
|
@ -62,6 +61,7 @@ type PublicreportNuisance struct {
|
|||
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" `
|
||||
|
||||
R publicreportNuisanceR `db:"-" `
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ type publicreportNuisanceR struct {
|
|||
func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns {
|
||||
return publicreportNuisanceColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "additional_info", "created", "duration", "source_container", "source_description", "source_stagnant", "public_id", "reporter_email", "reporter_name", "reporter_phone", "address", "location", "status", "organization_id", "source_gutter", "h3cell", "address_country", "address_place", "address_postcode", "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",
|
||||
"id", "additional_info", "created", "duration", "source_container", "source_description", "source_stagnant", "public_id", "reporter_email", "reporter_name", "reporter_phone", "address", "status", "organization_id", "source_gutter", "h3cell", "address_country", "address_place", "address_postcode", "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",
|
||||
).WithParent("publicreport.nuisance"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -102,7 +102,6 @@ func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns
|
|||
ReporterName: psql.Quote(alias, "reporter_name"),
|
||||
ReporterPhone: psql.Quote(alias, "reporter_phone"),
|
||||
Address: psql.Quote(alias, "address"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
OrganizationID: psql.Quote(alias, "organization_id"),
|
||||
SourceGutter: psql.Quote(alias, "source_gutter"),
|
||||
|
|
@ -125,6 +124,7 @@ func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns
|
|||
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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,6 @@ type publicreportNuisanceColumns struct {
|
|||
ReporterName psql.Expression
|
||||
ReporterPhone psql.Expression
|
||||
Address psql.Expression
|
||||
Location psql.Expression
|
||||
Status psql.Expression
|
||||
OrganizationID psql.Expression
|
||||
SourceGutter psql.Expression
|
||||
|
|
@ -166,6 +165,7 @@ type publicreportNuisanceColumns struct {
|
|||
LatlngAccuracyType psql.Expression
|
||||
LatlngAccuracyValue psql.Expression
|
||||
ReporterContactConsent psql.Expression
|
||||
Location psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportNuisanceColumns) Alias() string {
|
||||
|
|
@ -192,7 +192,6 @@ type PublicreportNuisanceSetter struct {
|
|||
ReporterName omitnull.Val[string] `db:"reporter_name" `
|
||||
ReporterPhone omitnull.Val[string] `db:"reporter_phone" `
|
||||
Address omit.Val[string] `db:"address" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
OrganizationID omitnull.Val[int32] `db:"organization_id" `
|
||||
SourceGutter omit.Val[bool] `db:"source_gutter" `
|
||||
|
|
@ -215,6 +214,7 @@ type PublicreportNuisanceSetter struct {
|
|||
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" `
|
||||
}
|
||||
|
||||
func (s PublicreportNuisanceSetter) SetColumns() []string {
|
||||
|
|
@ -255,9 +255,6 @@ func (s PublicreportNuisanceSetter) SetColumns() []string {
|
|||
if s.Address.IsValue() {
|
||||
vals = append(vals, "address")
|
||||
}
|
||||
if !s.Location.IsUnset() {
|
||||
vals = append(vals, "location")
|
||||
}
|
||||
if s.Status.IsValue() {
|
||||
vals = append(vals, "status")
|
||||
}
|
||||
|
|
@ -324,6 +321,9 @@ func (s PublicreportNuisanceSetter) SetColumns() []string {
|
|||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals = append(vals, "reporter_contact_consent")
|
||||
}
|
||||
if !s.Location.IsUnset() {
|
||||
vals = append(vals, "location")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -364,9 +364,6 @@ func (s PublicreportNuisanceSetter) Overwrite(t *PublicreportNuisance) {
|
|||
if s.Address.IsValue() {
|
||||
t.Address = s.Address.MustGet()
|
||||
}
|
||||
if !s.Location.IsUnset() {
|
||||
t.Location = s.Location.MustGetNull()
|
||||
}
|
||||
if s.Status.IsValue() {
|
||||
t.Status = s.Status.MustGet()
|
||||
}
|
||||
|
|
@ -433,6 +430,9 @@ func (s PublicreportNuisanceSetter) Overwrite(t *PublicreportNuisance) {
|
|||
if !s.ReporterContactConsent.IsUnset() {
|
||||
t.ReporterContactConsent = s.ReporterContactConsent.MustGetNull()
|
||||
}
|
||||
if !s.Location.IsUnset() {
|
||||
t.Location = s.Location.MustGetNull()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -514,140 +514,140 @@ func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[11] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Location.IsUnset() {
|
||||
vals[12] = psql.Arg(s.Location.MustGetNull())
|
||||
if s.Status.IsValue() {
|
||||
vals[12] = psql.Arg(s.Status.MustGet())
|
||||
} else {
|
||||
vals[12] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
vals[13] = psql.Arg(s.Status.MustGet())
|
||||
if !s.OrganizationID.IsUnset() {
|
||||
vals[13] = psql.Arg(s.OrganizationID.MustGetNull())
|
||||
} else {
|
||||
vals[13] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.OrganizationID.IsUnset() {
|
||||
vals[14] = psql.Arg(s.OrganizationID.MustGetNull())
|
||||
if s.SourceGutter.IsValue() {
|
||||
vals[14] = psql.Arg(s.SourceGutter.MustGet())
|
||||
} else {
|
||||
vals[14] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.SourceGutter.IsValue() {
|
||||
vals[15] = psql.Arg(s.SourceGutter.MustGet())
|
||||
if !s.H3cell.IsUnset() {
|
||||
vals[15] = psql.Arg(s.H3cell.MustGetNull())
|
||||
} else {
|
||||
vals[15] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.H3cell.IsUnset() {
|
||||
vals[16] = psql.Arg(s.H3cell.MustGetNull())
|
||||
if s.AddressCountry.IsValue() {
|
||||
vals[16] = psql.Arg(s.AddressCountry.MustGet())
|
||||
} else {
|
||||
vals[16] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressCountry.IsValue() {
|
||||
vals[17] = psql.Arg(s.AddressCountry.MustGet())
|
||||
if s.AddressPlace.IsValue() {
|
||||
vals[17] = psql.Arg(s.AddressPlace.MustGet())
|
||||
} else {
|
||||
vals[17] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressPlace.IsValue() {
|
||||
vals[18] = psql.Arg(s.AddressPlace.MustGet())
|
||||
if s.AddressPostcode.IsValue() {
|
||||
vals[18] = psql.Arg(s.AddressPostcode.MustGet())
|
||||
} else {
|
||||
vals[18] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressPostcode.IsValue() {
|
||||
vals[19] = psql.Arg(s.AddressPostcode.MustGet())
|
||||
if s.AddressRegion.IsValue() {
|
||||
vals[19] = psql.Arg(s.AddressRegion.MustGet())
|
||||
} else {
|
||||
vals[19] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressRegion.IsValue() {
|
||||
vals[20] = psql.Arg(s.AddressRegion.MustGet())
|
||||
if s.AddressStreet.IsValue() {
|
||||
vals[20] = psql.Arg(s.AddressStreet.MustGet())
|
||||
} else {
|
||||
vals[20] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressStreet.IsValue() {
|
||||
vals[21] = psql.Arg(s.AddressStreet.MustGet())
|
||||
if s.IsLocationBackyard.IsValue() {
|
||||
vals[21] = psql.Arg(s.IsLocationBackyard.MustGet())
|
||||
} else {
|
||||
vals[21] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.IsLocationBackyard.IsValue() {
|
||||
vals[22] = psql.Arg(s.IsLocationBackyard.MustGet())
|
||||
if s.IsLocationFrontyard.IsValue() {
|
||||
vals[22] = psql.Arg(s.IsLocationFrontyard.MustGet())
|
||||
} else {
|
||||
vals[22] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.IsLocationFrontyard.IsValue() {
|
||||
vals[23] = psql.Arg(s.IsLocationFrontyard.MustGet())
|
||||
if s.IsLocationGarden.IsValue() {
|
||||
vals[23] = psql.Arg(s.IsLocationGarden.MustGet())
|
||||
} else {
|
||||
vals[23] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.IsLocationGarden.IsValue() {
|
||||
vals[24] = psql.Arg(s.IsLocationGarden.MustGet())
|
||||
if s.IsLocationOther.IsValue() {
|
||||
vals[24] = psql.Arg(s.IsLocationOther.MustGet())
|
||||
} else {
|
||||
vals[24] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.IsLocationOther.IsValue() {
|
||||
vals[25] = psql.Arg(s.IsLocationOther.MustGet())
|
||||
if s.IsLocationPool.IsValue() {
|
||||
vals[25] = psql.Arg(s.IsLocationPool.MustGet())
|
||||
} else {
|
||||
vals[25] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.IsLocationPool.IsValue() {
|
||||
vals[26] = psql.Arg(s.IsLocationPool.MustGet())
|
||||
if s.MapZoom.IsValue() {
|
||||
vals[26] = psql.Arg(s.MapZoom.MustGet())
|
||||
} else {
|
||||
vals[26] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.MapZoom.IsValue() {
|
||||
vals[27] = psql.Arg(s.MapZoom.MustGet())
|
||||
if s.TodEarly.IsValue() {
|
||||
vals[27] = psql.Arg(s.TodEarly.MustGet())
|
||||
} else {
|
||||
vals[27] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.TodEarly.IsValue() {
|
||||
vals[28] = psql.Arg(s.TodEarly.MustGet())
|
||||
if s.TodDay.IsValue() {
|
||||
vals[28] = psql.Arg(s.TodDay.MustGet())
|
||||
} else {
|
||||
vals[28] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.TodDay.IsValue() {
|
||||
vals[29] = psql.Arg(s.TodDay.MustGet())
|
||||
if s.TodEvening.IsValue() {
|
||||
vals[29] = psql.Arg(s.TodEvening.MustGet())
|
||||
} else {
|
||||
vals[29] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.TodEvening.IsValue() {
|
||||
vals[30] = psql.Arg(s.TodEvening.MustGet())
|
||||
if s.TodNight.IsValue() {
|
||||
vals[30] = psql.Arg(s.TodNight.MustGet())
|
||||
} else {
|
||||
vals[30] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.TodNight.IsValue() {
|
||||
vals[31] = psql.Arg(s.TodNight.MustGet())
|
||||
if s.LatlngAccuracyType.IsValue() {
|
||||
vals[31] = psql.Arg(s.LatlngAccuracyType.MustGet())
|
||||
} else {
|
||||
vals[31] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.LatlngAccuracyType.IsValue() {
|
||||
vals[32] = psql.Arg(s.LatlngAccuracyType.MustGet())
|
||||
if s.LatlngAccuracyValue.IsValue() {
|
||||
vals[32] = psql.Arg(s.LatlngAccuracyValue.MustGet())
|
||||
} else {
|
||||
vals[32] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.LatlngAccuracyValue.IsValue() {
|
||||
vals[33] = psql.Arg(s.LatlngAccuracyValue.MustGet())
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals[33] = psql.Arg(s.ReporterContactConsent.MustGetNull())
|
||||
} else {
|
||||
vals[33] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals[34] = psql.Arg(s.ReporterContactConsent.MustGetNull())
|
||||
if !s.Location.IsUnset() {
|
||||
vals[34] = psql.Arg(s.Location.MustGetNull())
|
||||
} else {
|
||||
vals[34] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
|
@ -747,13 +747,6 @@ func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expressi
|
|||
}})
|
||||
}
|
||||
|
||||
if !s.Location.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "location")...),
|
||||
psql.Arg(s.Location),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "status")...),
|
||||
|
|
@ -908,6 +901,13 @@ func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expressi
|
|||
}})
|
||||
}
|
||||
|
||||
if !s.Location.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "location")...),
|
||||
psql.Arg(s.Location),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
@ -1497,7 +1497,6 @@ type publicreportNuisanceWhere[Q psql.Filterable] struct {
|
|||
ReporterName psql.WhereNullMod[Q, string]
|
||||
ReporterPhone psql.WhereNullMod[Q, string]
|
||||
Address psql.WhereMod[Q, string]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
||||
OrganizationID psql.WhereNullMod[Q, int32]
|
||||
SourceGutter psql.WhereMod[Q, bool]
|
||||
|
|
@ -1520,6 +1519,7 @@ type publicreportNuisanceWhere[Q psql.Filterable] struct {
|
|||
LatlngAccuracyType psql.WhereMod[Q, enums.PublicreportAccuracytype]
|
||||
LatlngAccuracyValue psql.WhereMod[Q, float32]
|
||||
ReporterContactConsent psql.WhereNullMod[Q, bool]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
}
|
||||
|
||||
func (publicreportNuisanceWhere[Q]) AliasedAs(alias string) publicreportNuisanceWhere[Q] {
|
||||
|
|
@ -1540,7 +1540,6 @@ func buildPublicreportNuisanceWhere[Q psql.Filterable](cols publicreportNuisance
|
|||
ReporterName: psql.WhereNull[Q, string](cols.ReporterName),
|
||||
ReporterPhone: psql.WhereNull[Q, string](cols.ReporterPhone),
|
||||
Address: psql.Where[Q, string](cols.Address),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
OrganizationID: psql.WhereNull[Q, int32](cols.OrganizationID),
|
||||
SourceGutter: psql.Where[Q, bool](cols.SourceGutter),
|
||||
|
|
@ -1563,6 +1562,7 @@ func buildPublicreportNuisanceWhere[Q psql.Filterable](cols publicreportNuisance
|
|||
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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ type PublicreportPool struct {
|
|||
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" `
|
||||
|
|
@ -61,6 +60,7 @@ type PublicreportPool struct {
|
|||
IsReporterConfidential bool `db:"is_reporter_confidential" `
|
||||
IsReporterOwner bool `db:"is_reporter_owner" `
|
||||
ReporterContactConsent null.Val[bool] `db:"reporter_contact_consent" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
|
||||
R publicreportPoolR `db:"-" `
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ type publicreportPoolR struct {
|
|||
func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
|
||||
return publicreportPoolColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"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", "reporter_contact_consent",
|
||||
"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", "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", "reporter_contact_consent", "location",
|
||||
).WithParent("publicreport.pool"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -108,7 +108,6 @@ func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
|
|||
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"),
|
||||
|
|
@ -123,6 +122,7 @@ func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
|
|||
IsReporterConfidential: psql.Quote(alias, "is_reporter_confidential"),
|
||||
IsReporterOwner: psql.Quote(alias, "is_reporter_owner"),
|
||||
ReporterContactConsent: psql.Quote(alias, "reporter_contact_consent"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,6 @@ type publicreportPoolColumns struct {
|
|||
HasAdult psql.Expression
|
||||
HasLarvae psql.Expression
|
||||
HasPupae psql.Expression
|
||||
Location psql.Expression
|
||||
MapZoom psql.Expression
|
||||
OwnerEmail psql.Expression
|
||||
OwnerName psql.Expression
|
||||
|
|
@ -163,6 +162,7 @@ type publicreportPoolColumns struct {
|
|||
IsReporterConfidential psql.Expression
|
||||
IsReporterOwner psql.Expression
|
||||
ReporterContactConsent psql.Expression
|
||||
Location psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportPoolColumns) Alias() string {
|
||||
|
|
@ -196,7 +196,6 @@ type PublicreportPoolSetter struct {
|
|||
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" `
|
||||
|
|
@ -211,6 +210,7 @@ type PublicreportPoolSetter struct {
|
|||
IsReporterConfidential omit.Val[bool] `db:"is_reporter_confidential" `
|
||||
IsReporterOwner omit.Val[bool] `db:"is_reporter_owner" `
|
||||
ReporterContactConsent omitnull.Val[bool] `db:"reporter_contact_consent" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
}
|
||||
|
||||
func (s PublicreportPoolSetter) SetColumns() []string {
|
||||
|
|
@ -272,9 +272,6 @@ func (s PublicreportPoolSetter) SetColumns() []string {
|
|||
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")
|
||||
}
|
||||
|
|
@ -317,6 +314,9 @@ func (s PublicreportPoolSetter) SetColumns() []string {
|
|||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals = append(vals, "reporter_contact_consent")
|
||||
}
|
||||
if !s.Location.IsUnset() {
|
||||
vals = append(vals, "location")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -378,9 +378,6 @@ func (s PublicreportPoolSetter) Overwrite(t *PublicreportPool) {
|
|||
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()
|
||||
}
|
||||
|
|
@ -423,6 +420,9 @@ func (s PublicreportPoolSetter) Overwrite(t *PublicreportPool) {
|
|||
if !s.ReporterContactConsent.IsUnset() {
|
||||
t.ReporterContactConsent = s.ReporterContactConsent.MustGetNull()
|
||||
}
|
||||
if !s.Location.IsUnset() {
|
||||
t.Location = s.Location.MustGetNull()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -546,92 +546,92 @@ func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[18] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Location.IsUnset() {
|
||||
vals[19] = psql.Arg(s.Location.MustGetNull())
|
||||
if s.MapZoom.IsValue() {
|
||||
vals[19] = psql.Arg(s.MapZoom.MustGet())
|
||||
} else {
|
||||
vals[19] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.MapZoom.IsValue() {
|
||||
vals[20] = psql.Arg(s.MapZoom.MustGet())
|
||||
if s.OwnerEmail.IsValue() {
|
||||
vals[20] = psql.Arg(s.OwnerEmail.MustGet())
|
||||
} else {
|
||||
vals[20] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.OwnerEmail.IsValue() {
|
||||
vals[21] = psql.Arg(s.OwnerEmail.MustGet())
|
||||
if s.OwnerName.IsValue() {
|
||||
vals[21] = psql.Arg(s.OwnerName.MustGet())
|
||||
} else {
|
||||
vals[21] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.OwnerName.IsValue() {
|
||||
vals[22] = psql.Arg(s.OwnerName.MustGet())
|
||||
if s.OwnerPhone.IsValue() {
|
||||
vals[22] = psql.Arg(s.OwnerPhone.MustGet())
|
||||
} else {
|
||||
vals[22] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.OwnerPhone.IsValue() {
|
||||
vals[23] = psql.Arg(s.OwnerPhone.MustGet())
|
||||
if s.PublicID.IsValue() {
|
||||
vals[23] = psql.Arg(s.PublicID.MustGet())
|
||||
} else {
|
||||
vals[23] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.PublicID.IsValue() {
|
||||
vals[24] = psql.Arg(s.PublicID.MustGet())
|
||||
if s.ReporterEmail.IsValue() {
|
||||
vals[24] = psql.Arg(s.ReporterEmail.MustGet())
|
||||
} else {
|
||||
vals[24] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterEmail.IsValue() {
|
||||
vals[25] = psql.Arg(s.ReporterEmail.MustGet())
|
||||
if s.ReporterName.IsValue() {
|
||||
vals[25] = psql.Arg(s.ReporterName.MustGet())
|
||||
} else {
|
||||
vals[25] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterName.IsValue() {
|
||||
vals[26] = psql.Arg(s.ReporterName.MustGet())
|
||||
if s.ReporterPhone.IsValue() {
|
||||
vals[26] = psql.Arg(s.ReporterPhone.MustGet())
|
||||
} else {
|
||||
vals[26] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterPhone.IsValue() {
|
||||
vals[27] = psql.Arg(s.ReporterPhone.MustGet())
|
||||
if s.Status.IsValue() {
|
||||
vals[27] = psql.Arg(s.Status.MustGet())
|
||||
} else {
|
||||
vals[27] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
vals[28] = psql.Arg(s.Status.MustGet())
|
||||
if !s.OrganizationID.IsUnset() {
|
||||
vals[28] = psql.Arg(s.OrganizationID.MustGetNull())
|
||||
} else {
|
||||
vals[28] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.OrganizationID.IsUnset() {
|
||||
vals[29] = psql.Arg(s.OrganizationID.MustGetNull())
|
||||
if s.HasBackyardPermission.IsValue() {
|
||||
vals[29] = psql.Arg(s.HasBackyardPermission.MustGet())
|
||||
} else {
|
||||
vals[29] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.HasBackyardPermission.IsValue() {
|
||||
vals[30] = psql.Arg(s.HasBackyardPermission.MustGet())
|
||||
if s.IsReporterConfidential.IsValue() {
|
||||
vals[30] = psql.Arg(s.IsReporterConfidential.MustGet())
|
||||
} else {
|
||||
vals[30] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.IsReporterConfidential.IsValue() {
|
||||
vals[31] = psql.Arg(s.IsReporterConfidential.MustGet())
|
||||
if s.IsReporterOwner.IsValue() {
|
||||
vals[31] = psql.Arg(s.IsReporterOwner.MustGet())
|
||||
} else {
|
||||
vals[31] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.IsReporterOwner.IsValue() {
|
||||
vals[32] = psql.Arg(s.IsReporterOwner.MustGet())
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals[32] = psql.Arg(s.ReporterContactConsent.MustGetNull())
|
||||
} else {
|
||||
vals[32] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals[33] = psql.Arg(s.ReporterContactConsent.MustGetNull())
|
||||
if !s.Location.IsUnset() {
|
||||
vals[33] = psql.Arg(s.Location.MustGetNull())
|
||||
} else {
|
||||
vals[33] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
|
@ -780,13 +780,6 @@ func (s PublicreportPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
|||
}})
|
||||
}
|
||||
|
||||
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")...),
|
||||
|
|
@ -885,6 +878,13 @@ func (s PublicreportPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
|||
}})
|
||||
}
|
||||
|
||||
if !s.Location.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "location")...),
|
||||
psql.Arg(s.Location),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
@ -1481,7 +1481,6 @@ type publicreportPoolWhere[Q psql.Filterable] struct {
|
|||
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]
|
||||
|
|
@ -1496,6 +1495,7 @@ type publicreportPoolWhere[Q psql.Filterable] struct {
|
|||
IsReporterConfidential psql.WhereMod[Q, bool]
|
||||
IsReporterOwner psql.WhereMod[Q, bool]
|
||||
ReporterContactConsent psql.WhereNullMod[Q, bool]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
}
|
||||
|
||||
func (publicreportPoolWhere[Q]) AliasedAs(alias string) publicreportPoolWhere[Q] {
|
||||
|
|
@ -1523,7 +1523,6 @@ func buildPublicreportPoolWhere[Q psql.Filterable](cols publicreportPoolColumns)
|
|||
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),
|
||||
|
|
@ -1538,6 +1537,7 @@ func buildPublicreportPoolWhere[Q psql.Filterable](cols publicreportPoolColumns)
|
|||
IsReporterConfidential: psql.Where[Q, bool](cols.IsReporterConfidential),
|
||||
IsReporterOwner: psql.Where[Q, bool](cols.IsReporterOwner),
|
||||
ReporterContactConsent: psql.WhereNull[Q, bool](cols.ReporterContactConsent),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,721 +0,0 @@
|
|||
// 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"
|
||||
|
||||
"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"
|
||||
"github.com/aarondl/opt/omit"
|
||||
)
|
||||
|
||||
// PublicreportQuickImage is an object representing the database table.
|
||||
type PublicreportQuickImage struct {
|
||||
ImageID int32 `db:"image_id,pk" `
|
||||
QuickID int32 `db:"quick_id,pk" `
|
||||
|
||||
R publicreportQuickImageR `db:"-" `
|
||||
}
|
||||
|
||||
// PublicreportQuickImageSlice is an alias for a slice of pointers to PublicreportQuickImage.
|
||||
// This should almost always be used instead of []*PublicreportQuickImage.
|
||||
type PublicreportQuickImageSlice []*PublicreportQuickImage
|
||||
|
||||
// PublicreportQuickImages contains methods to work with the quick_image table
|
||||
var PublicreportQuickImages = psql.NewTablex[*PublicreportQuickImage, PublicreportQuickImageSlice, *PublicreportQuickImageSetter]("publicreport", "quick_image", buildPublicreportQuickImageColumns("publicreport.quick_image"))
|
||||
|
||||
// PublicreportQuickImagesQuery is a query on the quick_image table
|
||||
type PublicreportQuickImagesQuery = *psql.ViewQuery[*PublicreportQuickImage, PublicreportQuickImageSlice]
|
||||
|
||||
// publicreportQuickImageR is where relationships are stored.
|
||||
type publicreportQuickImageR struct {
|
||||
Image *PublicreportImage // publicreport.quick_image.quick_image_image_id_fkey
|
||||
Quick *PublicreportQuick // publicreport.quick_image.quick_image_quick_id_fkey
|
||||
}
|
||||
|
||||
func buildPublicreportQuickImageColumns(alias string) publicreportQuickImageColumns {
|
||||
return publicreportQuickImageColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"image_id", "quick_id",
|
||||
).WithParent("publicreport.quick_image"),
|
||||
tableAlias: alias,
|
||||
ImageID: psql.Quote(alias, "image_id"),
|
||||
QuickID: psql.Quote(alias, "quick_id"),
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickImageColumns struct {
|
||||
expr.ColumnsExpr
|
||||
tableAlias string
|
||||
ImageID psql.Expression
|
||||
QuickID psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportQuickImageColumns) Alias() string {
|
||||
return c.tableAlias
|
||||
}
|
||||
|
||||
func (publicreportQuickImageColumns) AliasedAs(alias string) publicreportQuickImageColumns {
|
||||
return buildPublicreportQuickImageColumns(alias)
|
||||
}
|
||||
|
||||
// PublicreportQuickImageSetter is used for insert/upsert/update operations
|
||||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type PublicreportQuickImageSetter struct {
|
||||
ImageID omit.Val[int32] `db:"image_id,pk" `
|
||||
QuickID omit.Val[int32] `db:"quick_id,pk" `
|
||||
}
|
||||
|
||||
func (s PublicreportQuickImageSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 2)
|
||||
if s.ImageID.IsValue() {
|
||||
vals = append(vals, "image_id")
|
||||
}
|
||||
if s.QuickID.IsValue() {
|
||||
vals = append(vals, "quick_id")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
func (s PublicreportQuickImageSetter) Overwrite(t *PublicreportQuickImage) {
|
||||
if s.ImageID.IsValue() {
|
||||
t.ImageID = s.ImageID.MustGet()
|
||||
}
|
||||
if s.QuickID.IsValue() {
|
||||
t.QuickID = s.QuickID.MustGet()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportQuickImageSetter) Apply(q *dialect.InsertQuery) {
|
||||
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
||||
return PublicreportQuickImages.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, 2)
|
||||
if s.ImageID.IsValue() {
|
||||
vals[0] = psql.Arg(s.ImageID.MustGet())
|
||||
} else {
|
||||
vals[0] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.QuickID.IsValue() {
|
||||
vals[1] = psql.Arg(s.QuickID.MustGet())
|
||||
} else {
|
||||
vals[1] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
||||
func (s PublicreportQuickImageSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
||||
return um.Set(s.Expressions()...)
|
||||
}
|
||||
|
||||
func (s PublicreportQuickImageSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 2)
|
||||
|
||||
if s.ImageID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "image_id")...),
|
||||
psql.Arg(s.ImageID),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.QuickID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "quick_id")...),
|
||||
psql.Arg(s.QuickID),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
// FindPublicreportQuickImage retrieves a single record by primary key
|
||||
// If cols is empty Find will return all columns.
|
||||
func FindPublicreportQuickImage(ctx context.Context, exec bob.Executor, ImageIDPK int32, QuickIDPK int32, cols ...string) (*PublicreportQuickImage, error) {
|
||||
if len(cols) == 0 {
|
||||
return PublicreportQuickImages.Query(
|
||||
sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
|
||||
sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(QuickIDPK))),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
return PublicreportQuickImages.Query(
|
||||
sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
|
||||
sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(QuickIDPK))),
|
||||
sm.Columns(PublicreportQuickImages.Columns.Only(cols...)),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
// PublicreportQuickImageExists checks the presence of a single record by primary key
|
||||
func PublicreportQuickImageExists(ctx context.Context, exec bob.Executor, ImageIDPK int32, QuickIDPK int32) (bool, error) {
|
||||
return PublicreportQuickImages.Query(
|
||||
sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
|
||||
sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(QuickIDPK))),
|
||||
).Exists(ctx, exec)
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportQuickImage is retrieved from the database
|
||||
func (o *PublicreportQuickImage) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportQuickImages.AfterSelectHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
|
||||
case bob.QueryTypeInsert:
|
||||
ctx, err = PublicreportQuickImages.AfterInsertHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
|
||||
case bob.QueryTypeUpdate:
|
||||
ctx, err = PublicreportQuickImages.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
|
||||
case bob.QueryTypeDelete:
|
||||
ctx, err = PublicreportQuickImages.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// primaryKeyVals returns the primary key values of the PublicreportQuickImage
|
||||
func (o *PublicreportQuickImage) primaryKeyVals() bob.Expression {
|
||||
return psql.ArgGroup(
|
||||
o.ImageID,
|
||||
o.QuickID,
|
||||
)
|
||||
}
|
||||
|
||||
func (o *PublicreportQuickImage) pkEQ() dialect.Expression {
|
||||
return psql.Group(psql.Quote("publicreport.quick_image", "image_id"), psql.Quote("publicreport.quick_image", "quick_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 PublicreportQuickImage
|
||||
func (o *PublicreportQuickImage) Update(ctx context.Context, exec bob.Executor, s *PublicreportQuickImageSetter) error {
|
||||
v, err := PublicreportQuickImages.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 PublicreportQuickImage record with an executor
|
||||
func (o *PublicreportQuickImage) Delete(ctx context.Context, exec bob.Executor) error {
|
||||
_, err := PublicreportQuickImages.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
||||
return err
|
||||
}
|
||||
|
||||
// Reload refreshes the PublicreportQuickImage using the executor
|
||||
func (o *PublicreportQuickImage) Reload(ctx context.Context, exec bob.Executor) error {
|
||||
o2, err := PublicreportQuickImages.Query(
|
||||
sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(o.ImageID))),
|
||||
sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(o.QuickID))),
|
||||
).One(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o2.R = o.R
|
||||
*o = *o2
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportQuickImageSlice is retrieved from the database
|
||||
func (o PublicreportQuickImageSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportQuickImages.AfterSelectHooks.RunHooks(ctx, exec, o)
|
||||
case bob.QueryTypeInsert:
|
||||
ctx, err = PublicreportQuickImages.AfterInsertHooks.RunHooks(ctx, exec, o)
|
||||
case bob.QueryTypeUpdate:
|
||||
ctx, err = PublicreportQuickImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
||||
case bob.QueryTypeDelete:
|
||||
ctx, err = PublicreportQuickImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (o PublicreportQuickImageSlice) pkIN() dialect.Expression {
|
||||
if len(o) == 0 {
|
||||
return psql.Raw("NULL")
|
||||
}
|
||||
|
||||
return psql.Group(psql.Quote("publicreport.quick_image", "image_id"), psql.Quote("publicreport.quick_image", "quick_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 PublicreportQuickImageSlice) copyMatchingRows(from ...*PublicreportQuickImage) {
|
||||
for i, old := range o {
|
||||
for _, new := range from {
|
||||
if new.ImageID != old.ImageID {
|
||||
continue
|
||||
}
|
||||
if new.QuickID != old.QuickID {
|
||||
continue
|
||||
}
|
||||
new.R = old.R
|
||||
o[i] = new
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
|
||||
func (o PublicreportQuickImageSlice) 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 PublicreportQuickImages.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 *PublicreportQuickImage:
|
||||
o.copyMatchingRows(retrieved)
|
||||
case []*PublicreportQuickImage:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
case PublicreportQuickImageSlice:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
default:
|
||||
// If the retrieved value is not a PublicreportQuickImage or a slice of PublicreportQuickImage
|
||||
// then run the AfterUpdateHooks on the slice
|
||||
_, err = PublicreportQuickImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}))
|
||||
|
||||
q.AppendWhere(o.pkIN())
|
||||
})
|
||||
}
|
||||
|
||||
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
||||
func (o PublicreportQuickImageSlice) 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 PublicreportQuickImages.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 *PublicreportQuickImage:
|
||||
o.copyMatchingRows(retrieved)
|
||||
case []*PublicreportQuickImage:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
case PublicreportQuickImageSlice:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
default:
|
||||
// If the retrieved value is not a PublicreportQuickImage or a slice of PublicreportQuickImage
|
||||
// then run the AfterDeleteHooks on the slice
|
||||
_, err = PublicreportQuickImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}))
|
||||
|
||||
q.AppendWhere(o.pkIN())
|
||||
})
|
||||
}
|
||||
|
||||
func (o PublicreportQuickImageSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportQuickImageSetter) error {
|
||||
if len(o) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := PublicreportQuickImages.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
||||
return err
|
||||
}
|
||||
|
||||
func (o PublicreportQuickImageSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
||||
if len(o) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := PublicreportQuickImages.Delete(o.DeleteMod()).Exec(ctx, exec)
|
||||
return err
|
||||
}
|
||||
|
||||
func (o PublicreportQuickImageSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
||||
if len(o) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
o2, err := PublicreportQuickImages.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.copyMatchingRows(o2...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Image starts a query for related objects on publicreport.image
|
||||
func (o *PublicreportQuickImage) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
||||
return PublicreportImages.Query(append(mods,
|
||||
sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(o.ImageID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os PublicreportQuickImageSlice) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
|
||||
pkImageID := make(pgtypes.Array[int32], 0, len(os))
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
pkImageID = append(pkImageID, o.ImageID)
|
||||
}
|
||||
PKArgExpr := psql.Select(sm.Columns(
|
||||
psql.F("unnest", psql.Cast(psql.Arg(pkImageID), "integer[]")),
|
||||
))
|
||||
|
||||
return PublicreportImages.Query(append(mods,
|
||||
sm.Where(psql.Group(PublicreportImages.Columns.ID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// Quick starts a query for related objects on publicreport.quick
|
||||
func (o *PublicreportQuickImage) Quick(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
|
||||
return PublicreportQuicks.Query(append(mods,
|
||||
sm.Where(PublicreportQuicks.Columns.ID.EQ(psql.Arg(o.QuickID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os PublicreportQuickImageSlice) Quick(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
|
||||
pkQuickID := make(pgtypes.Array[int32], 0, len(os))
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
pkQuickID = append(pkQuickID, o.QuickID)
|
||||
}
|
||||
PKArgExpr := psql.Select(sm.Columns(
|
||||
psql.F("unnest", psql.Cast(psql.Arg(pkQuickID), "integer[]")),
|
||||
))
|
||||
|
||||
return PublicreportQuicks.Query(append(mods,
|
||||
sm.Where(psql.Group(PublicreportQuicks.Columns.ID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
func attachPublicreportQuickImageImage0(ctx context.Context, exec bob.Executor, count int, publicreportQuickImage0 *PublicreportQuickImage, publicreportImage1 *PublicreportImage) (*PublicreportQuickImage, error) {
|
||||
setter := &PublicreportQuickImageSetter{
|
||||
ImageID: omit.From(publicreportImage1.ID),
|
||||
}
|
||||
|
||||
err := publicreportQuickImage0.Update(ctx, exec, setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachPublicreportQuickImageImage0: %w", err)
|
||||
}
|
||||
|
||||
return publicreportQuickImage0, nil
|
||||
}
|
||||
|
||||
func (publicreportQuickImage0 *PublicreportQuickImage) InsertImage(ctx context.Context, exec bob.Executor, related *PublicreportImageSetter) error {
|
||||
var err error
|
||||
|
||||
publicreportImage1, err := PublicreportImages.Insert(related).One(ctx, exec)
|
||||
if err != nil {
|
||||
return fmt.Errorf("inserting related objects: %w", err)
|
||||
}
|
||||
|
||||
_, err = attachPublicreportQuickImageImage0(ctx, exec, 1, publicreportQuickImage0, publicreportImage1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportQuickImage0.R.Image = publicreportImage1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (publicreportQuickImage0 *PublicreportQuickImage) AttachImage(ctx context.Context, exec bob.Executor, publicreportImage1 *PublicreportImage) error {
|
||||
var err error
|
||||
|
||||
_, err = attachPublicreportQuickImageImage0(ctx, exec, 1, publicreportQuickImage0, publicreportImage1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportQuickImage0.R.Image = publicreportImage1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func attachPublicreportQuickImageQuick0(ctx context.Context, exec bob.Executor, count int, publicreportQuickImage0 *PublicreportQuickImage, publicreportQuick1 *PublicreportQuick) (*PublicreportQuickImage, error) {
|
||||
setter := &PublicreportQuickImageSetter{
|
||||
QuickID: omit.From(publicreportQuick1.ID),
|
||||
}
|
||||
|
||||
err := publicreportQuickImage0.Update(ctx, exec, setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachPublicreportQuickImageQuick0: %w", err)
|
||||
}
|
||||
|
||||
return publicreportQuickImage0, nil
|
||||
}
|
||||
|
||||
func (publicreportQuickImage0 *PublicreportQuickImage) InsertQuick(ctx context.Context, exec bob.Executor, related *PublicreportQuickSetter) error {
|
||||
var err error
|
||||
|
||||
publicreportQuick1, err := PublicreportQuicks.Insert(related).One(ctx, exec)
|
||||
if err != nil {
|
||||
return fmt.Errorf("inserting related objects: %w", err)
|
||||
}
|
||||
|
||||
_, err = attachPublicreportQuickImageQuick0(ctx, exec, 1, publicreportQuickImage0, publicreportQuick1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportQuickImage0.R.Quick = publicreportQuick1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (publicreportQuickImage0 *PublicreportQuickImage) AttachQuick(ctx context.Context, exec bob.Executor, publicreportQuick1 *PublicreportQuick) error {
|
||||
var err error
|
||||
|
||||
_, err = attachPublicreportQuickImageQuick0(ctx, exec, 1, publicreportQuickImage0, publicreportQuick1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportQuickImage0.R.Quick = publicreportQuick1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type publicreportQuickImageWhere[Q psql.Filterable] struct {
|
||||
ImageID psql.WhereMod[Q, int32]
|
||||
QuickID psql.WhereMod[Q, int32]
|
||||
}
|
||||
|
||||
func (publicreportQuickImageWhere[Q]) AliasedAs(alias string) publicreportQuickImageWhere[Q] {
|
||||
return buildPublicreportQuickImageWhere[Q](buildPublicreportQuickImageColumns(alias))
|
||||
}
|
||||
|
||||
func buildPublicreportQuickImageWhere[Q psql.Filterable](cols publicreportQuickImageColumns) publicreportQuickImageWhere[Q] {
|
||||
return publicreportQuickImageWhere[Q]{
|
||||
ImageID: psql.Where[Q, int32](cols.ImageID),
|
||||
QuickID: psql.Where[Q, int32](cols.QuickID),
|
||||
}
|
||||
}
|
||||
|
||||
func (o *PublicreportQuickImage) Preload(name string, retrieved any) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch name {
|
||||
case "Image":
|
||||
rel, ok := retrieved.(*PublicreportImage)
|
||||
if !ok {
|
||||
return fmt.Errorf("publicreportQuickImage cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Image = rel
|
||||
|
||||
return nil
|
||||
case "Quick":
|
||||
rel, ok := retrieved.(*PublicreportQuick)
|
||||
if !ok {
|
||||
return fmt.Errorf("publicreportQuickImage cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Quick = rel
|
||||
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("publicreportQuickImage has no relationship %q", name)
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickImagePreloader struct {
|
||||
Image func(...psql.PreloadOption) psql.Preloader
|
||||
Quick func(...psql.PreloadOption) psql.Preloader
|
||||
}
|
||||
|
||||
func buildPublicreportQuickImagePreloader() publicreportQuickImagePreloader {
|
||||
return publicreportQuickImagePreloader{
|
||||
Image: func(opts ...psql.PreloadOption) psql.Preloader {
|
||||
return psql.Preload[*PublicreportImage, PublicreportImageSlice](psql.PreloadRel{
|
||||
Name: "Image",
|
||||
Sides: []psql.PreloadSide{
|
||||
{
|
||||
From: PublicreportQuickImages,
|
||||
To: PublicreportImages,
|
||||
FromColumns: []string{"image_id"},
|
||||
ToColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
}, PublicreportImages.Columns.Names(), opts...)
|
||||
},
|
||||
Quick: func(opts ...psql.PreloadOption) psql.Preloader {
|
||||
return psql.Preload[*PublicreportQuick, PublicreportQuickSlice](psql.PreloadRel{
|
||||
Name: "Quick",
|
||||
Sides: []psql.PreloadSide{
|
||||
{
|
||||
From: PublicreportQuickImages,
|
||||
To: PublicreportQuicks,
|
||||
FromColumns: []string{"quick_id"},
|
||||
ToColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
}, PublicreportQuicks.Columns.Names(), opts...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportQuickImageThenLoader[Q orm.Loadable] struct {
|
||||
Image func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Quick func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildPublicreportQuickImageThenLoader[Q orm.Loadable]() publicreportQuickImageThenLoader[Q] {
|
||||
type ImageLoadInterface interface {
|
||||
LoadImage(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type QuickLoadInterface interface {
|
||||
LoadQuick(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
||||
return publicreportQuickImageThenLoader[Q]{
|
||||
Image: thenLoadBuilder[Q](
|
||||
"Image",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ImageLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadImage(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
Quick: thenLoadBuilder[Q](
|
||||
"Quick",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved QuickLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadQuick(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// LoadImage loads the publicreportQuickImage's Image into the .R struct
|
||||
func (o *PublicreportQuickImage) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.Image = nil
|
||||
|
||||
related, err := o.Image(mods...).One(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.R.Image = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadImage loads the publicreportQuickImage's Image into the .R struct
|
||||
func (os PublicreportQuickImageSlice) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
publicreportImages, err := os.Image(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range publicreportImages {
|
||||
|
||||
if !(o.ImageID == rel.ID) {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.Image = rel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadQuick loads the publicreportQuickImage's Quick into the .R struct
|
||||
func (o *PublicreportQuickImage) LoadQuick(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.Quick = nil
|
||||
|
||||
related, err := o.Quick(mods...).One(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.R.Quick = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadQuick loads the publicreportQuickImage's Quick into the .R struct
|
||||
func (os PublicreportQuickImageSlice) LoadQuick(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
publicreportQuicks, err := os.Quick(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range publicreportQuicks {
|
||||
|
||||
if !(o.QuickID == rel.ID) {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.Quick = rel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
// 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 sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"io"
|
||||
"iter"
|
||||
"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/orm"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stephenafamo/scan"
|
||||
)
|
||||
|
||||
//go:embed publicreport_image_with_json_by_quick_id.bob.sql
|
||||
var formattedQueries_publicreport_image_with_json_by_quick_id string
|
||||
|
||||
var publicreportImageWithJSONByQuickIDSQL = formattedQueries_publicreport_image_with_json_by_quick_id[172:965]
|
||||
|
||||
type PublicreportImageWithJSONByQuickIDQuery = orm.ModQuery[*dialect.SelectQuery, publicreportImageWithJSONByQuickID, PublicreportImageWithJSONByQuickIDRow, []PublicreportImageWithJSONByQuickIDRow, publicreportImageWithJSONByQuickIDTransformer]
|
||||
|
||||
func PublicreportImageWithJSONByQuickID(QuickID int32) *PublicreportImageWithJSONByQuickIDQuery {
|
||||
var expressionTypArgs publicreportImageWithJSONByQuickID
|
||||
|
||||
expressionTypArgs.QuickID = psql.Arg(QuickID)
|
||||
|
||||
return &PublicreportImageWithJSONByQuickIDQuery{
|
||||
Query: orm.Query[publicreportImageWithJSONByQuickID, PublicreportImageWithJSONByQuickIDRow, []PublicreportImageWithJSONByQuickIDRow, publicreportImageWithJSONByQuickIDTransformer]{
|
||||
ExecQuery: orm.ExecQuery[publicreportImageWithJSONByQuickID]{
|
||||
BaseQuery: bob.BaseQuery[publicreportImageWithJSONByQuickID]{
|
||||
Expression: expressionTypArgs,
|
||||
Dialect: dialect.Dialect,
|
||||
QueryType: bob.QueryTypeSelect,
|
||||
},
|
||||
},
|
||||
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (PublicreportImageWithJSONByQuickIDRow, error)) {
|
||||
return func(row *scan.Row) (any, error) {
|
||||
var t PublicreportImageWithJSONByQuickIDRow
|
||||
row.ScheduleScanByIndex(0, &t.ID)
|
||||
row.ScheduleScanByIndex(1, &t.ContentType)
|
||||
row.ScheduleScanByIndex(2, &t.Created)
|
||||
row.ScheduleScanByIndex(3, &t.Location)
|
||||
row.ScheduleScanByIndex(4, &t.LocationJSON)
|
||||
row.ScheduleScanByIndex(5, &t.ResolutionX)
|
||||
row.ScheduleScanByIndex(6, &t.ResolutionY)
|
||||
row.ScheduleScanByIndex(7, &t.StorageUUID)
|
||||
row.ScheduleScanByIndex(8, &t.StorageSize)
|
||||
row.ScheduleScanByIndex(9, &t.UploadedFilename)
|
||||
return &t, nil
|
||||
}, func(v any) (PublicreportImageWithJSONByQuickIDRow, error) {
|
||||
return *(v.(*PublicreportImageWithJSONByQuickIDRow)), nil
|
||||
}
|
||||
},
|
||||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendSelect(expressionTypArgs.subExpr(9, 549))
|
||||
q.SetTable(expressionTypArgs.subExpr(555, 742))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(750, 792))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type PublicreportImageWithJSONByQuickIDRow = struct {
|
||||
ID int32 `db:"id"`
|
||||
ContentType string `db:"content_type"`
|
||||
Created time.Time `db:"created"`
|
||||
Location null.Val[string] `db:"location"`
|
||||
LocationJSON string `db:"location_json"`
|
||||
ResolutionX int32 `db:"resolution_x"`
|
||||
ResolutionY int32 `db:"resolution_y"`
|
||||
StorageUUID uuid.UUID `db:"storage_uuid"`
|
||||
StorageSize int64 `db:"storage_size"`
|
||||
UploadedFilename string `db:"uploaded_filename"`
|
||||
}
|
||||
|
||||
type publicreportImageWithJSONByQuickIDTransformer = bob.SliceTransformer[PublicreportImageWithJSONByQuickIDRow, []PublicreportImageWithJSONByQuickIDRow]
|
||||
|
||||
type publicreportImageWithJSONByQuickID struct {
|
||||
QuickID bob.Expression
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByQuickID) args() iter.Seq[orm.ArgWithPosition] {
|
||||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "quickID",
|
||||
Start: 790,
|
||||
Stop: 792,
|
||||
Expression: o.QuickID,
|
||||
}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByQuickID) raw(from, to int) string {
|
||||
return publicreportImageWithJSONByQuickIDSQL[from:to]
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByQuickID) subExpr(from, to int) bob.Expression {
|
||||
return orm.ArgsToExpression(publicreportImageWithJSONByQuickIDSQL, from, to, o.args())
|
||||
}
|
||||
|
||||
func (o publicreportImageWithJSONByQuickID) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
return o.subExpr(0, len(publicreportImageWithJSONByQuickIDSQL)).WriteSQL(ctx, w, d, start)
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
-- 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.
|
||||
|
||||
-- PublicreportImageWithJSONByQuickID
|
||||
SELECT
|
||||
"publicreport.image"."id" AS "id",
|
||||
"publicreport.image"."content_type" AS "content_type",
|
||||
"publicreport.image"."created" AS "created",
|
||||
"publicreport.image"."location" AS "location",
|
||||
ST_AsGeoJSON("publicreport.image"."location") AS "location_json",
|
||||
"publicreport.image"."resolution_x" AS "resolution_x",
|
||||
"publicreport.image"."resolution_y" AS "resolution_y",
|
||||
"publicreport.image"."storage_uuid" AS "storage_uuid",
|
||||
"publicreport.image"."storage_size" AS "storage_size",
|
||||
"publicreport.image"."uploaded_filename" AS "uploaded_filename"
|
||||
FROM "publicreport"."image" AS "publicreport.image"
|
||||
INNER JOIN "publicreport"."quick_image" AS "publicreport.quick_image" ON ("publicreport.image"."id" = "publicreport.quick_image"."image_id")
|
||||
WHERE ("publicreport.quick_image"."quick_id" = $1);
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
-- PublicreportImageWithJSONByQuickID
|
||||
SELECT
|
||||
"publicreport.image"."id" AS "id",
|
||||
"publicreport.image"."content_type" AS "content_type",
|
||||
"publicreport.image"."created" AS "created",
|
||||
"publicreport.image"."location" AS "location",
|
||||
ST_AsGeoJSON("publicreport.image"."location") AS "location_json",
|
||||
"publicreport.image"."resolution_x" AS "resolution_x",
|
||||
"publicreport.image"."resolution_y" AS "resolution_y",
|
||||
"publicreport.image"."storage_uuid" AS "storage_uuid",
|
||||
"publicreport.image"."storage_size" AS "storage_size",
|
||||
"publicreport.image"."uploaded_filename" AS "uploaded_filename"
|
||||
FROM "publicreport"."image" AS "publicreport.image"
|
||||
INNER JOIN "publicreport"."quick_image" AS "publicreport.quick_image" ON ("publicreport.image"."id" = "publicreport.quick_image"."image_id")
|
||||
WHERE ("publicreport.quick_image"."quick_id" = $1)
|
||||
|
|
@ -20,7 +20,7 @@ import (
|
|||
//go:embed publicreport_publicid_table.bob.sql
|
||||
var formattedQueries_publicreport_publicid_table string
|
||||
|
||||
var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[157:638]
|
||||
var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[157:534]
|
||||
|
||||
type PublicreportIDTableQuery = orm.ModQuery[*dialect.SelectQuery, publicreportIDTable, PublicreportIDTableRow, []PublicreportIDTableRow, publicreportIDTableTransformer]
|
||||
|
||||
|
|
@ -51,9 +51,9 @@ func PublicreportIDTable(PublicID string) *PublicreportIDTableQuery {
|
|||
},
|
||||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendCTE(expressionTypArgs.subExpr(5, 325))
|
||||
q.AppendSelect(expressionTypArgs.subExpr(335, 463))
|
||||
q.SetTable(expressionTypArgs.subExpr(469, 481))
|
||||
q.AppendCTE(expressionTypArgs.subExpr(5, 221))
|
||||
q.AppendSelect(expressionTypArgs.subExpr(231, 359))
|
||||
q.SetTable(expressionTypArgs.subExpr(365, 377))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
@ -89,15 +89,6 @@ func (o publicreportIDTable) args() iter.Seq[orm.ArgWithPosition] {
|
|||
}) {
|
||||
return
|
||||
}
|
||||
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "publicID",
|
||||
Start: 321,
|
||||
Stop: 323,
|
||||
Expression: o.PublicID,
|
||||
}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,6 @@ WITH found_tables AS (
|
|||
id
|
||||
FROM publicreport.pool
|
||||
WHERE public_id = $2
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT 'quick' as table_name,
|
||||
id
|
||||
FROM publicreport.quick
|
||||
WHERE public_id = $3
|
||||
)
|
||||
SELECT
|
||||
EXISTS (SELECT 1 FROM found_tables) as exists_somewhere,
|
||||
|
|
|
|||
|
|
@ -13,13 +13,6 @@ WITH found_tables AS (
|
|||
id
|
||||
FROM publicreport.pool
|
||||
WHERE public_id = $1
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT 'quick' as table_name,
|
||||
id
|
||||
FROM publicreport.quick
|
||||
WHERE public_id = $1
|
||||
)
|
||||
SELECT
|
||||
EXISTS (SELECT 1 FROM found_tables) as exists_somewhere,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func geospatialFromForm(r *http.Request) (GeospatialData, error) {
|
|||
cell, err := h3utils.GetCell(longitude, latitude, resolution)
|
||||
return GeospatialData{
|
||||
Cell: cell,
|
||||
GeometryQuery: fmt.Sprintf("ST_GeometryFromText('Point(%f %f)')", longitude, latitude),
|
||||
GeometryQuery: fmt.Sprintf("ST_Point(%f, %f, 4326)", longitude, latitude),
|
||||
Populated: true,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,37 +288,6 @@ func contentFromPool(ctx context.Context, report_id string) (result ContentStatu
|
|||
return result, err
|
||||
}
|
||||
|
||||
func contentFromQuick(ctx context.Context, report_id string) (result ContentStatusByID, err error) {
|
||||
quick, err := models.PublicreportQuicks.Query(
|
||||
models.SelectWhere.PublicreportQuicks.PublicID.EQ(report_id),
|
||||
).One(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("Failed to query nuisance %s: %w", report_id, err)
|
||||
}
|
||||
|
||||
result.Report.ID = report_id
|
||||
result.Report.Address = quick.Address
|
||||
result.Report.Comments = quick.Comments
|
||||
result.Report.Created = quick.Created
|
||||
result.Report.Type = "Quick"
|
||||
|
||||
type LocationGeoJSON struct {
|
||||
Location string
|
||||
}
|
||||
location, err := bob.One(ctx, db.PGInstance.BobDB, psql.Select(
|
||||
sm.Columns(
|
||||
psql.F("ST_AsGeoJSON", "location"),
|
||||
),
|
||||
sm.From("publicreport.quick"),
|
||||
sm.Where(psql.Quote("public_id").EQ(psql.Arg(report_id))),
|
||||
), scan.SingleColumnMapper[string])
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("Failed to query nuisance %s: %w", report_id, err)
|
||||
}
|
||||
result.Report.Location = location
|
||||
|
||||
return result, err
|
||||
}
|
||||
func getStatusByID(w http.ResponseWriter, r *http.Request) {
|
||||
report_id := chi.URLParam(r, "report_id")
|
||||
ctx := r.Context()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue