Add district table for california districts.
This commit is contained in:
parent
e6e8371742
commit
00fd676adc
24 changed files with 4384 additions and 125 deletions
|
|
@ -31,6 +31,14 @@ You'll need a number of environment variables for configuring things;
|
|||
> BASE_URL=https://sync.nidus.cloud ARCGIS_CLIENT_ID=foo ARCGIS_CLIENT_SECRET=bar POSTGRES_DSN='postgresql://?host=/var/run/postgresql&dbname=nidus-sync' ./nidus-sync
|
||||
```
|
||||
|
||||
### Districts
|
||||
|
||||
There's a table containing district information in the database, `public.district`. It was created with:
|
||||
|
||||
```
|
||||
shp2pgsql -s 4326 -c -D -I CA_districts.shp public.district | psql -d nidus-sync
|
||||
```
|
||||
|
||||
## Hacking
|
||||
|
||||
### air
|
||||
|
|
|
|||
17
db/dberrors/district.bob.go
Normal file
17
db/dberrors/district.bob.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
var DistrictErrors = &districtErrors{
|
||||
ErrUniqueDistrictPkey: &UniqueConstraintError{
|
||||
schema: "",
|
||||
table: "district",
|
||||
columns: []string{"gid"},
|
||||
s: "district_pkey",
|
||||
},
|
||||
}
|
||||
|
||||
type districtErrors struct {
|
||||
ErrUniqueDistrictPkey *UniqueConstraintError
|
||||
}
|
||||
320
db/dbinfo/district.bob.go
Normal file
320
db/dbinfo/district.bob.go
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. 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 Districts = Table[
|
||||
districtColumns,
|
||||
districtIndexes,
|
||||
districtForeignKeys,
|
||||
districtUniques,
|
||||
districtChecks,
|
||||
]{
|
||||
Schema: "",
|
||||
Name: "district",
|
||||
Columns: districtColumns{
|
||||
Gid: column{
|
||||
Name: "gid",
|
||||
DBType: "integer",
|
||||
Default: "nextval('district_gid_seq'::regclass)",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ID: column{
|
||||
Name: "id",
|
||||
DBType: "numeric",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Website: column{
|
||||
Name: "website",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Contact: column{
|
||||
Name: "contact",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Address: column{
|
||||
Name: "address",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Regionid: column{
|
||||
Name: "regionid",
|
||||
DBType: "numeric",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
PostalCod: column{
|
||||
Name: "postal_cod",
|
||||
DBType: "numeric",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Phone1: column{
|
||||
Name: "phone1",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Fax1: column{
|
||||
Name: "fax1",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Agency: column{
|
||||
Name: "agency",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Code1: column{
|
||||
Name: "code1",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
City1: column{
|
||||
Name: "city1",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ShapeLeng: column{
|
||||
Name: "shape_leng",
|
||||
DBType: "numeric",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Address2: column{
|
||||
Name: "address2",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
GeneralMG: column{
|
||||
Name: "general_mg",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
City2: column{
|
||||
Name: "city2",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
PostalC1: column{
|
||||
Name: "postal_c_1",
|
||||
DBType: "numeric",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Fax2: column{
|
||||
Name: "fax2",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Phone2: column{
|
||||
Name: "phone2",
|
||||
DBType: "character varying",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ShapeLe1: column{
|
||||
Name: "shape_le_1",
|
||||
DBType: "numeric",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ShapeArea: column{
|
||||
Name: "shape_area",
|
||||
DBType: "numeric",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Geom: column{
|
||||
Name: "geom",
|
||||
DBType: "geometry",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: districtIndexes{
|
||||
DistrictPkey: index{
|
||||
Type: "btree",
|
||||
Name: "district_pkey",
|
||||
Columns: []indexColumn{
|
||||
{
|
||||
Name: "gid",
|
||||
Desc: null.FromCond(false, true),
|
||||
IsExpression: false,
|
||||
},
|
||||
},
|
||||
Unique: true,
|
||||
Comment: "",
|
||||
NullsFirst: []bool{false},
|
||||
NullsDistinct: false,
|
||||
Where: "",
|
||||
Include: []string{},
|
||||
},
|
||||
DistrictGeomIdx: index{
|
||||
Type: "gist",
|
||||
Name: "district_geom_idx",
|
||||
Columns: []indexColumn{
|
||||
{
|
||||
Name: "geom",
|
||||
Desc: null.FromCond(false, true),
|
||||
IsExpression: false,
|
||||
},
|
||||
},
|
||||
Unique: false,
|
||||
Comment: "",
|
||||
NullsFirst: []bool{false},
|
||||
NullsDistinct: false,
|
||||
Where: "",
|
||||
Include: []string{},
|
||||
},
|
||||
},
|
||||
PrimaryKey: &constraint{
|
||||
Name: "district_pkey",
|
||||
Columns: []string{"gid"},
|
||||
Comment: "",
|
||||
},
|
||||
|
||||
Comment: "",
|
||||
}
|
||||
|
||||
type districtColumns struct {
|
||||
Gid column
|
||||
ID column
|
||||
Website column
|
||||
Contact column
|
||||
Address column
|
||||
Regionid column
|
||||
PostalCod column
|
||||
Phone1 column
|
||||
Fax1 column
|
||||
Agency column
|
||||
Code1 column
|
||||
City1 column
|
||||
ShapeLeng column
|
||||
Address2 column
|
||||
GeneralMG column
|
||||
City2 column
|
||||
PostalC1 column
|
||||
Fax2 column
|
||||
Phone2 column
|
||||
ShapeLe1 column
|
||||
ShapeArea column
|
||||
Geom column
|
||||
}
|
||||
|
||||
func (c districtColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.Gid, c.ID, c.Website, c.Contact, c.Address, c.Regionid, c.PostalCod, c.Phone1, c.Fax1, c.Agency, c.Code1, c.City1, c.ShapeLeng, c.Address2, c.GeneralMG, c.City2, c.PostalC1, c.Fax2, c.Phone2, c.ShapeLe1, c.ShapeArea, c.Geom,
|
||||
}
|
||||
}
|
||||
|
||||
type districtIndexes struct {
|
||||
DistrictPkey index
|
||||
DistrictGeomIdx index
|
||||
}
|
||||
|
||||
func (i districtIndexes) AsSlice() []index {
|
||||
return []index{
|
||||
i.DistrictPkey, i.DistrictGeomIdx,
|
||||
}
|
||||
}
|
||||
|
||||
type districtForeignKeys struct{}
|
||||
|
||||
func (f districtForeignKeys) AsSlice() []foreignKey {
|
||||
return []foreignKey{}
|
||||
}
|
||||
|
||||
type districtUniques struct{}
|
||||
|
||||
func (u districtUniques) AsSlice() []constraint {
|
||||
return []constraint{}
|
||||
}
|
||||
|
||||
type districtChecks struct{}
|
||||
|
||||
func (c districtChecks) AsSlice() []check {
|
||||
return []check{}
|
||||
}
|
||||
|
|
@ -69,8 +69,8 @@ var PublicreportNuisances = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
SourceLocation: column{
|
||||
Name: "source_location",
|
||||
DBType: "publicreport.nuisancelocationtype",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
|
|
@ -231,6 +231,33 @@ var PublicreportNuisances = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Address: column{
|
||||
Name: "address",
|
||||
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,
|
||||
},
|
||||
Status: column{
|
||||
Name: "status",
|
||||
DBType: "publicreport.reportstatustype",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportNuisanceIndexes{
|
||||
NuisancePkey: index{
|
||||
|
|
@ -292,7 +319,7 @@ type publicreportNuisanceColumns struct {
|
|||
Duration column
|
||||
Email column
|
||||
InspectionType column
|
||||
Location column
|
||||
SourceLocation column
|
||||
PreferredDateRange column
|
||||
PreferredTime column
|
||||
RequestCall column
|
||||
|
|
@ -310,11 +337,14 @@ type publicreportNuisanceColumns struct {
|
|||
ReporterEmail column
|
||||
ReporterName column
|
||||
ReporterPhone column
|
||||
Address column
|
||||
Location column
|
||||
Status column
|
||||
}
|
||||
|
||||
func (c publicreportNuisanceColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.Email, c.InspectionType, c.Location, c.PreferredDateRange, c.PreferredTime, c.RequestCall, c.Severity, c.SourceContainer, c.SourceDescription, c.SourceRoof, c.SourceStagnant, c.TimeOfDayDay, c.TimeOfDayEarly, c.TimeOfDayEvening, c.TimeOfDayNight, c.PublicID, c.ReporterAddress, c.ReporterEmail, c.ReporterName, c.ReporterPhone,
|
||||
c.ID, c.AdditionalInfo, c.Created, c.Duration, c.Email, c.InspectionType, c.SourceLocation, c.PreferredDateRange, c.PreferredTime, c.RequestCall, c.Severity, c.SourceContainer, c.SourceDescription, c.SourceRoof, c.SourceStagnant, c.TimeOfDayDay, c.TimeOfDayEarly, c.TimeOfDayEvening, c.TimeOfDayNight, c.PublicID, c.ReporterAddress, c.ReporterEmail, c.ReporterName, c.ReporterPhone, c.Address, c.Location, c.Status,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -276,6 +276,15 @@ var PublicreportPools = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Status: column{
|
||||
Name: "status",
|
||||
DBType: "publicreport.reportstatustype",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportPoolIndexes{
|
||||
PoolPkey: index{
|
||||
|
|
@ -360,11 +369,12 @@ type publicreportPoolColumns struct {
|
|||
ReporterName column
|
||||
ReporterPhone column
|
||||
Subscribe column
|
||||
Status 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.Subscribe,
|
||||
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.Subscribe, c.Status,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,24 @@ var PublicreportQuicks = Table[
|
|||
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,
|
||||
},
|
||||
},
|
||||
Indexes: publicreportQuickIndexes{
|
||||
QuickPkey: index{
|
||||
|
|
@ -150,11 +168,13 @@ type publicreportQuickColumns struct {
|
|||
PublicID column
|
||||
ReporterEmail column
|
||||
ReporterPhone column
|
||||
Address column
|
||||
Status 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.ID, c.Created, c.Comments, c.Location, c.H3cell, c.PublicID, c.ReporterEmail, c.ReporterPhone, c.Address, c.Status,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
122
db/dbinfo/publicreport.report_location.bob.go
Normal file
122
db/dbinfo/publicreport.report_location.bob.go
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dbinfo
|
||||
|
||||
var PublicreportReportLocations = Table[
|
||||
publicreportReportLocationColumns,
|
||||
publicreportReportLocationIndexes,
|
||||
publicreportReportLocationForeignKeys,
|
||||
publicreportReportLocationUniques,
|
||||
publicreportReportLocationChecks,
|
||||
]{
|
||||
Schema: "publicreport",
|
||||
Name: "report_location",
|
||||
Columns: publicreportReportLocationColumns{
|
||||
ID: column{
|
||||
Name: "id",
|
||||
DBType: "bigint",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
TableName: column{
|
||||
Name: "table_name",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Address: column{
|
||||
Name: "address",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Created: column{
|
||||
Name: "created",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Location: column{
|
||||
Name: "location",
|
||||
DBType: "geography",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
PublicID: column{
|
||||
Name: "public_id",
|
||||
DBType: "text",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Status: column{
|
||||
Name: "status",
|
||||
DBType: "publicreport.reportstatustype",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
|
||||
Comment: "",
|
||||
}
|
||||
|
||||
type publicreportReportLocationColumns struct {
|
||||
ID column
|
||||
TableName column
|
||||
Address column
|
||||
Created column
|
||||
Location column
|
||||
PublicID column
|
||||
Status column
|
||||
}
|
||||
|
||||
func (c publicreportReportLocationColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.ID, c.TableName, c.Address, c.Created, c.Location, c.PublicID, c.Status,
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportReportLocationIndexes struct{}
|
||||
|
||||
func (i publicreportReportLocationIndexes) AsSlice() []index {
|
||||
return []index{}
|
||||
}
|
||||
|
||||
type publicreportReportLocationForeignKeys struct{}
|
||||
|
||||
func (f publicreportReportLocationForeignKeys) AsSlice() []foreignKey {
|
||||
return []foreignKey{}
|
||||
}
|
||||
|
||||
type publicreportReportLocationUniques struct{}
|
||||
|
||||
func (u publicreportReportLocationUniques) AsSlice() []constraint {
|
||||
return []constraint{}
|
||||
}
|
||||
|
||||
type publicreportReportLocationChecks struct{}
|
||||
|
||||
func (c publicreportReportLocationChecks) AsSlice() []check {
|
||||
return []check{}
|
||||
}
|
||||
|
|
@ -975,3 +975,82 @@ func (e *PublicreportPoolsourceduration) Scan(value any) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Enum values for PublicreportReportstatustype
|
||||
const (
|
||||
PublicreportReportstatustypeReported PublicreportReportstatustype = "reported"
|
||||
PublicreportReportstatustypeReviewed PublicreportReportstatustype = "reviewed"
|
||||
PublicreportReportstatustypeScheduled PublicreportReportstatustype = "scheduled"
|
||||
PublicreportReportstatustypeTreated PublicreportReportstatustype = "treated"
|
||||
)
|
||||
|
||||
func AllPublicreportReportstatustype() []PublicreportReportstatustype {
|
||||
return []PublicreportReportstatustype{
|
||||
PublicreportReportstatustypeReported,
|
||||
PublicreportReportstatustypeReviewed,
|
||||
PublicreportReportstatustypeScheduled,
|
||||
PublicreportReportstatustypeTreated,
|
||||
}
|
||||
}
|
||||
|
||||
type PublicreportReportstatustype string
|
||||
|
||||
func (e PublicreportReportstatustype) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e PublicreportReportstatustype) Valid() bool {
|
||||
switch e {
|
||||
case PublicreportReportstatustypeReported,
|
||||
PublicreportReportstatustypeReviewed,
|
||||
PublicreportReportstatustypeScheduled,
|
||||
PublicreportReportstatustypeTreated:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// useful when testing in other packages
|
||||
func (e PublicreportReportstatustype) All() []PublicreportReportstatustype {
|
||||
return AllPublicreportReportstatustype()
|
||||
}
|
||||
|
||||
func (e PublicreportReportstatustype) MarshalText() ([]byte, error) {
|
||||
return []byte(e), nil
|
||||
}
|
||||
|
||||
func (e *PublicreportReportstatustype) UnmarshalText(text []byte) error {
|
||||
return e.Scan(text)
|
||||
}
|
||||
|
||||
func (e PublicreportReportstatustype) MarshalBinary() ([]byte, error) {
|
||||
return []byte(e), nil
|
||||
}
|
||||
|
||||
func (e *PublicreportReportstatustype) UnmarshalBinary(data []byte) error {
|
||||
return e.Scan(data)
|
||||
}
|
||||
|
||||
func (e PublicreportReportstatustype) Value() (driver.Value, error) {
|
||||
return string(e), nil
|
||||
}
|
||||
|
||||
func (e *PublicreportReportstatustype) Scan(value any) error {
|
||||
switch x := value.(type) {
|
||||
case string:
|
||||
*e = PublicreportReportstatustype(x)
|
||||
case []byte:
|
||||
*e = PublicreportReportstatustype(x)
|
||||
case nil:
|
||||
return fmt.Errorf("cannot nil into PublicreportReportstatustype")
|
||||
default:
|
||||
return fmt.Errorf("cannot scan type %T: %v", value, value)
|
||||
}
|
||||
|
||||
if !e.Valid() {
|
||||
return fmt.Errorf("invalid PublicreportReportstatustype value: %s", *e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import "context"
|
|||
type contextKey string
|
||||
|
||||
var (
|
||||
// Relationship Contexts for district
|
||||
districtWithParentsCascadingCtx = newContextual[bool]("districtWithParentsCascading")
|
||||
|
||||
// Relationship Contexts for fieldseeker.containerrelate
|
||||
fieldseekerContainerrelateWithParentsCascadingCtx = newContextual[bool]("fieldseekerContainerrelateWithParentsCascading")
|
||||
fieldseekerContainerrelateRelOrganizationCtx = newContextual[bool]("fieldseeker.containerrelate.organization.fieldseeker.containerrelate.containerrelate_organization_id_fkey")
|
||||
|
|
@ -227,6 +230,9 @@ var (
|
|||
publicreportQuickPhotoWithParentsCascadingCtx = newContextual[bool]("publicreportQuickPhotoWithParentsCascading")
|
||||
publicreportQuickPhotoRelQuickCtx = newContextual[bool]("publicreport.quick.publicreport.quick_photo.publicreport.quick_photo.quick_photo_quick_id_fkey")
|
||||
|
||||
// Relationship Contexts for publicreport.report_location
|
||||
publicreportReportLocationWithParentsCascadingCtx = newContextual[bool]("publicreportReportLocationWithParentsCascading")
|
||||
|
||||
// Relationship Contexts for raster_columns
|
||||
rasterColumnWithParentsCascadingCtx = newContextual[bool]("rasterColumnWithParentsCascading")
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@ import (
|
|||
"github.com/aarondl/opt/null"
|
||||
"github.com/google/uuid"
|
||||
"github.com/lib/pq"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stephenafamo/bob/types"
|
||||
)
|
||||
|
||||
type Factory struct {
|
||||
baseDistrictMods DistrictModSlice
|
||||
baseFieldseekerContainerrelateMods FieldseekerContainerrelateModSlice
|
||||
baseFieldseekerFieldscoutinglogMods FieldseekerFieldscoutinglogModSlice
|
||||
baseFieldseekerHabitatrelateMods FieldseekerHabitatrelateModSlice
|
||||
|
|
@ -63,6 +65,7 @@ type Factory struct {
|
|||
basePublicreportPoolPhotoMods PublicreportPoolPhotoModSlice
|
||||
basePublicreportQuickMods PublicreportQuickModSlice
|
||||
basePublicreportQuickPhotoMods PublicreportQuickPhotoModSlice
|
||||
basePublicreportReportLocationMods PublicreportReportLocationModSlice
|
||||
baseRasterColumnMods RasterColumnModSlice
|
||||
baseRasterOverviewMods RasterOverviewModSlice
|
||||
baseSessionMods SessionModSlice
|
||||
|
|
@ -74,6 +77,51 @@ func New() *Factory {
|
|||
return &Factory{}
|
||||
}
|
||||
|
||||
func (f *Factory) NewDistrict(mods ...DistrictMod) *DistrictTemplate {
|
||||
return f.NewDistrictWithContext(context.Background(), mods...)
|
||||
}
|
||||
|
||||
func (f *Factory) NewDistrictWithContext(ctx context.Context, mods ...DistrictMod) *DistrictTemplate {
|
||||
o := &DistrictTemplate{f: f}
|
||||
|
||||
if f != nil {
|
||||
f.baseDistrictMods.Apply(ctx, o)
|
||||
}
|
||||
|
||||
DistrictModSlice(mods).Apply(ctx, o)
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
func (f *Factory) FromExistingDistrict(m *models.District) *DistrictTemplate {
|
||||
o := &DistrictTemplate{f: f, alreadyPersisted: true}
|
||||
|
||||
o.Gid = func() int32 { return m.Gid }
|
||||
o.ID = func() null.Val[decimal.Decimal] { return m.ID }
|
||||
o.Website = func() null.Val[string] { return m.Website }
|
||||
o.Contact = func() null.Val[string] { return m.Contact }
|
||||
o.Address = func() null.Val[string] { return m.Address }
|
||||
o.Regionid = func() null.Val[decimal.Decimal] { return m.Regionid }
|
||||
o.PostalCod = func() null.Val[decimal.Decimal] { return m.PostalCod }
|
||||
o.Phone1 = func() null.Val[string] { return m.Phone1 }
|
||||
o.Fax1 = func() null.Val[string] { return m.Fax1 }
|
||||
o.Agency = func() null.Val[string] { return m.Agency }
|
||||
o.Code1 = func() null.Val[string] { return m.Code1 }
|
||||
o.City1 = func() null.Val[string] { return m.City1 }
|
||||
o.ShapeLeng = func() null.Val[decimal.Decimal] { return m.ShapeLeng }
|
||||
o.Address2 = func() null.Val[string] { return m.Address2 }
|
||||
o.GeneralMG = func() null.Val[string] { return m.GeneralMG }
|
||||
o.City2 = func() null.Val[string] { return m.City2 }
|
||||
o.PostalC1 = func() null.Val[decimal.Decimal] { return m.PostalC1 }
|
||||
o.Fax2 = func() null.Val[string] { return m.Fax2 }
|
||||
o.Phone2 = func() null.Val[string] { return m.Phone2 }
|
||||
o.ShapeLe1 = func() null.Val[decimal.Decimal] { return m.ShapeLe1 }
|
||||
o.ShapeArea = func() null.Val[decimal.Decimal] { return m.ShapeArea }
|
||||
o.Geom = func() null.Val[string] { return m.Geom }
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
func (f *Factory) NewFieldseekerContainerrelate(mods ...FieldseekerContainerrelateMod) *FieldseekerContainerrelateTemplate {
|
||||
return f.NewFieldseekerContainerrelateWithContext(context.Background(), mods...)
|
||||
}
|
||||
|
|
@ -2400,7 +2448,7 @@ func (f *Factory) FromExistingPublicreportNuisance(m *models.PublicreportNuisanc
|
|||
o.Duration = func() enums.PublicreportNuisancedurationtype { return m.Duration }
|
||||
o.Email = func() string { return m.Email }
|
||||
o.InspectionType = func() enums.PublicreportNuisanceinspectiontype { return m.InspectionType }
|
||||
o.Location = func() enums.PublicreportNuisancelocationtype { return m.Location }
|
||||
o.SourceLocation = func() enums.PublicreportNuisancelocationtype { return m.SourceLocation }
|
||||
o.PreferredDateRange = func() enums.PublicreportNuisancepreferreddaterangetype { return m.PreferredDateRange }
|
||||
o.PreferredTime = func() enums.PublicreportNuisancepreferredtimetype { return m.PreferredTime }
|
||||
o.RequestCall = func() bool { return m.RequestCall }
|
||||
|
|
@ -2418,6 +2466,9 @@ func (f *Factory) FromExistingPublicreportNuisance(m *models.PublicreportNuisanc
|
|||
o.ReporterEmail = func() string { return m.ReporterEmail }
|
||||
o.ReporterName = func() string { return m.ReporterName }
|
||||
o.ReporterPhone = func() string { return m.ReporterPhone }
|
||||
o.Address = func() string { return m.Address }
|
||||
o.Location = func() null.Val[string] { return m.Location }
|
||||
o.Status = func() enums.PublicreportReportstatustype { return m.Status }
|
||||
|
||||
return o
|
||||
}
|
||||
|
|
@ -2470,6 +2521,7 @@ func (f *Factory) FromExistingPublicreportPool(m *models.PublicreportPool) *Publ
|
|||
o.ReporterName = func() string { return m.ReporterName }
|
||||
o.ReporterPhone = func() string { return m.ReporterPhone }
|
||||
o.Subscribe = func() bool { return m.Subscribe }
|
||||
o.Status = func() enums.PublicreportReportstatustype { return m.Status }
|
||||
|
||||
ctx := context.Background()
|
||||
if len(m.R.PoolPhotos) > 0 {
|
||||
|
|
@ -2539,6 +2591,8 @@ func (f *Factory) FromExistingPublicreportQuick(m *models.PublicreportQuick) *Pu
|
|||
o.PublicID = func() string { return m.PublicID }
|
||||
o.ReporterEmail = func() string { return m.ReporterEmail }
|
||||
o.ReporterPhone = func() string { return m.ReporterPhone }
|
||||
o.Address = func() string { return m.Address }
|
||||
o.Status = func() enums.PublicreportReportstatustype { return m.Status }
|
||||
|
||||
ctx := context.Background()
|
||||
if len(m.R.QuickPhotos) > 0 {
|
||||
|
|
@ -2581,6 +2635,36 @@ func (f *Factory) FromExistingPublicreportQuickPhoto(m *models.PublicreportQuick
|
|||
return o
|
||||
}
|
||||
|
||||
func (f *Factory) NewPublicreportReportLocation(mods ...PublicreportReportLocationMod) *PublicreportReportLocationTemplate {
|
||||
return f.NewPublicreportReportLocationWithContext(context.Background(), mods...)
|
||||
}
|
||||
|
||||
func (f *Factory) NewPublicreportReportLocationWithContext(ctx context.Context, mods ...PublicreportReportLocationMod) *PublicreportReportLocationTemplate {
|
||||
o := &PublicreportReportLocationTemplate{f: f}
|
||||
|
||||
if f != nil {
|
||||
f.basePublicreportReportLocationMods.Apply(ctx, o)
|
||||
}
|
||||
|
||||
PublicreportReportLocationModSlice(mods).Apply(ctx, o)
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
func (f *Factory) FromExistingPublicreportReportLocation(m *models.PublicreportReportLocation) *PublicreportReportLocationTemplate {
|
||||
o := &PublicreportReportLocationTemplate{f: f, alreadyPersisted: true}
|
||||
|
||||
o.ID = func() null.Val[int64] { return m.ID }
|
||||
o.TableName = func() null.Val[string] { return m.TableName }
|
||||
o.Address = func() null.Val[string] { return m.Address }
|
||||
o.Created = func() null.Val[time.Time] { return m.Created }
|
||||
o.Location = func() null.Val[string] { return m.Location }
|
||||
o.PublicID = func() null.Val[string] { return m.PublicID }
|
||||
o.Status = func() null.Val[enums.PublicreportReportstatustype] { return m.Status }
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
func (f *Factory) NewRasterColumn(mods ...RasterColumnMod) *RasterColumnTemplate {
|
||||
return f.NewRasterColumnWithContext(context.Background(), mods...)
|
||||
}
|
||||
|
|
@ -2765,6 +2849,14 @@ func (f *Factory) FromExistingUser(m *models.User) *UserTemplate {
|
|||
return o
|
||||
}
|
||||
|
||||
func (f *Factory) ClearBaseDistrictMods() {
|
||||
f.baseDistrictMods = nil
|
||||
}
|
||||
|
||||
func (f *Factory) AddBaseDistrictMod(mods ...DistrictMod) {
|
||||
f.baseDistrictMods = append(f.baseDistrictMods, mods...)
|
||||
}
|
||||
|
||||
func (f *Factory) ClearBaseFieldseekerContainerrelateMods() {
|
||||
f.baseFieldseekerContainerrelateMods = nil
|
||||
}
|
||||
|
|
@ -3133,6 +3225,14 @@ func (f *Factory) AddBasePublicreportQuickPhotoMod(mods ...PublicreportQuickPhot
|
|||
f.basePublicreportQuickPhotoMods = append(f.basePublicreportQuickPhotoMods, mods...)
|
||||
}
|
||||
|
||||
func (f *Factory) ClearBasePublicreportReportLocationMods() {
|
||||
f.basePublicreportReportLocationMods = nil
|
||||
}
|
||||
|
||||
func (f *Factory) AddBasePublicreportReportLocationMod(mods ...PublicreportReportLocationMod) {
|
||||
f.basePublicreportReportLocationMods = append(f.basePublicreportReportLocationMods, mods...)
|
||||
}
|
||||
|
||||
func (f *Factory) ClearBaseRasterColumnMods() {
|
||||
f.baseRasterColumnMods = nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/google/uuid"
|
||||
"github.com/jaswdr/faker/v2"
|
||||
"github.com/lib/pq"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stephenafamo/bob/types"
|
||||
)
|
||||
|
||||
|
|
@ -37,6 +38,37 @@ func random_bool(f *faker.Faker, limits ...string) bool {
|
|||
return f.Bool()
|
||||
}
|
||||
|
||||
func random_decimal_Decimal(f *faker.Faker, limits ...string) decimal.Decimal {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
var precision int64 = 7
|
||||
var scale int64 = 3
|
||||
|
||||
if len(limits) > 0 {
|
||||
precision, _ = strconv.ParseInt(limits[0], 10, 32)
|
||||
}
|
||||
|
||||
if len(limits) > 1 {
|
||||
scale, _ = strconv.ParseInt(limits[1], 10, 32)
|
||||
}
|
||||
|
||||
baseVal := f.Float32(10, -1, 1)
|
||||
for baseVal == -1 || baseVal == 0 || baseVal == 1 {
|
||||
baseVal = f.Float32(10, -1, 1)
|
||||
}
|
||||
|
||||
precisionDecimal, _ := decimal.NewFromInt(10).PowInt32(int32(precision))
|
||||
val := decimal.
|
||||
NewFromFloat32(baseVal).
|
||||
Mul(precisionDecimal).
|
||||
Shift(int32(-1 * scale)).
|
||||
RoundDown(int32(scale))
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func random_enums_Arcgislicensetype(f *faker.Faker, limits ...string) enums.Arcgislicensetype {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
|
|
@ -137,6 +169,16 @@ func random_enums_PublicreportNuisancepreferredtimetype(f *faker.Faker, limits .
|
|||
return all[f.IntBetween(0, len(all)-1)]
|
||||
}
|
||||
|
||||
func random_enums_PublicreportReportstatustype(f *faker.Faker, limits ...string) enums.PublicreportReportstatustype {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
var e enums.PublicreportReportstatustype
|
||||
all := e.All()
|
||||
return all[f.IntBetween(0, len(all)-1)]
|
||||
}
|
||||
|
||||
func random_float32(f *faker.Faker, limits ...string) float32 {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
|
|
|
|||
1556
db/factory/district.bob.go
Normal file
1556
db/factory/district.bob.go
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -10,7 +10,9 @@ import (
|
|||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
"github.com/jaswdr/faker/v2"
|
||||
"github.com/stephenafamo/bob"
|
||||
)
|
||||
|
|
@ -42,7 +44,7 @@ type PublicreportNuisanceTemplate struct {
|
|||
Duration func() enums.PublicreportNuisancedurationtype
|
||||
Email func() string
|
||||
InspectionType func() enums.PublicreportNuisanceinspectiontype
|
||||
Location func() enums.PublicreportNuisancelocationtype
|
||||
SourceLocation func() enums.PublicreportNuisancelocationtype
|
||||
PreferredDateRange func() enums.PublicreportNuisancepreferreddaterangetype
|
||||
PreferredTime func() enums.PublicreportNuisancepreferredtimetype
|
||||
RequestCall func() bool
|
||||
|
|
@ -60,6 +62,9 @@ type PublicreportNuisanceTemplate struct {
|
|||
ReporterEmail func() string
|
||||
ReporterName func() string
|
||||
ReporterPhone func() string
|
||||
Address func() string
|
||||
Location func() null.Val[string]
|
||||
Status func() enums.PublicreportReportstatustype
|
||||
|
||||
f *Factory
|
||||
|
||||
|
|
@ -106,9 +111,9 @@ func (o PublicreportNuisanceTemplate) BuildSetter() *models.PublicreportNuisance
|
|||
val := o.InspectionType()
|
||||
m.InspectionType = omit.From(val)
|
||||
}
|
||||
if o.Location != nil {
|
||||
val := o.Location()
|
||||
m.Location = omit.From(val)
|
||||
if o.SourceLocation != nil {
|
||||
val := o.SourceLocation()
|
||||
m.SourceLocation = omit.From(val)
|
||||
}
|
||||
if o.PreferredDateRange != nil {
|
||||
val := o.PreferredDateRange()
|
||||
|
|
@ -178,6 +183,18 @@ func (o PublicreportNuisanceTemplate) BuildSetter() *models.PublicreportNuisance
|
|||
val := o.ReporterPhone()
|
||||
m.ReporterPhone = omit.From(val)
|
||||
}
|
||||
if o.Address != nil {
|
||||
val := o.Address()
|
||||
m.Address = omit.From(val)
|
||||
}
|
||||
if o.Location != nil {
|
||||
val := o.Location()
|
||||
m.Location = omitnull.FromNull(val)
|
||||
}
|
||||
if o.Status != nil {
|
||||
val := o.Status()
|
||||
m.Status = omit.From(val)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
@ -218,8 +235,8 @@ func (o PublicreportNuisanceTemplate) Build() *models.PublicreportNuisance {
|
|||
if o.InspectionType != nil {
|
||||
m.InspectionType = o.InspectionType()
|
||||
}
|
||||
if o.Location != nil {
|
||||
m.Location = o.Location()
|
||||
if o.SourceLocation != nil {
|
||||
m.SourceLocation = o.SourceLocation()
|
||||
}
|
||||
if o.PreferredDateRange != nil {
|
||||
m.PreferredDateRange = o.PreferredDateRange()
|
||||
|
|
@ -272,6 +289,15 @@ func (o PublicreportNuisanceTemplate) Build() *models.PublicreportNuisance {
|
|||
if o.ReporterPhone != nil {
|
||||
m.ReporterPhone = o.ReporterPhone()
|
||||
}
|
||||
if o.Address != nil {
|
||||
m.Address = o.Address()
|
||||
}
|
||||
if o.Location != nil {
|
||||
m.Location = o.Location()
|
||||
}
|
||||
if o.Status != nil {
|
||||
m.Status = o.Status()
|
||||
}
|
||||
|
||||
o.setModelRels(m)
|
||||
|
||||
|
|
@ -312,9 +338,9 @@ func ensureCreatablePublicreportNuisance(m *models.PublicreportNuisanceSetter) {
|
|||
val := random_enums_PublicreportNuisanceinspectiontype(nil)
|
||||
m.InspectionType = omit.From(val)
|
||||
}
|
||||
if !(m.Location.IsValue()) {
|
||||
if !(m.SourceLocation.IsValue()) {
|
||||
val := random_enums_PublicreportNuisancelocationtype(nil)
|
||||
m.Location = omit.From(val)
|
||||
m.SourceLocation = omit.From(val)
|
||||
}
|
||||
if !(m.PreferredDateRange.IsValue()) {
|
||||
val := random_enums_PublicreportNuisancepreferreddaterangetype(nil)
|
||||
|
|
@ -384,6 +410,14 @@ func ensureCreatablePublicreportNuisance(m *models.PublicreportNuisanceSetter) {
|
|||
val := random_string(nil)
|
||||
m.ReporterPhone = omit.From(val)
|
||||
}
|
||||
if !(m.Address.IsValue()) {
|
||||
val := random_string(nil)
|
||||
m.Address = omit.From(val)
|
||||
}
|
||||
if !(m.Status.IsValue()) {
|
||||
val := random_enums_PublicreportReportstatustype(nil)
|
||||
m.Status = omit.From(val)
|
||||
}
|
||||
}
|
||||
|
||||
// insertOptRels creates and inserts any optional the relationships on *models.PublicreportNuisance
|
||||
|
|
@ -490,7 +524,7 @@ func (m publicreportNuisanceMods) RandomizeAllColumns(f *faker.Faker) Publicrepo
|
|||
PublicreportNuisanceMods.RandomDuration(f),
|
||||
PublicreportNuisanceMods.RandomEmail(f),
|
||||
PublicreportNuisanceMods.RandomInspectionType(f),
|
||||
PublicreportNuisanceMods.RandomLocation(f),
|
||||
PublicreportNuisanceMods.RandomSourceLocation(f),
|
||||
PublicreportNuisanceMods.RandomPreferredDateRange(f),
|
||||
PublicreportNuisanceMods.RandomPreferredTime(f),
|
||||
PublicreportNuisanceMods.RandomRequestCall(f),
|
||||
|
|
@ -508,6 +542,9 @@ func (m publicreportNuisanceMods) RandomizeAllColumns(f *faker.Faker) Publicrepo
|
|||
PublicreportNuisanceMods.RandomReporterEmail(f),
|
||||
PublicreportNuisanceMods.RandomReporterName(f),
|
||||
PublicreportNuisanceMods.RandomReporterPhone(f),
|
||||
PublicreportNuisanceMods.RandomAddress(f),
|
||||
PublicreportNuisanceMods.RandomLocation(f),
|
||||
PublicreportNuisanceMods.RandomStatus(f),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -698,31 +735,31 @@ func (m publicreportNuisanceMods) RandomInspectionType(f *faker.Faker) Publicrep
|
|||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportNuisanceMods) Location(val enums.PublicreportNuisancelocationtype) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) SourceLocation(val enums.PublicreportNuisancelocationtype) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = func() enums.PublicreportNuisancelocationtype { return val }
|
||||
o.SourceLocation = func() enums.PublicreportNuisancelocationtype { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportNuisanceMods) LocationFunc(f func() enums.PublicreportNuisancelocationtype) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) SourceLocationFunc(f func() enums.PublicreportNuisancelocationtype) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = f
|
||||
o.SourceLocation = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportNuisanceMods) UnsetLocation() PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) UnsetSourceLocation() PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = nil
|
||||
o.SourceLocation = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
func (m publicreportNuisanceMods) RandomLocation(f *faker.Faker) PublicreportNuisanceMod {
|
||||
func (m publicreportNuisanceMods) RandomSourceLocation(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = func() enums.PublicreportNuisancelocationtype {
|
||||
o.SourceLocation = func() enums.PublicreportNuisancelocationtype {
|
||||
return random_enums_PublicreportNuisancelocationtype(f)
|
||||
}
|
||||
})
|
||||
|
|
@ -1255,6 +1292,121 @@ func (m publicreportNuisanceMods) RandomReporterPhone(f *faker.Faker) Publicrepo
|
|||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportNuisanceMods) Address(val string) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Address = func() string { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportNuisanceMods) AddressFunc(f func() string) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Address = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportNuisanceMods) UnsetAddress() PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Address = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
func (m publicreportNuisanceMods) RandomAddress(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Address = func() string {
|
||||
return random_string(f)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportNuisanceMods) Location(val null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportNuisanceMods) LocationFunc(f func() null.Val[string]) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportNuisanceMods) UnsetLocation() PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportNuisanceMods) RandomLocation(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportNuisanceMods) RandomLocationNotNull(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Location = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportNuisanceMods) Status(val enums.PublicreportReportstatustype) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Status = func() enums.PublicreportReportstatustype { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportNuisanceMods) StatusFunc(f func() enums.PublicreportReportstatustype) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Status = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportNuisanceMods) UnsetStatus() PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Status = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
func (m publicreportNuisanceMods) RandomStatus(f *faker.Faker) PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(_ context.Context, o *PublicreportNuisanceTemplate) {
|
||||
o.Status = func() enums.PublicreportReportstatustype {
|
||||
return random_enums_PublicreportReportstatustype(f)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m publicreportNuisanceMods) WithParentsCascading() PublicreportNuisanceMod {
|
||||
return PublicreportNuisanceModFunc(func(ctx context.Context, o *PublicreportNuisanceTemplate) {
|
||||
if isDone, _ := publicreportNuisanceWithParentsCascadingCtx.Value(ctx); isDone {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
|
|
@ -66,6 +67,7 @@ type PublicreportPoolTemplate struct {
|
|||
ReporterName func() string
|
||||
ReporterPhone func() string
|
||||
Subscribe func() bool
|
||||
Status func() enums.PublicreportReportstatustype
|
||||
|
||||
r publicreportPoolR
|
||||
f *Factory
|
||||
|
|
@ -227,6 +229,10 @@ func (o PublicreportPoolTemplate) BuildSetter() *models.PublicreportPoolSetter {
|
|||
val := o.Subscribe()
|
||||
m.Subscribe = omit.From(val)
|
||||
}
|
||||
if o.Status != nil {
|
||||
val := o.Status()
|
||||
m.Status = omit.From(val)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
@ -336,6 +342,9 @@ func (o PublicreportPoolTemplate) Build() *models.PublicreportPool {
|
|||
if o.Subscribe != nil {
|
||||
m.Subscribe = o.Subscribe()
|
||||
}
|
||||
if o.Status != nil {
|
||||
m.Status = o.Status()
|
||||
}
|
||||
|
||||
o.setModelRels(m)
|
||||
|
||||
|
|
@ -460,6 +469,10 @@ func ensureCreatablePublicreportPool(m *models.PublicreportPoolSetter) {
|
|||
val := random_bool(nil)
|
||||
m.Subscribe = omit.From(val)
|
||||
}
|
||||
if !(m.Status.IsValue()) {
|
||||
val := random_enums_PublicreportReportstatustype(nil)
|
||||
m.Status = omit.From(val)
|
||||
}
|
||||
}
|
||||
|
||||
// insertOptRels creates and inserts any optional the relationships on *models.PublicreportPool
|
||||
|
|
@ -609,6 +622,7 @@ func (m publicreportPoolMods) RandomizeAllColumns(f *faker.Faker) PublicreportPo
|
|||
PublicreportPoolMods.RandomReporterName(f),
|
||||
PublicreportPoolMods.RandomReporterPhone(f),
|
||||
PublicreportPoolMods.RandomSubscribe(f),
|
||||
PublicreportPoolMods.RandomStatus(f),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1555,6 +1569,37 @@ func (m publicreportPoolMods) RandomSubscribe(f *faker.Faker) PublicreportPoolMo
|
|||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportPoolMods) Status(val enums.PublicreportReportstatustype) PublicreportPoolMod {
|
||||
return PublicreportPoolModFunc(func(_ context.Context, o *PublicreportPoolTemplate) {
|
||||
o.Status = func() enums.PublicreportReportstatustype { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportPoolMods) StatusFunc(f func() enums.PublicreportReportstatustype) PublicreportPoolMod {
|
||||
return PublicreportPoolModFunc(func(_ context.Context, o *PublicreportPoolTemplate) {
|
||||
o.Status = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportPoolMods) UnsetStatus() PublicreportPoolMod {
|
||||
return PublicreportPoolModFunc(func(_ context.Context, o *PublicreportPoolTemplate) {
|
||||
o.Status = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
func (m publicreportPoolMods) RandomStatus(f *faker.Faker) PublicreportPoolMod {
|
||||
return PublicreportPoolModFunc(func(_ context.Context, o *PublicreportPoolTemplate) {
|
||||
o.Status = func() enums.PublicreportReportstatustype {
|
||||
return random_enums_PublicreportReportstatustype(f)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m publicreportPoolMods) WithParentsCascading() PublicreportPoolMod {
|
||||
return PublicreportPoolModFunc(func(ctx context.Context, o *PublicreportPoolTemplate) {
|
||||
if isDone, _ := publicreportPoolWithParentsCascadingCtx.Value(ctx); isDone {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
|
|
@ -45,6 +46,8 @@ type PublicreportQuickTemplate struct {
|
|||
PublicID func() string
|
||||
ReporterEmail func() string
|
||||
ReporterPhone func() string
|
||||
Address func() string
|
||||
Status func() enums.PublicreportReportstatustype
|
||||
|
||||
r publicreportQuickR
|
||||
f *Factory
|
||||
|
|
@ -122,6 +125,14 @@ func (o PublicreportQuickTemplate) BuildSetter() *models.PublicreportQuickSetter
|
|||
val := o.ReporterPhone()
|
||||
m.ReporterPhone = omit.From(val)
|
||||
}
|
||||
if o.Address != nil {
|
||||
val := o.Address()
|
||||
m.Address = omit.From(val)
|
||||
}
|
||||
if o.Status != nil {
|
||||
val := o.Status()
|
||||
m.Status = omit.From(val)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
@ -168,6 +179,12 @@ func (o PublicreportQuickTemplate) Build() *models.PublicreportQuick {
|
|||
if o.ReporterPhone != nil {
|
||||
m.ReporterPhone = o.ReporterPhone()
|
||||
}
|
||||
if o.Address != nil {
|
||||
m.Address = o.Address()
|
||||
}
|
||||
if o.Status != nil {
|
||||
m.Status = o.Status()
|
||||
}
|
||||
|
||||
o.setModelRels(m)
|
||||
|
||||
|
|
@ -208,6 +225,14 @@ func ensureCreatablePublicreportQuick(m *models.PublicreportQuickSetter) {
|
|||
val := random_string(nil)
|
||||
m.ReporterPhone = omit.From(val)
|
||||
}
|
||||
if !(m.Address.IsValue()) {
|
||||
val := random_string(nil)
|
||||
m.Address = omit.From(val)
|
||||
}
|
||||
if !(m.Status.IsValue()) {
|
||||
val := random_enums_PublicreportReportstatustype(nil)
|
||||
m.Status = omit.From(val)
|
||||
}
|
||||
}
|
||||
|
||||
// insertOptRels creates and inserts any optional the relationships on *models.PublicreportQuick
|
||||
|
|
@ -336,6 +361,8 @@ func (m publicreportQuickMods) RandomizeAllColumns(f *faker.Faker) PublicreportQ
|
|||
PublicreportQuickMods.RandomPublicID(f),
|
||||
PublicreportQuickMods.RandomReporterEmail(f),
|
||||
PublicreportQuickMods.RandomReporterPhone(f),
|
||||
PublicreportQuickMods.RandomAddress(f),
|
||||
PublicreportQuickMods.RandomStatus(f),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -631,6 +658,68 @@ func (m publicreportQuickMods) RandomReporterPhone(f *faker.Faker) PublicreportQ
|
|||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportQuickMods) Address(val string) PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Address = func() string { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportQuickMods) AddressFunc(f func() string) PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Address = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportQuickMods) UnsetAddress() PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Address = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
func (m publicreportQuickMods) RandomAddress(f *faker.Faker) PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Address = func() string {
|
||||
return random_string(f)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportQuickMods) Status(val enums.PublicreportReportstatustype) PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Status = func() enums.PublicreportReportstatustype { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportQuickMods) StatusFunc(f func() enums.PublicreportReportstatustype) PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Status = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportQuickMods) UnsetStatus() PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Status = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
func (m publicreportQuickMods) RandomStatus(f *faker.Faker) PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
||||
o.Status = func() enums.PublicreportReportstatustype {
|
||||
return random_enums_PublicreportReportstatustype(f)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m publicreportQuickMods) WithParentsCascading() PublicreportQuickMod {
|
||||
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
||||
if isDone, _ := publicreportQuickWithParentsCascadingCtx.Value(ctx); isDone {
|
||||
|
|
|
|||
502
db/factory/publicreport.report_location.bob.go
Normal file
502
db/factory/publicreport.report_location.bob.go
Normal file
|
|
@ -0,0 +1,502 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package factory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/jaswdr/faker/v2"
|
||||
)
|
||||
|
||||
type PublicreportReportLocationMod interface {
|
||||
Apply(context.Context, *PublicreportReportLocationTemplate)
|
||||
}
|
||||
|
||||
type PublicreportReportLocationModFunc func(context.Context, *PublicreportReportLocationTemplate)
|
||||
|
||||
func (f PublicreportReportLocationModFunc) Apply(ctx context.Context, n *PublicreportReportLocationTemplate) {
|
||||
f(ctx, n)
|
||||
}
|
||||
|
||||
type PublicreportReportLocationModSlice []PublicreportReportLocationMod
|
||||
|
||||
func (mods PublicreportReportLocationModSlice) Apply(ctx context.Context, n *PublicreportReportLocationTemplate) {
|
||||
for _, f := range mods {
|
||||
f.Apply(ctx, n)
|
||||
}
|
||||
}
|
||||
|
||||
// PublicreportReportLocationTemplate is an object representing the database table.
|
||||
// all columns are optional and should be set by mods
|
||||
type PublicreportReportLocationTemplate struct {
|
||||
ID func() null.Val[int64]
|
||||
TableName func() null.Val[string]
|
||||
Address func() null.Val[string]
|
||||
Created func() null.Val[time.Time]
|
||||
Location func() null.Val[string]
|
||||
PublicID func() null.Val[string]
|
||||
Status func() null.Val[enums.PublicreportReportstatustype]
|
||||
|
||||
f *Factory
|
||||
|
||||
alreadyPersisted bool
|
||||
}
|
||||
|
||||
// Apply mods to the PublicreportReportLocationTemplate
|
||||
func (o *PublicreportReportLocationTemplate) Apply(ctx context.Context, mods ...PublicreportReportLocationMod) {
|
||||
for _, mod := range mods {
|
||||
mod.Apply(ctx, o)
|
||||
}
|
||||
}
|
||||
|
||||
// setModelRels creates and sets the relationships on *models.PublicreportReportLocation
|
||||
// according to the relationships in the template. Nothing is inserted into the db
|
||||
func (t PublicreportReportLocationTemplate) setModelRels(o *models.PublicreportReportLocation) {}
|
||||
|
||||
// Build returns an *models.PublicreportReportLocation
|
||||
// Related objects are also created and placed in the .R field
|
||||
// NOTE: Objects are not inserted into the database. Use PublicreportReportLocationTemplate.Create
|
||||
func (o PublicreportReportLocationTemplate) Build() *models.PublicreportReportLocation {
|
||||
m := &models.PublicreportReportLocation{}
|
||||
|
||||
if o.ID != nil {
|
||||
m.ID = o.ID()
|
||||
}
|
||||
if o.TableName != nil {
|
||||
m.TableName = o.TableName()
|
||||
}
|
||||
if o.Address != nil {
|
||||
m.Address = o.Address()
|
||||
}
|
||||
if o.Created != nil {
|
||||
m.Created = o.Created()
|
||||
}
|
||||
if o.Location != nil {
|
||||
m.Location = o.Location()
|
||||
}
|
||||
if o.PublicID != nil {
|
||||
m.PublicID = o.PublicID()
|
||||
}
|
||||
if o.Status != nil {
|
||||
m.Status = o.Status()
|
||||
}
|
||||
|
||||
o.setModelRels(m)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// BuildMany returns an models.PublicreportReportLocationSlice
|
||||
// Related objects are also created and placed in the .R field
|
||||
// NOTE: Objects are not inserted into the database. Use PublicreportReportLocationTemplate.CreateMany
|
||||
func (o PublicreportReportLocationTemplate) BuildMany(number int) models.PublicreportReportLocationSlice {
|
||||
m := make(models.PublicreportReportLocationSlice, number)
|
||||
|
||||
for i := range m {
|
||||
m[i] = o.Build()
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// PublicreportReportLocation has methods that act as mods for the PublicreportReportLocationTemplate
|
||||
var PublicreportReportLocationMods publicreportReportLocationMods
|
||||
|
||||
type publicreportReportLocationMods struct{}
|
||||
|
||||
func (m publicreportReportLocationMods) RandomizeAllColumns(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModSlice{
|
||||
PublicreportReportLocationMods.RandomID(f),
|
||||
PublicreportReportLocationMods.RandomTableName(f),
|
||||
PublicreportReportLocationMods.RandomAddress(f),
|
||||
PublicreportReportLocationMods.RandomCreated(f),
|
||||
PublicreportReportLocationMods.RandomLocation(f),
|
||||
PublicreportReportLocationMods.RandomPublicID(f),
|
||||
PublicreportReportLocationMods.RandomStatus(f),
|
||||
}
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportReportLocationMods) ID(val null.Val[int64]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.ID = func() null.Val[int64] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportReportLocationMods) IDFunc(f func() null.Val[int64]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.ID = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportReportLocationMods) UnsetID() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.ID = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportReportLocationMods) RandomID(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.ID = func() null.Val[int64] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_int64(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportReportLocationMods) RandomIDNotNull(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.ID = func() null.Val[int64] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_int64(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportReportLocationMods) TableName(val null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.TableName = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportReportLocationMods) TableNameFunc(f func() null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.TableName = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportReportLocationMods) UnsetTableName() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.TableName = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportReportLocationMods) RandomTableName(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.TableName = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportReportLocationMods) RandomTableNameNotNull(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.TableName = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportReportLocationMods) Address(val null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Address = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportReportLocationMods) AddressFunc(f func() null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Address = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportReportLocationMods) UnsetAddress() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Address = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportReportLocationMods) RandomAddress(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Address = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportReportLocationMods) RandomAddressNotNull(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Address = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportReportLocationMods) Created(val null.Val[time.Time]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Created = func() null.Val[time.Time] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportReportLocationMods) CreatedFunc(f func() null.Val[time.Time]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Created = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportReportLocationMods) UnsetCreated() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Created = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportReportLocationMods) RandomCreated(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Created = func() null.Val[time.Time] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_time_Time(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportReportLocationMods) RandomCreatedNotNull(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Created = func() null.Val[time.Time] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_time_Time(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportReportLocationMods) Location(val null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Location = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportReportLocationMods) LocationFunc(f func() null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Location = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportReportLocationMods) UnsetLocation() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Location = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportReportLocationMods) RandomLocation(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Location = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportReportLocationMods) RandomLocationNotNull(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Location = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportReportLocationMods) PublicID(val null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.PublicID = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportReportLocationMods) PublicIDFunc(f func() null.Val[string]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.PublicID = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportReportLocationMods) UnsetPublicID() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.PublicID = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportReportLocationMods) RandomPublicID(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.PublicID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportReportLocationMods) RandomPublicIDNotNull(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.PublicID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m publicreportReportLocationMods) Status(val null.Val[enums.PublicreportReportstatustype]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Status = func() null.Val[enums.PublicreportReportstatustype] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m publicreportReportLocationMods) StatusFunc(f func() null.Val[enums.PublicreportReportstatustype]) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Status = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m publicreportReportLocationMods) UnsetStatus() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Status = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is sometimes null
|
||||
func (m publicreportReportLocationMods) RandomStatus(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Status = func() null.Val[enums.PublicreportReportstatustype] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_enums_PublicreportReportstatustype(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
// The generated value is never null
|
||||
func (m publicreportReportLocationMods) RandomStatusNotNull(f *faker.Faker) PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(_ context.Context, o *PublicreportReportLocationTemplate) {
|
||||
o.Status = func() null.Val[enums.PublicreportReportstatustype] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_enums_PublicreportReportstatustype(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m publicreportReportLocationMods) WithParentsCascading() PublicreportReportLocationMod {
|
||||
return PublicreportReportLocationModFunc(func(ctx context.Context, o *PublicreportReportLocationTemplate) {
|
||||
if isDone, _ := publicreportReportLocationWithParentsCascadingCtx.Value(ctx); isDone {
|
||||
return
|
||||
}
|
||||
ctx = publicreportReportLocationWithParentsCascadingCtx.WithValue(ctx, true)
|
||||
})
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ var (
|
|||
)
|
||||
|
||||
func Where[Q psql.Filterable]() struct {
|
||||
Districts districtWhere[Q]
|
||||
FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q]
|
||||
FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q]
|
||||
FieldseekerHabitatrelates fieldseekerHabitatrelateWhere[Q]
|
||||
|
|
@ -63,6 +64,7 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportPoolPhotos publicreportPoolPhotoWhere[Q]
|
||||
PublicreportQuicks publicreportQuickWhere[Q]
|
||||
PublicreportQuickPhotos publicreportQuickPhotoWhere[Q]
|
||||
PublicreportReportLocations publicreportReportLocationWhere[Q]
|
||||
RasterColumns rasterColumnWhere[Q]
|
||||
RasterOverviews rasterOverviewWhere[Q]
|
||||
Sessions sessionWhere[Q]
|
||||
|
|
@ -70,6 +72,7 @@ func Where[Q psql.Filterable]() struct {
|
|||
Users userWhere[Q]
|
||||
} {
|
||||
return struct {
|
||||
Districts districtWhere[Q]
|
||||
FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q]
|
||||
FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q]
|
||||
FieldseekerHabitatrelates fieldseekerHabitatrelateWhere[Q]
|
||||
|
|
@ -116,12 +119,14 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportPoolPhotos publicreportPoolPhotoWhere[Q]
|
||||
PublicreportQuicks publicreportQuickWhere[Q]
|
||||
PublicreportQuickPhotos publicreportQuickPhotoWhere[Q]
|
||||
PublicreportReportLocations publicreportReportLocationWhere[Q]
|
||||
RasterColumns rasterColumnWhere[Q]
|
||||
RasterOverviews rasterOverviewWhere[Q]
|
||||
Sessions sessionWhere[Q]
|
||||
SpatialRefSys spatialRefSyWhere[Q]
|
||||
Users userWhere[Q]
|
||||
}{
|
||||
Districts: buildDistrictWhere[Q](Districts.Columns),
|
||||
FieldseekerContainerrelates: buildFieldseekerContainerrelateWhere[Q](FieldseekerContainerrelates.Columns),
|
||||
FieldseekerFieldscoutinglogs: buildFieldseekerFieldscoutinglogWhere[Q](FieldseekerFieldscoutinglogs.Columns),
|
||||
FieldseekerHabitatrelates: buildFieldseekerHabitatrelateWhere[Q](FieldseekerHabitatrelates.Columns),
|
||||
|
|
@ -168,6 +173,7 @@ func Where[Q psql.Filterable]() struct {
|
|||
PublicreportPoolPhotos: buildPublicreportPoolPhotoWhere[Q](PublicreportPoolPhotos.Columns),
|
||||
PublicreportQuicks: buildPublicreportQuickWhere[Q](PublicreportQuicks.Columns),
|
||||
PublicreportQuickPhotos: buildPublicreportQuickPhotoWhere[Q](PublicreportQuickPhotos.Columns),
|
||||
PublicreportReportLocations: buildPublicreportReportLocationWhere[Q](PublicreportReportLocations.Columns),
|
||||
RasterColumns: buildRasterColumnWhere[Q](RasterColumns.Columns),
|
||||
RasterOverviews: buildRasterOverviewWhere[Q](RasterOverviews.Columns),
|
||||
Sessions: buildSessionWhere[Q](Sessions.Columns),
|
||||
|
|
|
|||
876
db/models/district.bob.go
Normal file
876
db/models/district.bob.go
Normal file
|
|
@ -0,0 +1,876 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stephenafamo/bob"
|
||||
"github.com/stephenafamo/bob/dialect/psql"
|
||||
"github.com/stephenafamo/bob/dialect/psql/dialect"
|
||||
"github.com/stephenafamo/bob/dialect/psql/dm"
|
||||
"github.com/stephenafamo/bob/dialect/psql/sm"
|
||||
"github.com/stephenafamo/bob/dialect/psql/um"
|
||||
"github.com/stephenafamo/bob/expr"
|
||||
)
|
||||
|
||||
// District is an object representing the database table.
|
||||
type District struct {
|
||||
Gid int32 `db:"gid,pk" `
|
||||
ID null.Val[decimal.Decimal] `db:"id" `
|
||||
Website null.Val[string] `db:"website" `
|
||||
Contact null.Val[string] `db:"contact" `
|
||||
Address null.Val[string] `db:"address" `
|
||||
Regionid null.Val[decimal.Decimal] `db:"regionid" `
|
||||
PostalCod null.Val[decimal.Decimal] `db:"postal_cod" `
|
||||
Phone1 null.Val[string] `db:"phone1" `
|
||||
Fax1 null.Val[string] `db:"fax1" `
|
||||
Agency null.Val[string] `db:"agency" `
|
||||
Code1 null.Val[string] `db:"code1" `
|
||||
City1 null.Val[string] `db:"city1" `
|
||||
ShapeLeng null.Val[decimal.Decimal] `db:"shape_leng" `
|
||||
Address2 null.Val[string] `db:"address2" `
|
||||
GeneralMG null.Val[string] `db:"general_mg" `
|
||||
City2 null.Val[string] `db:"city2" `
|
||||
PostalC1 null.Val[decimal.Decimal] `db:"postal_c_1" `
|
||||
Fax2 null.Val[string] `db:"fax2" `
|
||||
Phone2 null.Val[string] `db:"phone2" `
|
||||
ShapeLe1 null.Val[decimal.Decimal] `db:"shape_le_1" `
|
||||
ShapeArea null.Val[decimal.Decimal] `db:"shape_area" `
|
||||
Geom null.Val[string] `db:"geom" `
|
||||
}
|
||||
|
||||
// DistrictSlice is an alias for a slice of pointers to District.
|
||||
// This should almost always be used instead of []*District.
|
||||
type DistrictSlice []*District
|
||||
|
||||
// Districts contains methods to work with the district table
|
||||
var Districts = psql.NewTablex[*District, DistrictSlice, *DistrictSetter]("", "district", buildDistrictColumns("district"))
|
||||
|
||||
// DistrictsQuery is a query on the district table
|
||||
type DistrictsQuery = *psql.ViewQuery[*District, DistrictSlice]
|
||||
|
||||
func buildDistrictColumns(alias string) districtColumns {
|
||||
return districtColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"gid", "id", "website", "contact", "address", "regionid", "postal_cod", "phone1", "fax1", "agency", "code1", "city1", "shape_leng", "address2", "general_mg", "city2", "postal_c_1", "fax2", "phone2", "shape_le_1", "shape_area", "geom",
|
||||
).WithParent("district"),
|
||||
tableAlias: alias,
|
||||
Gid: psql.Quote(alias, "gid"),
|
||||
ID: psql.Quote(alias, "id"),
|
||||
Website: psql.Quote(alias, "website"),
|
||||
Contact: psql.Quote(alias, "contact"),
|
||||
Address: psql.Quote(alias, "address"),
|
||||
Regionid: psql.Quote(alias, "regionid"),
|
||||
PostalCod: psql.Quote(alias, "postal_cod"),
|
||||
Phone1: psql.Quote(alias, "phone1"),
|
||||
Fax1: psql.Quote(alias, "fax1"),
|
||||
Agency: psql.Quote(alias, "agency"),
|
||||
Code1: psql.Quote(alias, "code1"),
|
||||
City1: psql.Quote(alias, "city1"),
|
||||
ShapeLeng: psql.Quote(alias, "shape_leng"),
|
||||
Address2: psql.Quote(alias, "address2"),
|
||||
GeneralMG: psql.Quote(alias, "general_mg"),
|
||||
City2: psql.Quote(alias, "city2"),
|
||||
PostalC1: psql.Quote(alias, "postal_c_1"),
|
||||
Fax2: psql.Quote(alias, "fax2"),
|
||||
Phone2: psql.Quote(alias, "phone2"),
|
||||
ShapeLe1: psql.Quote(alias, "shape_le_1"),
|
||||
ShapeArea: psql.Quote(alias, "shape_area"),
|
||||
Geom: psql.Quote(alias, "geom"),
|
||||
}
|
||||
}
|
||||
|
||||
type districtColumns struct {
|
||||
expr.ColumnsExpr
|
||||
tableAlias string
|
||||
Gid psql.Expression
|
||||
ID psql.Expression
|
||||
Website psql.Expression
|
||||
Contact psql.Expression
|
||||
Address psql.Expression
|
||||
Regionid psql.Expression
|
||||
PostalCod psql.Expression
|
||||
Phone1 psql.Expression
|
||||
Fax1 psql.Expression
|
||||
Agency psql.Expression
|
||||
Code1 psql.Expression
|
||||
City1 psql.Expression
|
||||
ShapeLeng psql.Expression
|
||||
Address2 psql.Expression
|
||||
GeneralMG psql.Expression
|
||||
City2 psql.Expression
|
||||
PostalC1 psql.Expression
|
||||
Fax2 psql.Expression
|
||||
Phone2 psql.Expression
|
||||
ShapeLe1 psql.Expression
|
||||
ShapeArea psql.Expression
|
||||
Geom psql.Expression
|
||||
}
|
||||
|
||||
func (c districtColumns) Alias() string {
|
||||
return c.tableAlias
|
||||
}
|
||||
|
||||
func (districtColumns) AliasedAs(alias string) districtColumns {
|
||||
return buildDistrictColumns(alias)
|
||||
}
|
||||
|
||||
// DistrictSetter is used for insert/upsert/update operations
|
||||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type DistrictSetter struct {
|
||||
Gid omit.Val[int32] `db:"gid,pk" `
|
||||
ID omitnull.Val[decimal.Decimal] `db:"id" `
|
||||
Website omitnull.Val[string] `db:"website" `
|
||||
Contact omitnull.Val[string] `db:"contact" `
|
||||
Address omitnull.Val[string] `db:"address" `
|
||||
Regionid omitnull.Val[decimal.Decimal] `db:"regionid" `
|
||||
PostalCod omitnull.Val[decimal.Decimal] `db:"postal_cod" `
|
||||
Phone1 omitnull.Val[string] `db:"phone1" `
|
||||
Fax1 omitnull.Val[string] `db:"fax1" `
|
||||
Agency omitnull.Val[string] `db:"agency" `
|
||||
Code1 omitnull.Val[string] `db:"code1" `
|
||||
City1 omitnull.Val[string] `db:"city1" `
|
||||
ShapeLeng omitnull.Val[decimal.Decimal] `db:"shape_leng" `
|
||||
Address2 omitnull.Val[string] `db:"address2" `
|
||||
GeneralMG omitnull.Val[string] `db:"general_mg" `
|
||||
City2 omitnull.Val[string] `db:"city2" `
|
||||
PostalC1 omitnull.Val[decimal.Decimal] `db:"postal_c_1" `
|
||||
Fax2 omitnull.Val[string] `db:"fax2" `
|
||||
Phone2 omitnull.Val[string] `db:"phone2" `
|
||||
ShapeLe1 omitnull.Val[decimal.Decimal] `db:"shape_le_1" `
|
||||
ShapeArea omitnull.Val[decimal.Decimal] `db:"shape_area" `
|
||||
Geom omitnull.Val[string] `db:"geom" `
|
||||
}
|
||||
|
||||
func (s DistrictSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 22)
|
||||
if s.Gid.IsValue() {
|
||||
vals = append(vals, "gid")
|
||||
}
|
||||
if !s.ID.IsUnset() {
|
||||
vals = append(vals, "id")
|
||||
}
|
||||
if !s.Website.IsUnset() {
|
||||
vals = append(vals, "website")
|
||||
}
|
||||
if !s.Contact.IsUnset() {
|
||||
vals = append(vals, "contact")
|
||||
}
|
||||
if !s.Address.IsUnset() {
|
||||
vals = append(vals, "address")
|
||||
}
|
||||
if !s.Regionid.IsUnset() {
|
||||
vals = append(vals, "regionid")
|
||||
}
|
||||
if !s.PostalCod.IsUnset() {
|
||||
vals = append(vals, "postal_cod")
|
||||
}
|
||||
if !s.Phone1.IsUnset() {
|
||||
vals = append(vals, "phone1")
|
||||
}
|
||||
if !s.Fax1.IsUnset() {
|
||||
vals = append(vals, "fax1")
|
||||
}
|
||||
if !s.Agency.IsUnset() {
|
||||
vals = append(vals, "agency")
|
||||
}
|
||||
if !s.Code1.IsUnset() {
|
||||
vals = append(vals, "code1")
|
||||
}
|
||||
if !s.City1.IsUnset() {
|
||||
vals = append(vals, "city1")
|
||||
}
|
||||
if !s.ShapeLeng.IsUnset() {
|
||||
vals = append(vals, "shape_leng")
|
||||
}
|
||||
if !s.Address2.IsUnset() {
|
||||
vals = append(vals, "address2")
|
||||
}
|
||||
if !s.GeneralMG.IsUnset() {
|
||||
vals = append(vals, "general_mg")
|
||||
}
|
||||
if !s.City2.IsUnset() {
|
||||
vals = append(vals, "city2")
|
||||
}
|
||||
if !s.PostalC1.IsUnset() {
|
||||
vals = append(vals, "postal_c_1")
|
||||
}
|
||||
if !s.Fax2.IsUnset() {
|
||||
vals = append(vals, "fax2")
|
||||
}
|
||||
if !s.Phone2.IsUnset() {
|
||||
vals = append(vals, "phone2")
|
||||
}
|
||||
if !s.ShapeLe1.IsUnset() {
|
||||
vals = append(vals, "shape_le_1")
|
||||
}
|
||||
if !s.ShapeArea.IsUnset() {
|
||||
vals = append(vals, "shape_area")
|
||||
}
|
||||
if !s.Geom.IsUnset() {
|
||||
vals = append(vals, "geom")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
func (s DistrictSetter) Overwrite(t *District) {
|
||||
if s.Gid.IsValue() {
|
||||
t.Gid = s.Gid.MustGet()
|
||||
}
|
||||
if !s.ID.IsUnset() {
|
||||
t.ID = s.ID.MustGetNull()
|
||||
}
|
||||
if !s.Website.IsUnset() {
|
||||
t.Website = s.Website.MustGetNull()
|
||||
}
|
||||
if !s.Contact.IsUnset() {
|
||||
t.Contact = s.Contact.MustGetNull()
|
||||
}
|
||||
if !s.Address.IsUnset() {
|
||||
t.Address = s.Address.MustGetNull()
|
||||
}
|
||||
if !s.Regionid.IsUnset() {
|
||||
t.Regionid = s.Regionid.MustGetNull()
|
||||
}
|
||||
if !s.PostalCod.IsUnset() {
|
||||
t.PostalCod = s.PostalCod.MustGetNull()
|
||||
}
|
||||
if !s.Phone1.IsUnset() {
|
||||
t.Phone1 = s.Phone1.MustGetNull()
|
||||
}
|
||||
if !s.Fax1.IsUnset() {
|
||||
t.Fax1 = s.Fax1.MustGetNull()
|
||||
}
|
||||
if !s.Agency.IsUnset() {
|
||||
t.Agency = s.Agency.MustGetNull()
|
||||
}
|
||||
if !s.Code1.IsUnset() {
|
||||
t.Code1 = s.Code1.MustGetNull()
|
||||
}
|
||||
if !s.City1.IsUnset() {
|
||||
t.City1 = s.City1.MustGetNull()
|
||||
}
|
||||
if !s.ShapeLeng.IsUnset() {
|
||||
t.ShapeLeng = s.ShapeLeng.MustGetNull()
|
||||
}
|
||||
if !s.Address2.IsUnset() {
|
||||
t.Address2 = s.Address2.MustGetNull()
|
||||
}
|
||||
if !s.GeneralMG.IsUnset() {
|
||||
t.GeneralMG = s.GeneralMG.MustGetNull()
|
||||
}
|
||||
if !s.City2.IsUnset() {
|
||||
t.City2 = s.City2.MustGetNull()
|
||||
}
|
||||
if !s.PostalC1.IsUnset() {
|
||||
t.PostalC1 = s.PostalC1.MustGetNull()
|
||||
}
|
||||
if !s.Fax2.IsUnset() {
|
||||
t.Fax2 = s.Fax2.MustGetNull()
|
||||
}
|
||||
if !s.Phone2.IsUnset() {
|
||||
t.Phone2 = s.Phone2.MustGetNull()
|
||||
}
|
||||
if !s.ShapeLe1.IsUnset() {
|
||||
t.ShapeLe1 = s.ShapeLe1.MustGetNull()
|
||||
}
|
||||
if !s.ShapeArea.IsUnset() {
|
||||
t.ShapeArea = s.ShapeArea.MustGetNull()
|
||||
}
|
||||
if !s.Geom.IsUnset() {
|
||||
t.Geom = s.Geom.MustGetNull()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DistrictSetter) Apply(q *dialect.InsertQuery) {
|
||||
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
||||
return Districts.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, 22)
|
||||
if s.Gid.IsValue() {
|
||||
vals[0] = psql.Arg(s.Gid.MustGet())
|
||||
} else {
|
||||
vals[0] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ID.IsUnset() {
|
||||
vals[1] = psql.Arg(s.ID.MustGetNull())
|
||||
} else {
|
||||
vals[1] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Website.IsUnset() {
|
||||
vals[2] = psql.Arg(s.Website.MustGetNull())
|
||||
} else {
|
||||
vals[2] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Contact.IsUnset() {
|
||||
vals[3] = psql.Arg(s.Contact.MustGetNull())
|
||||
} else {
|
||||
vals[3] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Address.IsUnset() {
|
||||
vals[4] = psql.Arg(s.Address.MustGetNull())
|
||||
} else {
|
||||
vals[4] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Regionid.IsUnset() {
|
||||
vals[5] = psql.Arg(s.Regionid.MustGetNull())
|
||||
} else {
|
||||
vals[5] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.PostalCod.IsUnset() {
|
||||
vals[6] = psql.Arg(s.PostalCod.MustGetNull())
|
||||
} else {
|
||||
vals[6] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Phone1.IsUnset() {
|
||||
vals[7] = psql.Arg(s.Phone1.MustGetNull())
|
||||
} else {
|
||||
vals[7] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Fax1.IsUnset() {
|
||||
vals[8] = psql.Arg(s.Fax1.MustGetNull())
|
||||
} else {
|
||||
vals[8] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Agency.IsUnset() {
|
||||
vals[9] = psql.Arg(s.Agency.MustGetNull())
|
||||
} else {
|
||||
vals[9] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Code1.IsUnset() {
|
||||
vals[10] = psql.Arg(s.Code1.MustGetNull())
|
||||
} else {
|
||||
vals[10] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.City1.IsUnset() {
|
||||
vals[11] = psql.Arg(s.City1.MustGetNull())
|
||||
} else {
|
||||
vals[11] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ShapeLeng.IsUnset() {
|
||||
vals[12] = psql.Arg(s.ShapeLeng.MustGetNull())
|
||||
} else {
|
||||
vals[12] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Address2.IsUnset() {
|
||||
vals[13] = psql.Arg(s.Address2.MustGetNull())
|
||||
} else {
|
||||
vals[13] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.GeneralMG.IsUnset() {
|
||||
vals[14] = psql.Arg(s.GeneralMG.MustGetNull())
|
||||
} else {
|
||||
vals[14] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.City2.IsUnset() {
|
||||
vals[15] = psql.Arg(s.City2.MustGetNull())
|
||||
} else {
|
||||
vals[15] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.PostalC1.IsUnset() {
|
||||
vals[16] = psql.Arg(s.PostalC1.MustGetNull())
|
||||
} else {
|
||||
vals[16] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Fax2.IsUnset() {
|
||||
vals[17] = psql.Arg(s.Fax2.MustGetNull())
|
||||
} else {
|
||||
vals[17] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Phone2.IsUnset() {
|
||||
vals[18] = psql.Arg(s.Phone2.MustGetNull())
|
||||
} else {
|
||||
vals[18] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ShapeLe1.IsUnset() {
|
||||
vals[19] = psql.Arg(s.ShapeLe1.MustGetNull())
|
||||
} else {
|
||||
vals[19] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ShapeArea.IsUnset() {
|
||||
vals[20] = psql.Arg(s.ShapeArea.MustGetNull())
|
||||
} else {
|
||||
vals[20] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Geom.IsUnset() {
|
||||
vals[21] = psql.Arg(s.Geom.MustGetNull())
|
||||
} else {
|
||||
vals[21] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
||||
func (s DistrictSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
||||
return um.Set(s.Expressions()...)
|
||||
}
|
||||
|
||||
func (s DistrictSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 22)
|
||||
|
||||
if s.Gid.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "gid")...),
|
||||
psql.Arg(s.Gid),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.ID.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "id")...),
|
||||
psql.Arg(s.ID),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Website.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "website")...),
|
||||
psql.Arg(s.Website),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Contact.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "contact")...),
|
||||
psql.Arg(s.Contact),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Address.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "address")...),
|
||||
psql.Arg(s.Address),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Regionid.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "regionid")...),
|
||||
psql.Arg(s.Regionid),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.PostalCod.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "postal_cod")...),
|
||||
psql.Arg(s.PostalCod),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Phone1.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "phone1")...),
|
||||
psql.Arg(s.Phone1),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Fax1.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "fax1")...),
|
||||
psql.Arg(s.Fax1),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Agency.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "agency")...),
|
||||
psql.Arg(s.Agency),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Code1.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "code1")...),
|
||||
psql.Arg(s.Code1),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.City1.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "city1")...),
|
||||
psql.Arg(s.City1),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.ShapeLeng.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "shape_leng")...),
|
||||
psql.Arg(s.ShapeLeng),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Address2.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "address2")...),
|
||||
psql.Arg(s.Address2),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.GeneralMG.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "general_mg")...),
|
||||
psql.Arg(s.GeneralMG),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.City2.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "city2")...),
|
||||
psql.Arg(s.City2),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.PostalC1.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "postal_c_1")...),
|
||||
psql.Arg(s.PostalC1),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Fax2.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "fax2")...),
|
||||
psql.Arg(s.Fax2),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Phone2.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "phone2")...),
|
||||
psql.Arg(s.Phone2),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.ShapeLe1.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "shape_le_1")...),
|
||||
psql.Arg(s.ShapeLe1),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.ShapeArea.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "shape_area")...),
|
||||
psql.Arg(s.ShapeArea),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.Geom.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "geom")...),
|
||||
psql.Arg(s.Geom),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
// FindDistrict retrieves a single record by primary key
|
||||
// If cols is empty Find will return all columns.
|
||||
func FindDistrict(ctx context.Context, exec bob.Executor, GidPK int32, cols ...string) (*District, error) {
|
||||
if len(cols) == 0 {
|
||||
return Districts.Query(
|
||||
sm.Where(Districts.Columns.Gid.EQ(psql.Arg(GidPK))),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
return Districts.Query(
|
||||
sm.Where(Districts.Columns.Gid.EQ(psql.Arg(GidPK))),
|
||||
sm.Columns(Districts.Columns.Only(cols...)),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
// DistrictExists checks the presence of a single record by primary key
|
||||
func DistrictExists(ctx context.Context, exec bob.Executor, GidPK int32) (bool, error) {
|
||||
return Districts.Query(
|
||||
sm.Where(Districts.Columns.Gid.EQ(psql.Arg(GidPK))),
|
||||
).Exists(ctx, exec)
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after District is retrieved from the database
|
||||
func (o *District) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = Districts.AfterSelectHooks.RunHooks(ctx, exec, DistrictSlice{o})
|
||||
case bob.QueryTypeInsert:
|
||||
ctx, err = Districts.AfterInsertHooks.RunHooks(ctx, exec, DistrictSlice{o})
|
||||
case bob.QueryTypeUpdate:
|
||||
ctx, err = Districts.AfterUpdateHooks.RunHooks(ctx, exec, DistrictSlice{o})
|
||||
case bob.QueryTypeDelete:
|
||||
ctx, err = Districts.AfterDeleteHooks.RunHooks(ctx, exec, DistrictSlice{o})
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// primaryKeyVals returns the primary key values of the District
|
||||
func (o *District) primaryKeyVals() bob.Expression {
|
||||
return psql.Arg(o.Gid)
|
||||
}
|
||||
|
||||
func (o *District) pkEQ() dialect.Expression {
|
||||
return psql.Quote("district", "gid").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 District
|
||||
func (o *District) Update(ctx context.Context, exec bob.Executor, s *DistrictSetter) error {
|
||||
v, err := Districts.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*o = *v
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes a single District record with an executor
|
||||
func (o *District) Delete(ctx context.Context, exec bob.Executor) error {
|
||||
_, err := Districts.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
||||
return err
|
||||
}
|
||||
|
||||
// Reload refreshes the District using the executor
|
||||
func (o *District) Reload(ctx context.Context, exec bob.Executor) error {
|
||||
o2, err := Districts.Query(
|
||||
sm.Where(Districts.Columns.Gid.EQ(psql.Arg(o.Gid))),
|
||||
).One(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*o = *o2
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after DistrictSlice is retrieved from the database
|
||||
func (o DistrictSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = Districts.AfterSelectHooks.RunHooks(ctx, exec, o)
|
||||
case bob.QueryTypeInsert:
|
||||
ctx, err = Districts.AfterInsertHooks.RunHooks(ctx, exec, o)
|
||||
case bob.QueryTypeUpdate:
|
||||
ctx, err = Districts.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
||||
case bob.QueryTypeDelete:
|
||||
ctx, err = Districts.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (o DistrictSlice) pkIN() dialect.Expression {
|
||||
if len(o) == 0 {
|
||||
return psql.Raw("NULL")
|
||||
}
|
||||
|
||||
return psql.Quote("district", "gid").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 DistrictSlice) copyMatchingRows(from ...*District) {
|
||||
for i, old := range o {
|
||||
for _, new := range from {
|
||||
if new.Gid != old.Gid {
|
||||
continue
|
||||
}
|
||||
|
||||
o[i] = new
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
|
||||
func (o DistrictSlice) 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 Districts.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 *District:
|
||||
o.copyMatchingRows(retrieved)
|
||||
case []*District:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
case DistrictSlice:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
default:
|
||||
// If the retrieved value is not a District or a slice of District
|
||||
// then run the AfterUpdateHooks on the slice
|
||||
_, err = Districts.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}))
|
||||
|
||||
q.AppendWhere(o.pkIN())
|
||||
})
|
||||
}
|
||||
|
||||
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
||||
func (o DistrictSlice) 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 Districts.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 *District:
|
||||
o.copyMatchingRows(retrieved)
|
||||
case []*District:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
case DistrictSlice:
|
||||
o.copyMatchingRows(retrieved...)
|
||||
default:
|
||||
// If the retrieved value is not a District or a slice of District
|
||||
// then run the AfterDeleteHooks on the slice
|
||||
_, err = Districts.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}))
|
||||
|
||||
q.AppendWhere(o.pkIN())
|
||||
})
|
||||
}
|
||||
|
||||
func (o DistrictSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals DistrictSetter) error {
|
||||
if len(o) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := Districts.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
||||
return err
|
||||
}
|
||||
|
||||
func (o DistrictSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
||||
if len(o) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := Districts.Delete(o.DeleteMod()).Exec(ctx, exec)
|
||||
return err
|
||||
}
|
||||
|
||||
func (o DistrictSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
||||
if len(o) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
o2, err := Districts.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.copyMatchingRows(o2...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type districtWhere[Q psql.Filterable] struct {
|
||||
Gid psql.WhereMod[Q, int32]
|
||||
ID psql.WhereNullMod[Q, decimal.Decimal]
|
||||
Website psql.WhereNullMod[Q, string]
|
||||
Contact psql.WhereNullMod[Q, string]
|
||||
Address psql.WhereNullMod[Q, string]
|
||||
Regionid psql.WhereNullMod[Q, decimal.Decimal]
|
||||
PostalCod psql.WhereNullMod[Q, decimal.Decimal]
|
||||
Phone1 psql.WhereNullMod[Q, string]
|
||||
Fax1 psql.WhereNullMod[Q, string]
|
||||
Agency psql.WhereNullMod[Q, string]
|
||||
Code1 psql.WhereNullMod[Q, string]
|
||||
City1 psql.WhereNullMod[Q, string]
|
||||
ShapeLeng psql.WhereNullMod[Q, decimal.Decimal]
|
||||
Address2 psql.WhereNullMod[Q, string]
|
||||
GeneralMG psql.WhereNullMod[Q, string]
|
||||
City2 psql.WhereNullMod[Q, string]
|
||||
PostalC1 psql.WhereNullMod[Q, decimal.Decimal]
|
||||
Fax2 psql.WhereNullMod[Q, string]
|
||||
Phone2 psql.WhereNullMod[Q, string]
|
||||
ShapeLe1 psql.WhereNullMod[Q, decimal.Decimal]
|
||||
ShapeArea psql.WhereNullMod[Q, decimal.Decimal]
|
||||
Geom psql.WhereNullMod[Q, string]
|
||||
}
|
||||
|
||||
func (districtWhere[Q]) AliasedAs(alias string) districtWhere[Q] {
|
||||
return buildDistrictWhere[Q](buildDistrictColumns(alias))
|
||||
}
|
||||
|
||||
func buildDistrictWhere[Q psql.Filterable](cols districtColumns) districtWhere[Q] {
|
||||
return districtWhere[Q]{
|
||||
Gid: psql.Where[Q, int32](cols.Gid),
|
||||
ID: psql.WhereNull[Q, decimal.Decimal](cols.ID),
|
||||
Website: psql.WhereNull[Q, string](cols.Website),
|
||||
Contact: psql.WhereNull[Q, string](cols.Contact),
|
||||
Address: psql.WhereNull[Q, string](cols.Address),
|
||||
Regionid: psql.WhereNull[Q, decimal.Decimal](cols.Regionid),
|
||||
PostalCod: psql.WhereNull[Q, decimal.Decimal](cols.PostalCod),
|
||||
Phone1: psql.WhereNull[Q, string](cols.Phone1),
|
||||
Fax1: psql.WhereNull[Q, string](cols.Fax1),
|
||||
Agency: psql.WhereNull[Q, string](cols.Agency),
|
||||
Code1: psql.WhereNull[Q, string](cols.Code1),
|
||||
City1: psql.WhereNull[Q, string](cols.City1),
|
||||
ShapeLeng: psql.WhereNull[Q, decimal.Decimal](cols.ShapeLeng),
|
||||
Address2: psql.WhereNull[Q, string](cols.Address2),
|
||||
GeneralMG: psql.WhereNull[Q, string](cols.GeneralMG),
|
||||
City2: psql.WhereNull[Q, string](cols.City2),
|
||||
PostalC1: psql.WhereNull[Q, decimal.Decimal](cols.PostalC1),
|
||||
Fax2: psql.WhereNull[Q, string](cols.Fax2),
|
||||
Phone2: psql.WhereNull[Q, string](cols.Phone2),
|
||||
ShapeLe1: psql.WhereNull[Q, decimal.Decimal](cols.ShapeLe1),
|
||||
ShapeArea: psql.WhereNull[Q, decimal.Decimal](cols.ShapeArea),
|
||||
Geom: psql.WhereNull[Q, string](cols.Geom),
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,9 @@ import (
|
|||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
"github.com/stephenafamo/bob"
|
||||
"github.com/stephenafamo/bob/dialect/psql"
|
||||
"github.com/stephenafamo/bob/dialect/psql/dialect"
|
||||
|
|
@ -27,7 +29,7 @@ type PublicreportNuisance struct {
|
|||
Duration enums.PublicreportNuisancedurationtype `db:"duration" `
|
||||
Email string `db:"email" `
|
||||
InspectionType enums.PublicreportNuisanceinspectiontype `db:"inspection_type" `
|
||||
Location enums.PublicreportNuisancelocationtype `db:"location" `
|
||||
SourceLocation enums.PublicreportNuisancelocationtype `db:"source_location" `
|
||||
PreferredDateRange enums.PublicreportNuisancepreferreddaterangetype `db:"preferred_date_range" `
|
||||
PreferredTime enums.PublicreportNuisancepreferredtimetype `db:"preferred_time" `
|
||||
RequestCall bool `db:"request_call" `
|
||||
|
|
@ -45,6 +47,9 @@ type PublicreportNuisance struct {
|
|||
ReporterEmail string `db:"reporter_email" `
|
||||
ReporterName string `db:"reporter_name" `
|
||||
ReporterPhone string `db:"reporter_phone" `
|
||||
Address string `db:"address" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
Status enums.PublicreportReportstatustype `db:"status" `
|
||||
}
|
||||
|
||||
// PublicreportNuisanceSlice is an alias for a slice of pointers to PublicreportNuisance.
|
||||
|
|
@ -60,7 +65,7 @@ type PublicreportNuisancesQuery = *psql.ViewQuery[*PublicreportNuisance, Publicr
|
|||
func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns {
|
||||
return publicreportNuisanceColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "additional_info", "created", "duration", "email", "inspection_type", "location", "preferred_date_range", "preferred_time", "request_call", "severity", "source_container", "source_description", "source_roof", "source_stagnant", "time_of_day_day", "time_of_day_early", "time_of_day_evening", "time_of_day_night", "public_id", "reporter_address", "reporter_email", "reporter_name", "reporter_phone",
|
||||
"id", "additional_info", "created", "duration", "email", "inspection_type", "source_location", "preferred_date_range", "preferred_time", "request_call", "severity", "source_container", "source_description", "source_roof", "source_stagnant", "time_of_day_day", "time_of_day_early", "time_of_day_evening", "time_of_day_night", "public_id", "reporter_address", "reporter_email", "reporter_name", "reporter_phone", "address", "location", "status",
|
||||
).WithParent("publicreport.nuisance"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -69,7 +74,7 @@ func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns
|
|||
Duration: psql.Quote(alias, "duration"),
|
||||
Email: psql.Quote(alias, "email"),
|
||||
InspectionType: psql.Quote(alias, "inspection_type"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
SourceLocation: psql.Quote(alias, "source_location"),
|
||||
PreferredDateRange: psql.Quote(alias, "preferred_date_range"),
|
||||
PreferredTime: psql.Quote(alias, "preferred_time"),
|
||||
RequestCall: psql.Quote(alias, "request_call"),
|
||||
|
|
@ -87,6 +92,9 @@ func buildPublicreportNuisanceColumns(alias string) publicreportNuisanceColumns
|
|||
ReporterEmail: psql.Quote(alias, "reporter_email"),
|
||||
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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +107,7 @@ type publicreportNuisanceColumns struct {
|
|||
Duration psql.Expression
|
||||
Email psql.Expression
|
||||
InspectionType psql.Expression
|
||||
Location psql.Expression
|
||||
SourceLocation psql.Expression
|
||||
PreferredDateRange psql.Expression
|
||||
PreferredTime psql.Expression
|
||||
RequestCall psql.Expression
|
||||
|
|
@ -117,6 +125,9 @@ type publicreportNuisanceColumns struct {
|
|||
ReporterEmail psql.Expression
|
||||
ReporterName psql.Expression
|
||||
ReporterPhone psql.Expression
|
||||
Address psql.Expression
|
||||
Location psql.Expression
|
||||
Status psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportNuisanceColumns) Alias() string {
|
||||
|
|
@ -137,7 +148,7 @@ type PublicreportNuisanceSetter struct {
|
|||
Duration omit.Val[enums.PublicreportNuisancedurationtype] `db:"duration" `
|
||||
Email omit.Val[string] `db:"email" `
|
||||
InspectionType omit.Val[enums.PublicreportNuisanceinspectiontype] `db:"inspection_type" `
|
||||
Location omit.Val[enums.PublicreportNuisancelocationtype] `db:"location" `
|
||||
SourceLocation omit.Val[enums.PublicreportNuisancelocationtype] `db:"source_location" `
|
||||
PreferredDateRange omit.Val[enums.PublicreportNuisancepreferreddaterangetype] `db:"preferred_date_range" `
|
||||
PreferredTime omit.Val[enums.PublicreportNuisancepreferredtimetype] `db:"preferred_time" `
|
||||
RequestCall omit.Val[bool] `db:"request_call" `
|
||||
|
|
@ -155,10 +166,13 @@ type PublicreportNuisanceSetter struct {
|
|||
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
||||
ReporterName omit.Val[string] `db:"reporter_name" `
|
||||
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
||||
Address omit.Val[string] `db:"address" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
}
|
||||
|
||||
func (s PublicreportNuisanceSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 24)
|
||||
vals := make([]string, 0, 27)
|
||||
if s.ID.IsValue() {
|
||||
vals = append(vals, "id")
|
||||
}
|
||||
|
|
@ -177,8 +191,8 @@ func (s PublicreportNuisanceSetter) SetColumns() []string {
|
|||
if s.InspectionType.IsValue() {
|
||||
vals = append(vals, "inspection_type")
|
||||
}
|
||||
if s.Location.IsValue() {
|
||||
vals = append(vals, "location")
|
||||
if s.SourceLocation.IsValue() {
|
||||
vals = append(vals, "source_location")
|
||||
}
|
||||
if s.PreferredDateRange.IsValue() {
|
||||
vals = append(vals, "preferred_date_range")
|
||||
|
|
@ -231,6 +245,15 @@ func (s PublicreportNuisanceSetter) SetColumns() []string {
|
|||
if s.ReporterPhone.IsValue() {
|
||||
vals = append(vals, "reporter_phone")
|
||||
}
|
||||
if s.Address.IsValue() {
|
||||
vals = append(vals, "address")
|
||||
}
|
||||
if !s.Location.IsUnset() {
|
||||
vals = append(vals, "location")
|
||||
}
|
||||
if s.Status.IsValue() {
|
||||
vals = append(vals, "status")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -253,8 +276,8 @@ func (s PublicreportNuisanceSetter) Overwrite(t *PublicreportNuisance) {
|
|||
if s.InspectionType.IsValue() {
|
||||
t.InspectionType = s.InspectionType.MustGet()
|
||||
}
|
||||
if s.Location.IsValue() {
|
||||
t.Location = s.Location.MustGet()
|
||||
if s.SourceLocation.IsValue() {
|
||||
t.SourceLocation = s.SourceLocation.MustGet()
|
||||
}
|
||||
if s.PreferredDateRange.IsValue() {
|
||||
t.PreferredDateRange = s.PreferredDateRange.MustGet()
|
||||
|
|
@ -307,6 +330,15 @@ func (s PublicreportNuisanceSetter) Overwrite(t *PublicreportNuisance) {
|
|||
if s.ReporterPhone.IsValue() {
|
||||
t.ReporterPhone = s.ReporterPhone.MustGet()
|
||||
}
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -315,7 +347,7 @@ func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
|||
})
|
||||
|
||||
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
vals := make([]bob.Expression, 24)
|
||||
vals := make([]bob.Expression, 27)
|
||||
if s.ID.IsValue() {
|
||||
vals[0] = psql.Arg(s.ID.MustGet())
|
||||
} else {
|
||||
|
|
@ -352,8 +384,8 @@ func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[5] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Location.IsValue() {
|
||||
vals[6] = psql.Arg(s.Location.MustGet())
|
||||
if s.SourceLocation.IsValue() {
|
||||
vals[6] = psql.Arg(s.SourceLocation.MustGet())
|
||||
} else {
|
||||
vals[6] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
|
@ -460,6 +492,24 @@ func (s *PublicreportNuisanceSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[23] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Address.IsValue() {
|
||||
vals[24] = psql.Arg(s.Address.MustGet())
|
||||
} else {
|
||||
vals[24] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.Location.IsUnset() {
|
||||
vals[25] = psql.Arg(s.Location.MustGetNull())
|
||||
} else {
|
||||
vals[25] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
vals[26] = psql.Arg(s.Status.MustGet())
|
||||
} else {
|
||||
vals[26] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -469,7 +519,7 @@ func (s PublicreportNuisanceSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 24)
|
||||
exprs := make([]bob.Expression, 0, 27)
|
||||
|
||||
if s.ID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -513,10 +563,10 @@ func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expressi
|
|||
}})
|
||||
}
|
||||
|
||||
if s.Location.IsValue() {
|
||||
if s.SourceLocation.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "location")...),
|
||||
psql.Arg(s.Location),
|
||||
psql.Quote(append(prefix, "source_location")...),
|
||||
psql.Arg(s.SourceLocation),
|
||||
}})
|
||||
}
|
||||
|
||||
|
|
@ -639,6 +689,27 @@ func (s PublicreportNuisanceSetter) Expressions(prefix ...string) []bob.Expressi
|
|||
}})
|
||||
}
|
||||
|
||||
if s.Address.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "address")...),
|
||||
psql.Arg(s.Address),
|
||||
}})
|
||||
}
|
||||
|
||||
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")...),
|
||||
psql.Arg(s.Status),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
@ -871,7 +942,7 @@ type publicreportNuisanceWhere[Q psql.Filterable] struct {
|
|||
Duration psql.WhereMod[Q, enums.PublicreportNuisancedurationtype]
|
||||
Email psql.WhereMod[Q, string]
|
||||
InspectionType psql.WhereMod[Q, enums.PublicreportNuisanceinspectiontype]
|
||||
Location psql.WhereMod[Q, enums.PublicreportNuisancelocationtype]
|
||||
SourceLocation psql.WhereMod[Q, enums.PublicreportNuisancelocationtype]
|
||||
PreferredDateRange psql.WhereMod[Q, enums.PublicreportNuisancepreferreddaterangetype]
|
||||
PreferredTime psql.WhereMod[Q, enums.PublicreportNuisancepreferredtimetype]
|
||||
RequestCall psql.WhereMod[Q, bool]
|
||||
|
|
@ -889,6 +960,9 @@ type publicreportNuisanceWhere[Q psql.Filterable] struct {
|
|||
ReporterEmail psql.WhereMod[Q, string]
|
||||
ReporterName psql.WhereMod[Q, string]
|
||||
ReporterPhone psql.WhereMod[Q, string]
|
||||
Address psql.WhereMod[Q, string]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
||||
}
|
||||
|
||||
func (publicreportNuisanceWhere[Q]) AliasedAs(alias string) publicreportNuisanceWhere[Q] {
|
||||
|
|
@ -903,7 +977,7 @@ func buildPublicreportNuisanceWhere[Q psql.Filterable](cols publicreportNuisance
|
|||
Duration: psql.Where[Q, enums.PublicreportNuisancedurationtype](cols.Duration),
|
||||
Email: psql.Where[Q, string](cols.Email),
|
||||
InspectionType: psql.Where[Q, enums.PublicreportNuisanceinspectiontype](cols.InspectionType),
|
||||
Location: psql.Where[Q, enums.PublicreportNuisancelocationtype](cols.Location),
|
||||
SourceLocation: psql.Where[Q, enums.PublicreportNuisancelocationtype](cols.SourceLocation),
|
||||
PreferredDateRange: psql.Where[Q, enums.PublicreportNuisancepreferreddaterangetype](cols.PreferredDateRange),
|
||||
PreferredTime: psql.Where[Q, enums.PublicreportNuisancepreferredtimetype](cols.PreferredTime),
|
||||
RequestCall: psql.Where[Q, bool](cols.RequestCall),
|
||||
|
|
@ -921,5 +995,8 @@ func buildPublicreportNuisanceWhere[Q psql.Filterable](cols publicreportNuisance
|
|||
ReporterEmail: psql.Where[Q, string](cols.ReporterEmail),
|
||||
ReporterName: psql.Where[Q, string](cols.ReporterName),
|
||||
ReporterPhone: psql.Where[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),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"io"
|
||||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
|
|
@ -26,35 +27,36 @@ import (
|
|||
|
||||
// PublicreportPool is an object representing the database table.
|
||||
type PublicreportPool struct {
|
||||
ID int32 `db:"id,pk" `
|
||||
AccessComments string `db:"access_comments" `
|
||||
AccessGate bool `db:"access_gate" `
|
||||
AccessFence bool `db:"access_fence" `
|
||||
AccessLocked bool `db:"access_locked" `
|
||||
AccessDog bool `db:"access_dog" `
|
||||
AccessOther bool `db:"access_other" `
|
||||
Address string `db:"address" `
|
||||
AddressCountry string `db:"address_country" `
|
||||
AddressPostCode string `db:"address_post_code" `
|
||||
AddressPlace string `db:"address_place" `
|
||||
AddressStreet string `db:"address_street" `
|
||||
AddressRegion string `db:"address_region" `
|
||||
Comments string `db:"comments" `
|
||||
Created time.Time `db:"created" `
|
||||
H3cell null.Val[string] `db:"h3cell" `
|
||||
HasAdult bool `db:"has_adult" `
|
||||
HasLarvae bool `db:"has_larvae" `
|
||||
HasPupae bool `db:"has_pupae" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
MapZoom float64 `db:"map_zoom" `
|
||||
OwnerEmail string `db:"owner_email" `
|
||||
OwnerName string `db:"owner_name" `
|
||||
OwnerPhone string `db:"owner_phone" `
|
||||
PublicID string `db:"public_id" `
|
||||
ReporterEmail string `db:"reporter_email" `
|
||||
ReporterName string `db:"reporter_name" `
|
||||
ReporterPhone string `db:"reporter_phone" `
|
||||
Subscribe bool `db:"subscribe" `
|
||||
ID int32 `db:"id,pk" `
|
||||
AccessComments string `db:"access_comments" `
|
||||
AccessGate bool `db:"access_gate" `
|
||||
AccessFence bool `db:"access_fence" `
|
||||
AccessLocked bool `db:"access_locked" `
|
||||
AccessDog bool `db:"access_dog" `
|
||||
AccessOther bool `db:"access_other" `
|
||||
Address string `db:"address" `
|
||||
AddressCountry string `db:"address_country" `
|
||||
AddressPostCode string `db:"address_post_code" `
|
||||
AddressPlace string `db:"address_place" `
|
||||
AddressStreet string `db:"address_street" `
|
||||
AddressRegion string `db:"address_region" `
|
||||
Comments string `db:"comments" `
|
||||
Created time.Time `db:"created" `
|
||||
H3cell null.Val[string] `db:"h3cell" `
|
||||
HasAdult bool `db:"has_adult" `
|
||||
HasLarvae bool `db:"has_larvae" `
|
||||
HasPupae bool `db:"has_pupae" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
MapZoom float64 `db:"map_zoom" `
|
||||
OwnerEmail string `db:"owner_email" `
|
||||
OwnerName string `db:"owner_name" `
|
||||
OwnerPhone string `db:"owner_phone" `
|
||||
PublicID string `db:"public_id" `
|
||||
ReporterEmail string `db:"reporter_email" `
|
||||
ReporterName string `db:"reporter_name" `
|
||||
ReporterPhone string `db:"reporter_phone" `
|
||||
Subscribe bool `db:"subscribe" `
|
||||
Status enums.PublicreportReportstatustype `db:"status" `
|
||||
|
||||
R publicreportPoolR `db:"-" `
|
||||
}
|
||||
|
|
@ -77,7 +79,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", "subscribe",
|
||||
"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", "subscribe", "status",
|
||||
).WithParent("publicreport.pool"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -109,6 +111,7 @@ func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
|
|||
ReporterName: psql.Quote(alias, "reporter_name"),
|
||||
ReporterPhone: psql.Quote(alias, "reporter_phone"),
|
||||
Subscribe: psql.Quote(alias, "subscribe"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,6 +147,7 @@ type publicreportPoolColumns struct {
|
|||
ReporterName psql.Expression
|
||||
ReporterPhone psql.Expression
|
||||
Subscribe psql.Expression
|
||||
Status psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportPoolColumns) Alias() string {
|
||||
|
|
@ -158,39 +162,40 @@ func (publicreportPoolColumns) AliasedAs(alias string) publicreportPoolColumns {
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type PublicreportPoolSetter struct {
|
||||
ID omit.Val[int32] `db:"id,pk" `
|
||||
AccessComments omit.Val[string] `db:"access_comments" `
|
||||
AccessGate omit.Val[bool] `db:"access_gate" `
|
||||
AccessFence omit.Val[bool] `db:"access_fence" `
|
||||
AccessLocked omit.Val[bool] `db:"access_locked" `
|
||||
AccessDog omit.Val[bool] `db:"access_dog" `
|
||||
AccessOther omit.Val[bool] `db:"access_other" `
|
||||
Address omit.Val[string] `db:"address" `
|
||||
AddressCountry omit.Val[string] `db:"address_country" `
|
||||
AddressPostCode omit.Val[string] `db:"address_post_code" `
|
||||
AddressPlace omit.Val[string] `db:"address_place" `
|
||||
AddressStreet omit.Val[string] `db:"address_street" `
|
||||
AddressRegion omit.Val[string] `db:"address_region" `
|
||||
Comments omit.Val[string] `db:"comments" `
|
||||
Created omit.Val[time.Time] `db:"created" `
|
||||
H3cell omitnull.Val[string] `db:"h3cell" `
|
||||
HasAdult omit.Val[bool] `db:"has_adult" `
|
||||
HasLarvae omit.Val[bool] `db:"has_larvae" `
|
||||
HasPupae omit.Val[bool] `db:"has_pupae" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
MapZoom omit.Val[float64] `db:"map_zoom" `
|
||||
OwnerEmail omit.Val[string] `db:"owner_email" `
|
||||
OwnerName omit.Val[string] `db:"owner_name" `
|
||||
OwnerPhone omit.Val[string] `db:"owner_phone" `
|
||||
PublicID omit.Val[string] `db:"public_id" `
|
||||
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
||||
ReporterName omit.Val[string] `db:"reporter_name" `
|
||||
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
||||
Subscribe omit.Val[bool] `db:"subscribe" `
|
||||
ID omit.Val[int32] `db:"id,pk" `
|
||||
AccessComments omit.Val[string] `db:"access_comments" `
|
||||
AccessGate omit.Val[bool] `db:"access_gate" `
|
||||
AccessFence omit.Val[bool] `db:"access_fence" `
|
||||
AccessLocked omit.Val[bool] `db:"access_locked" `
|
||||
AccessDog omit.Val[bool] `db:"access_dog" `
|
||||
AccessOther omit.Val[bool] `db:"access_other" `
|
||||
Address omit.Val[string] `db:"address" `
|
||||
AddressCountry omit.Val[string] `db:"address_country" `
|
||||
AddressPostCode omit.Val[string] `db:"address_post_code" `
|
||||
AddressPlace omit.Val[string] `db:"address_place" `
|
||||
AddressStreet omit.Val[string] `db:"address_street" `
|
||||
AddressRegion omit.Val[string] `db:"address_region" `
|
||||
Comments omit.Val[string] `db:"comments" `
|
||||
Created omit.Val[time.Time] `db:"created" `
|
||||
H3cell omitnull.Val[string] `db:"h3cell" `
|
||||
HasAdult omit.Val[bool] `db:"has_adult" `
|
||||
HasLarvae omit.Val[bool] `db:"has_larvae" `
|
||||
HasPupae omit.Val[bool] `db:"has_pupae" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
MapZoom omit.Val[float64] `db:"map_zoom" `
|
||||
OwnerEmail omit.Val[string] `db:"owner_email" `
|
||||
OwnerName omit.Val[string] `db:"owner_name" `
|
||||
OwnerPhone omit.Val[string] `db:"owner_phone" `
|
||||
PublicID omit.Val[string] `db:"public_id" `
|
||||
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
||||
ReporterName omit.Val[string] `db:"reporter_name" `
|
||||
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
||||
Subscribe omit.Val[bool] `db:"subscribe" `
|
||||
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
}
|
||||
|
||||
func (s PublicreportPoolSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 29)
|
||||
vals := make([]string, 0, 30)
|
||||
if s.ID.IsValue() {
|
||||
vals = append(vals, "id")
|
||||
}
|
||||
|
|
@ -278,6 +283,9 @@ func (s PublicreportPoolSetter) SetColumns() []string {
|
|||
if s.Subscribe.IsValue() {
|
||||
vals = append(vals, "subscribe")
|
||||
}
|
||||
if s.Status.IsValue() {
|
||||
vals = append(vals, "status")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -369,6 +377,9 @@ func (s PublicreportPoolSetter) Overwrite(t *PublicreportPool) {
|
|||
if s.Subscribe.IsValue() {
|
||||
t.Subscribe = s.Subscribe.MustGet()
|
||||
}
|
||||
if s.Status.IsValue() {
|
||||
t.Status = s.Status.MustGet()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -377,7 +388,7 @@ func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
|||
})
|
||||
|
||||
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
vals := make([]bob.Expression, 29)
|
||||
vals := make([]bob.Expression, 30)
|
||||
if s.ID.IsValue() {
|
||||
vals[0] = psql.Arg(s.ID.MustGet())
|
||||
} else {
|
||||
|
|
@ -552,6 +563,12 @@ func (s *PublicreportPoolSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[28] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
vals[29] = psql.Arg(s.Status.MustGet())
|
||||
} else {
|
||||
vals[29] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -561,7 +578,7 @@ func (s PublicreportPoolSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s PublicreportPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 29)
|
||||
exprs := make([]bob.Expression, 0, 30)
|
||||
|
||||
if s.ID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -766,6 +783,13 @@ func (s PublicreportPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
|||
}})
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "status")...),
|
||||
psql.Arg(s.Status),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
@ -1114,6 +1138,7 @@ type publicreportPoolWhere[Q psql.Filterable] struct {
|
|||
ReporterName psql.WhereMod[Q, string]
|
||||
ReporterPhone psql.WhereMod[Q, string]
|
||||
Subscribe psql.WhereMod[Q, bool]
|
||||
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
||||
}
|
||||
|
||||
func (publicreportPoolWhere[Q]) AliasedAs(alias string) publicreportPoolWhere[Q] {
|
||||
|
|
@ -1151,6 +1176,7 @@ func buildPublicreportPoolWhere[Q psql.Filterable](cols publicreportPoolColumns)
|
|||
ReporterName: psql.Where[Q, string](cols.ReporterName),
|
||||
ReporterPhone: psql.Where[Q, string](cols.ReporterPhone),
|
||||
Subscribe: psql.Where[Q, bool](cols.Subscribe),
|
||||
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"io"
|
||||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
|
|
@ -26,14 +27,16 @@ import (
|
|||
|
||||
// PublicreportQuick is an object representing the database table.
|
||||
type PublicreportQuick struct {
|
||||
ID int32 `db:"id,pk" `
|
||||
Created time.Time `db:"created" `
|
||||
Comments string `db:"comments" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
H3cell null.Val[string] `db:"h3cell" `
|
||||
PublicID string `db:"public_id" `
|
||||
ReporterEmail string `db:"reporter_email" `
|
||||
ReporterPhone string `db:"reporter_phone" `
|
||||
ID int32 `db:"id,pk" `
|
||||
Created time.Time `db:"created" `
|
||||
Comments string `db:"comments" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
H3cell null.Val[string] `db:"h3cell" `
|
||||
PublicID string `db:"public_id" `
|
||||
ReporterEmail string `db:"reporter_email" `
|
||||
ReporterPhone string `db:"reporter_phone" `
|
||||
Address string `db:"address" `
|
||||
Status enums.PublicreportReportstatustype `db:"status" `
|
||||
|
||||
R publicreportQuickR `db:"-" `
|
||||
}
|
||||
|
|
@ -56,7 +59,7 @@ type publicreportQuickR struct {
|
|||
func buildPublicreportQuickColumns(alias string) publicreportQuickColumns {
|
||||
return publicreportQuickColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "created", "comments", "location", "h3cell", "public_id", "reporter_email", "reporter_phone",
|
||||
"id", "created", "comments", "location", "h3cell", "public_id", "reporter_email", "reporter_phone", "address", "status",
|
||||
).WithParent("publicreport.quick"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
|
|
@ -67,6 +70,8 @@ func buildPublicreportQuickColumns(alias string) publicreportQuickColumns {
|
|||
PublicID: psql.Quote(alias, "public_id"),
|
||||
ReporterEmail: psql.Quote(alias, "reporter_email"),
|
||||
ReporterPhone: psql.Quote(alias, "reporter_phone"),
|
||||
Address: psql.Quote(alias, "address"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,6 +86,8 @@ type publicreportQuickColumns struct {
|
|||
PublicID psql.Expression
|
||||
ReporterEmail psql.Expression
|
||||
ReporterPhone psql.Expression
|
||||
Address psql.Expression
|
||||
Status psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportQuickColumns) Alias() string {
|
||||
|
|
@ -95,18 +102,20 @@ func (publicreportQuickColumns) AliasedAs(alias string) publicreportQuickColumns
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type PublicreportQuickSetter struct {
|
||||
ID omit.Val[int32] `db:"id,pk" `
|
||||
Created omit.Val[time.Time] `db:"created" `
|
||||
Comments omit.Val[string] `db:"comments" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
H3cell omitnull.Val[string] `db:"h3cell" `
|
||||
PublicID omit.Val[string] `db:"public_id" `
|
||||
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
||||
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
||||
ID omit.Val[int32] `db:"id,pk" `
|
||||
Created omit.Val[time.Time] `db:"created" `
|
||||
Comments omit.Val[string] `db:"comments" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
H3cell omitnull.Val[string] `db:"h3cell" `
|
||||
PublicID omit.Val[string] `db:"public_id" `
|
||||
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
||||
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
||||
Address omit.Val[string] `db:"address" `
|
||||
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
}
|
||||
|
||||
func (s PublicreportQuickSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 8)
|
||||
vals := make([]string, 0, 10)
|
||||
if s.ID.IsValue() {
|
||||
vals = append(vals, "id")
|
||||
}
|
||||
|
|
@ -131,6 +140,12 @@ func (s PublicreportQuickSetter) SetColumns() []string {
|
|||
if s.ReporterPhone.IsValue() {
|
||||
vals = append(vals, "reporter_phone")
|
||||
}
|
||||
if s.Address.IsValue() {
|
||||
vals = append(vals, "address")
|
||||
}
|
||||
if s.Status.IsValue() {
|
||||
vals = append(vals, "status")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -159,6 +174,12 @@ func (s PublicreportQuickSetter) Overwrite(t *PublicreportQuick) {
|
|||
if s.ReporterPhone.IsValue() {
|
||||
t.ReporterPhone = s.ReporterPhone.MustGet()
|
||||
}
|
||||
if s.Address.IsValue() {
|
||||
t.Address = s.Address.MustGet()
|
||||
}
|
||||
if s.Status.IsValue() {
|
||||
t.Status = s.Status.MustGet()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportQuickSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -167,7 +188,7 @@ func (s *PublicreportQuickSetter) Apply(q *dialect.InsertQuery) {
|
|||
})
|
||||
|
||||
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
vals := make([]bob.Expression, 8)
|
||||
vals := make([]bob.Expression, 10)
|
||||
if s.ID.IsValue() {
|
||||
vals[0] = psql.Arg(s.ID.MustGet())
|
||||
} else {
|
||||
|
|
@ -216,6 +237,18 @@ func (s *PublicreportQuickSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[7] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Address.IsValue() {
|
||||
vals[8] = psql.Arg(s.Address.MustGet())
|
||||
} else {
|
||||
vals[8] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
vals[9] = psql.Arg(s.Status.MustGet())
|
||||
} else {
|
||||
vals[9] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -225,7 +258,7 @@ func (s PublicreportQuickSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s PublicreportQuickSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 8)
|
||||
exprs := make([]bob.Expression, 0, 10)
|
||||
|
||||
if s.ID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -283,6 +316,20 @@ func (s PublicreportQuickSetter) Expressions(prefix ...string) []bob.Expression
|
|||
}})
|
||||
}
|
||||
|
||||
if s.Address.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "address")...),
|
||||
psql.Arg(s.Address),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.Status.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "status")...),
|
||||
psql.Arg(s.Status),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
@ -610,6 +657,8 @@ type publicreportQuickWhere[Q psql.Filterable] struct {
|
|||
PublicID psql.WhereMod[Q, string]
|
||||
ReporterEmail psql.WhereMod[Q, string]
|
||||
ReporterPhone psql.WhereMod[Q, string]
|
||||
Address psql.WhereMod[Q, string]
|
||||
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
|
||||
}
|
||||
|
||||
func (publicreportQuickWhere[Q]) AliasedAs(alias string) publicreportQuickWhere[Q] {
|
||||
|
|
@ -626,6 +675,8 @@ func buildPublicreportQuickWhere[Q psql.Filterable](cols publicreportQuickColumn
|
|||
PublicID: psql.Where[Q, string](cols.PublicID),
|
||||
ReporterEmail: psql.Where[Q, string](cols.ReporterEmail),
|
||||
ReporterPhone: psql.Where[Q, string](cols.ReporterPhone),
|
||||
Address: psql.Where[Q, string](cols.Address),
|
||||
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
122
db/models/publicreport.report_location.bob.go
Normal file
122
db/models/publicreport.report_location.bob.go
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/stephenafamo/bob"
|
||||
"github.com/stephenafamo/bob/dialect/psql"
|
||||
"github.com/stephenafamo/bob/expr"
|
||||
)
|
||||
|
||||
// PublicreportReportLocation is an object representing the database table.
|
||||
type PublicreportReportLocation struct {
|
||||
ID null.Val[int64] `db:"id" `
|
||||
TableName null.Val[string] `db:"table_name" `
|
||||
Address null.Val[string] `db:"address" `
|
||||
Created null.Val[time.Time] `db:"created" `
|
||||
Location null.Val[string] `db:"location" `
|
||||
PublicID null.Val[string] `db:"public_id" `
|
||||
Status null.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
}
|
||||
|
||||
// PublicreportReportLocationSlice is an alias for a slice of pointers to PublicreportReportLocation.
|
||||
// This should almost always be used instead of []*PublicreportReportLocation.
|
||||
type PublicreportReportLocationSlice []*PublicreportReportLocation
|
||||
|
||||
// PublicreportReportLocations contains methods to work with the report_location view
|
||||
var PublicreportReportLocations = psql.NewViewx[*PublicreportReportLocation, PublicreportReportLocationSlice]("publicreport", "report_location", buildPublicreportReportLocationColumns("publicreport.report_location"))
|
||||
|
||||
// PublicreportReportLocationsQuery is a query on the report_location view
|
||||
type PublicreportReportLocationsQuery = *psql.ViewQuery[*PublicreportReportLocation, PublicreportReportLocationSlice]
|
||||
|
||||
func buildPublicreportReportLocationColumns(alias string) publicreportReportLocationColumns {
|
||||
return publicreportReportLocationColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"id", "table_name", "address", "created", "location", "public_id", "status",
|
||||
).WithParent("publicreport.report_location"),
|
||||
tableAlias: alias,
|
||||
ID: psql.Quote(alias, "id"),
|
||||
TableName: psql.Quote(alias, "table_name"),
|
||||
Address: psql.Quote(alias, "address"),
|
||||
Created: psql.Quote(alias, "created"),
|
||||
Location: psql.Quote(alias, "location"),
|
||||
PublicID: psql.Quote(alias, "public_id"),
|
||||
Status: psql.Quote(alias, "status"),
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportReportLocationColumns struct {
|
||||
expr.ColumnsExpr
|
||||
tableAlias string
|
||||
ID psql.Expression
|
||||
TableName psql.Expression
|
||||
Address psql.Expression
|
||||
Created psql.Expression
|
||||
Location psql.Expression
|
||||
PublicID psql.Expression
|
||||
Status psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportReportLocationColumns) Alias() string {
|
||||
return c.tableAlias
|
||||
}
|
||||
|
||||
func (publicreportReportLocationColumns) AliasedAs(alias string) publicreportReportLocationColumns {
|
||||
return buildPublicreportReportLocationColumns(alias)
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportReportLocation is retrieved from the database
|
||||
func (o *PublicreportReportLocation) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportReportLocations.AfterSelectHooks.RunHooks(ctx, exec, PublicreportReportLocationSlice{o})
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportReportLocationSlice is retrieved from the database
|
||||
func (o PublicreportReportLocationSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportReportLocations.AfterSelectHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type publicreportReportLocationWhere[Q psql.Filterable] struct {
|
||||
ID psql.WhereNullMod[Q, int64]
|
||||
TableName psql.WhereNullMod[Q, string]
|
||||
Address psql.WhereNullMod[Q, string]
|
||||
Created psql.WhereNullMod[Q, time.Time]
|
||||
Location psql.WhereNullMod[Q, string]
|
||||
PublicID psql.WhereNullMod[Q, string]
|
||||
Status psql.WhereNullMod[Q, enums.PublicreportReportstatustype]
|
||||
}
|
||||
|
||||
func (publicreportReportLocationWhere[Q]) AliasedAs(alias string) publicreportReportLocationWhere[Q] {
|
||||
return buildPublicreportReportLocationWhere[Q](buildPublicreportReportLocationColumns(alias))
|
||||
}
|
||||
|
||||
func buildPublicreportReportLocationWhere[Q psql.Filterable](cols publicreportReportLocationColumns) publicreportReportLocationWhere[Q] {
|
||||
return publicreportReportLocationWhere[Q]{
|
||||
ID: psql.WhereNull[Q, int64](cols.ID),
|
||||
TableName: psql.WhereNull[Q, string](cols.TableName),
|
||||
Address: psql.WhereNull[Q, string](cols.Address),
|
||||
Created: psql.WhereNull[Q, time.Time](cols.Created),
|
||||
Location: psql.WhereNull[Q, string](cols.Location),
|
||||
PublicID: psql.WhereNull[Q, string](cols.PublicID),
|
||||
Status: psql.WhereNull[Q, enums.PublicreportReportstatustype](cols.Status),
|
||||
}
|
||||
}
|
||||
1
go.mod
1
go.mod
|
|
@ -21,6 +21,7 @@ require (
|
|||
github.com/minio/minio-go/v7 v7.0.97
|
||||
github.com/pressly/goose/v3 v3.26.0
|
||||
github.com/rs/zerolog v1.34.0
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/stephenafamo/bob v0.42.0
|
||||
github.com/stephenafamo/scan v0.7.0
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -172,6 +172,8 @@ github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah
|
|||
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
||||
github.com/shirou/gopsutil/v4 v4.25.5 h1:rtd9piuSMGeU8g1RMXjZs9y9luK5BwtnG7dZaQUJAsc=
|
||||
github.com/shirou/gopsutil/v4 v4.25.5/go.mod h1:PfybzyydfZcN+JMMjkF6Zb8Mq1A/VcogFFg7hj50W9c=
|
||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue