diff --git a/api/district.go b/api/district.go index 85499cbb..a323716d 100644 --- a/api/district.go +++ b/api/district.go @@ -33,20 +33,20 @@ func apiGetDistrict(w http.ResponseWriter, r *http.Request) { render.Render(w, r, errRender(fmt.Errorf("Failed to parse lng as float: %w", err))) return } - district, _, err := platform.DistrictForLocation(r.Context(), lng, lat) + org, err := platform.DistrictForLocation(r.Context(), lng, lat) if err != nil { render.Render(w, r, errRender(fmt.Errorf("Failed to get district: %w", err))) return } - if district == nil { + if org == nil { http.NotFound(w, r) return } d := ResponseDistrict{ - Agency: district.Agency.GetOr(""), - Manager: district.GeneralMG.GetOr(""), - Phone: district.Phone1.GetOr(""), - Website: district.Website.GetOr(""), + Agency: org.Name, + Manager: org.GeneralManagerName.GetOr(""), + Phone: org.OfficePhone.GetOr(""), + Website: org.Website.GetOr(""), } if err := render.Render(w, r, d); err != nil { render.Render(w, r, errRender(err)) diff --git a/db/bobgen.yaml b/db/bobgen.yaml index 3269b917..4effbb43 100644 --- a/db/bobgen.yaml +++ b/db/bobgen.yaml @@ -19,7 +19,6 @@ psql: - "arcgis" - "comms" - "fileupload" - - "import" - "public" - "publicreport" - "fieldseeker" diff --git a/db/dberrors/import.district.bob.go b/db/dberrors/import.district.bob.go deleted file mode 100644 index 61d0df39..00000000 --- a/db/dberrors/import.district.bob.go +++ /dev/null @@ -1,17 +0,0 @@ -// Code generated by BobGen psql v0.42.5. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dberrors - -var ImportDistrictErrors = &importDistrictErrors{ - ErrUniqueDistrictPkey: &UniqueConstraintError{ - schema: "import", - table: "district", - columns: []string{"gid"}, - s: "district_pkey", - }, -} - -type importDistrictErrors struct { - ErrUniqueDistrictPkey *UniqueConstraintError -} diff --git a/db/dberrors/organization.bob.go b/db/dberrors/organization.bob.go index d01bcc41..d69538b3 100644 --- a/db/dberrors/organization.bob.go +++ b/db/dberrors/organization.bob.go @@ -24,13 +24,6 @@ var OrganizationErrors = &organizationErrors{ columns: []string{"slug"}, s: "organization_slug_key", }, - - ErrUniqueOrganizationWebsiteKey: &UniqueConstraintError{ - schema: "", - table: "organization", - columns: []string{"website"}, - s: "organization_website_key", - }, } type organizationErrors struct { @@ -39,6 +32,4 @@ type organizationErrors struct { ErrUniqueOrganizationImportDistrictGidKey *UniqueConstraintError ErrUniqueOrganizationSlugKey *UniqueConstraintError - - ErrUniqueOrganizationWebsiteKey *UniqueConstraintError } diff --git a/db/dbinfo/import.district.bob.go b/db/dbinfo/import.district.bob.go deleted file mode 100644 index 30f44017..00000000 --- a/db/dbinfo/import.district.bob.go +++ /dev/null @@ -1,360 +0,0 @@ -// Code generated by BobGen psql v0.42.5. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package dbinfo - -import "github.com/aarondl/opt/null" - -var ImportDistricts = Table[ - importDistrictColumns, - importDistrictIndexes, - importDistrictForeignKeys, - importDistrictUniques, - importDistrictChecks, -]{ - Schema: "import", - Name: "district", - Columns: importDistrictColumns{ - Gid: column{ - Name: "gid", - DBType: "integer", - Default: "nextval('import.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, - }, - Geom4326: column{ - Name: "geom_4326", - DBType: "geometry", - Default: "GENERATED", - Comment: "", - Nullable: true, - Generated: true, - AutoIncr: false, - }, - Centroid4326: column{ - Name: "centroid_4326", - DBType: "geometry", - Default: "GENERATED", - Comment: "", - Nullable: true, - Generated: true, - AutoIncr: false, - }, - Extent4326: column{ - Name: "extent_4326", - DBType: "geometry", - Default: "GENERATED", - Comment: "", - Nullable: true, - Generated: true, - AutoIncr: false, - }, - Area4326SQM: column{ - Name: "area_4326_sqm", - DBType: "numeric", - Default: "GENERATED", - Comment: "", - Nullable: true, - Generated: true, - AutoIncr: false, - }, - }, - Indexes: importDistrictIndexes{ - 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 importDistrictColumns 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 - Geom4326 column - Centroid4326 column - Extent4326 column - Area4326SQM column -} - -func (c importDistrictColumns) 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, c.Geom4326, c.Centroid4326, c.Extent4326, c.Area4326SQM, - } -} - -type importDistrictIndexes struct { - DistrictPkey index - DistrictGeomIdx index -} - -func (i importDistrictIndexes) AsSlice() []index { - return []index{ - i.DistrictPkey, i.DistrictGeomIdx, - } -} - -type importDistrictForeignKeys struct{} - -func (f importDistrictForeignKeys) AsSlice() []foreignKey { - return []foreignKey{} -} - -type importDistrictUniques struct{} - -func (u importDistrictUniques) AsSlice() []constraint { - return []constraint{} -} - -type importDistrictChecks struct{} - -func (c importDistrictChecks) AsSlice() []check { - return []check{} -} diff --git a/db/dbinfo/organization.bob.go b/db/dbinfo/organization.bob.go index 8248f9fc..3a0089c2 100644 --- a/db/dbinfo/organization.bob.go +++ b/db/dbinfo/organization.bob.go @@ -96,6 +96,168 @@ var Organizations = Table[ Generated: false, AutoIncr: false, }, + GeneralManagerName: column{ + Name: "general_manager_name", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + MailingAddressCity: column{ + Name: "mailing_address_city", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + MailingAddressPostalCode: column{ + Name: "mailing_address_postal_code", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + MailingAddressStreet: column{ + Name: "mailing_address_street", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + OfficeAddressCity: column{ + Name: "office_address_city", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + OfficeAddressPostalCode: column{ + Name: "office_address_postal_code", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + OfficeAddressStreet: column{ + Name: "office_address_street", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + ServiceAreaGeometry: column{ + Name: "service_area_geometry", + DBType: "geometry", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + ServiceAreaSquareMeters: column{ + Name: "service_area_square_meters", + DBType: "numeric", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, + ServiceAreaCentroid: column{ + Name: "service_area_centroid", + DBType: "geometry", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, + ServiceAreaExtent: column{ + Name: "service_area_extent", + DBType: "geometry", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, + OfficeFax: column{ + Name: "office_fax", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + OfficePhone: column{ + Name: "office_phone", + DBType: "text", + Default: "NULL", + Comment: "", + Nullable: true, + Generated: false, + AutoIncr: false, + }, + ServiceAreaXmin: column{ + Name: "service_area_xmin", + DBType: "double precision", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, + ServiceAreaYmin: column{ + Name: "service_area_ymin", + DBType: "double precision", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, + ServiceAreaXmax: column{ + Name: "service_area_xmax", + DBType: "double precision", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, + ServiceAreaYmax: column{ + Name: "service_area_ymax", + DBType: "double precision", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, + ServiceAreaCentroidGeojson: column{ + Name: "service_area_centroid_geojson", + DBType: "text", + Default: "GENERATED", + Comment: "", + Nullable: true, + Generated: true, + AutoIncr: false, + }, }, Indexes: organizationIndexes{ OrganizationPkey: index{ @@ -149,23 +311,6 @@ var Organizations = Table[ Where: "", Include: []string{}, }, - OrganizationWebsiteKey: index{ - Type: "btree", - Name: "organization_website_key", - Columns: []indexColumn{ - { - Name: "website", - Desc: null.FromCond(false, true), - IsExpression: false, - }, - }, - Unique: true, - Comment: "", - NullsFirst: []bool{false}, - NullsDistinct: false, - Where: "", - Include: []string{}, - }, }, PrimaryKey: &constraint{ Name: "organization_pkey", @@ -194,31 +339,44 @@ var Organizations = Table[ Columns: []string{"slug"}, Comment: "", }, - OrganizationWebsiteKey: constraint{ - Name: "organization_website_key", - Columns: []string{"website"}, - Comment: "", - }, }, Comment: "", } type organizationColumns struct { - ID column - Name column - ArcgisID column - ArcgisName column - FieldseekerURL column - ImportDistrictGid column - Website column - LogoUUID column - Slug column + ID column + Name column + ArcgisID column + ArcgisName column + FieldseekerURL column + ImportDistrictGid column + Website column + LogoUUID column + Slug column + GeneralManagerName column + MailingAddressCity column + MailingAddressPostalCode column + MailingAddressStreet column + OfficeAddressCity column + OfficeAddressPostalCode column + OfficeAddressStreet column + ServiceAreaGeometry column + ServiceAreaSquareMeters column + ServiceAreaCentroid column + ServiceAreaExtent column + OfficeFax column + OfficePhone column + ServiceAreaXmin column + ServiceAreaYmin column + ServiceAreaXmax column + ServiceAreaYmax column + ServiceAreaCentroidGeojson column } func (c organizationColumns) AsSlice() []column { return []column{ - c.ID, c.Name, c.ArcgisID, c.ArcgisName, c.FieldseekerURL, c.ImportDistrictGid, c.Website, c.LogoUUID, c.Slug, + c.ID, c.Name, c.ArcgisID, c.ArcgisName, c.FieldseekerURL, c.ImportDistrictGid, c.Website, c.LogoUUID, c.Slug, c.GeneralManagerName, c.MailingAddressCity, c.MailingAddressPostalCode, c.MailingAddressStreet, c.OfficeAddressCity, c.OfficeAddressPostalCode, c.OfficeAddressStreet, c.ServiceAreaGeometry, c.ServiceAreaSquareMeters, c.ServiceAreaCentroid, c.ServiceAreaExtent, c.OfficeFax, c.OfficePhone, c.ServiceAreaXmin, c.ServiceAreaYmin, c.ServiceAreaXmax, c.ServiceAreaYmax, c.ServiceAreaCentroidGeojson, } } @@ -226,12 +384,11 @@ type organizationIndexes struct { OrganizationPkey index OrganizationImportDistrictGidKey index OrganizationSlugKey index - OrganizationWebsiteKey index } func (i organizationIndexes) AsSlice() []index { return []index{ - i.OrganizationPkey, i.OrganizationImportDistrictGidKey, i.OrganizationSlugKey, i.OrganizationWebsiteKey, + i.OrganizationPkey, i.OrganizationImportDistrictGidKey, i.OrganizationSlugKey, } } @@ -248,12 +405,11 @@ func (f organizationForeignKeys) AsSlice() []foreignKey { type organizationUniques struct { OrganizationImportDistrictGidKey constraint OrganizationSlugKey constraint - OrganizationWebsiteKey constraint } func (u organizationUniques) AsSlice() []constraint { return []constraint{ - u.OrganizationImportDistrictGidKey, u.OrganizationSlugKey, u.OrganizationWebsiteKey, + u.OrganizationImportDistrictGidKey, u.OrganizationSlugKey, } } diff --git a/db/factory/bobfactory_context.bob.go b/db/factory/bobfactory_context.bob.go index a3a9efae..3c6836a5 100644 --- a/db/factory/bobfactory_context.bob.go +++ b/db/factory/bobfactory_context.bob.go @@ -219,10 +219,6 @@ var ( h3AggregationWithParentsCascadingCtx = newContextual[bool]("h3AggregationWithParentsCascading") h3AggregationRelOrganizationCtx = newContextual[bool]("h3_aggregation.organization.h3_aggregation.h3_aggregation_organization_id_fkey") - // Relationship Contexts for import.district - importDistrictWithParentsCascadingCtx = newContextual[bool]("importDistrictWithParentsCascading") - importDistrictRelImportDistrictGidOrganizationCtx = newContextual[bool]("import.district.organization.organization.organization_import_district_gid_fkey") - // Relationship Contexts for note_audio noteAudioWithParentsCascadingCtx = newContextual[bool]("noteAudioWithParentsCascading") noteAudioRelCreatorUserCtx = newContextual[bool]("note_audio.user_.note_audio.note_audio_creator_id_fkey") @@ -264,47 +260,46 @@ var ( oauthTokenRelUserUserCtx = newContextual[bool]("oauth_token.user_.oauth_token.oauth_token_user_id_fkey") // Relationship Contexts for organization - organizationWithParentsCascadingCtx = newContextual[bool]("organizationWithParentsCascading") - organizationRelEmailContactsCtx = newContextual[bool]("comms.email_contact.organization.district_subscription_email.district_subscription_email_email_contact_address_fkeydistrict_subscription_email.district_subscription_email_organization_id_fkey") - organizationRelPhonesCtx = newContextual[bool]("comms.phone.organization.district_subscription_phone.district_subscription_phone_organization_id_fkeydistrict_subscription_phone.district_subscription_phone_phone_e164_fkey") - organizationRelContainerrelatesCtx = newContextual[bool]("fieldseeker.containerrelate.organization.fieldseeker.containerrelate.containerrelate_organization_id_fkey") - organizationRelFieldscoutinglogsCtx = newContextual[bool]("fieldseeker.fieldscoutinglog.organization.fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey") - organizationRelHabitatrelatesCtx = newContextual[bool]("fieldseeker.habitatrelate.organization.fieldseeker.habitatrelate.habitatrelate_organization_id_fkey") - organizationRelInspectionsamplesCtx = newContextual[bool]("fieldseeker.inspectionsample.organization.fieldseeker.inspectionsample.inspectionsample_organization_id_fkey") - organizationRelInspectionsampledetailsCtx = newContextual[bool]("fieldseeker.inspectionsampledetail.organization.fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey") - organizationRelLinelocationsCtx = newContextual[bool]("fieldseeker.linelocation.organization.fieldseeker.linelocation.linelocation_organization_id_fkey") - organizationRelLocationtrackingsCtx = newContextual[bool]("fieldseeker.locationtracking.organization.fieldseeker.locationtracking.locationtracking_organization_id_fkey") - organizationRelMosquitoinspectionsCtx = newContextual[bool]("fieldseeker.mosquitoinspection.organization.fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey") - organizationRelPointlocationsCtx = newContextual[bool]("fieldseeker.pointlocation.organization.fieldseeker.pointlocation.pointlocation_organization_id_fkey") - organizationRelPolygonlocationsCtx = newContextual[bool]("fieldseeker.polygonlocation.organization.fieldseeker.polygonlocation.polygonlocation_organization_id_fkey") - organizationRelFieldseekerPoolCtx = newContextual[bool]("fieldseeker.pool.organization.fieldseeker.pool.pool_organization_id_fkey") - organizationRelPooldetailsCtx = newContextual[bool]("fieldseeker.pooldetail.organization.fieldseeker.pooldetail.pooldetail_organization_id_fkey") - organizationRelProposedtreatmentareasCtx = newContextual[bool]("fieldseeker.proposedtreatmentarea.organization.fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey") - organizationRelQamosquitoinspectionsCtx = newContextual[bool]("fieldseeker.qamosquitoinspection.organization.fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey") - organizationRelRodentlocationsCtx = newContextual[bool]("fieldseeker.rodentlocation.organization.fieldseeker.rodentlocation.rodentlocation_organization_id_fkey") - organizationRelSamplecollectionsCtx = newContextual[bool]("fieldseeker.samplecollection.organization.fieldseeker.samplecollection.samplecollection_organization_id_fkey") - organizationRelSamplelocationsCtx = newContextual[bool]("fieldseeker.samplelocation.organization.fieldseeker.samplelocation.samplelocation_organization_id_fkey") - organizationRelServicerequestsCtx = newContextual[bool]("fieldseeker.servicerequest.organization.fieldseeker.servicerequest.servicerequest_organization_id_fkey") - organizationRelSpeciesabundancesCtx = newContextual[bool]("fieldseeker.speciesabundance.organization.fieldseeker.speciesabundance.speciesabundance_organization_id_fkey") - organizationRelStormdrainsCtx = newContextual[bool]("fieldseeker.stormdrain.organization.fieldseeker.stormdrain.stormdrain_organization_id_fkey") - organizationRelTimecardsCtx = newContextual[bool]("fieldseeker.timecard.organization.fieldseeker.timecard.timecard_organization_id_fkey") - organizationRelTrapdataCtx = newContextual[bool]("fieldseeker.trapdata.organization.fieldseeker.trapdata.trapdata_organization_id_fkey") - organizationRelTraplocationsCtx = newContextual[bool]("fieldseeker.traplocation.organization.fieldseeker.traplocation.traplocation_organization_id_fkey") - organizationRelTreatmentsCtx = newContextual[bool]("fieldseeker.treatment.organization.fieldseeker.treatment.treatment_organization_id_fkey") - organizationRelTreatmentareasCtx = newContextual[bool]("fieldseeker.treatmentarea.organization.fieldseeker.treatmentarea.treatmentarea_organization_id_fkey") - organizationRelZonesCtx = newContextual[bool]("fieldseeker.zones.organization.fieldseeker.zones.zones_organization_id_fkey") - organizationRelZones2sCtx = newContextual[bool]("fieldseeker.zones2.organization.fieldseeker.zones2.zones2_organization_id_fkey") - organizationRelFieldseekerSyncsCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey") - organizationRelFilesCtx = newContextual[bool]("fileupload.file.organization.fileupload.file.file_organization_id_fkey") - organizationRelPoolsCtx = newContextual[bool]("fileupload.pool.organization.fileupload.pool.pool_organization_id_fkey") - organizationRelH3AggregationsCtx = newContextual[bool]("h3_aggregation.organization.h3_aggregation.h3_aggregation_organization_id_fkey") - organizationRelNoteAudiosCtx = newContextual[bool]("note_audio.organization.note_audio.note_audio_organization_id_fkey") - organizationRelNoteImagesCtx = newContextual[bool]("note_image.organization.note_image.note_image_organization_id_fkey") - organizationRelImportDistrictGidDistrictCtx = newContextual[bool]("import.district.organization.organization.organization_import_district_gid_fkey") - organizationRelNuisancesCtx = newContextual[bool]("organization.publicreport.nuisance.publicreport.nuisance.nuisance_organization_id_fkey") - organizationRelPublicreportPoolCtx = newContextual[bool]("organization.publicreport.pool.publicreport.pool.pool_organization_id_fkey") - organizationRelQuicksCtx = newContextual[bool]("organization.publicreport.quick.publicreport.quick.quick_organization_id_fkey") - organizationRelUserCtx = newContextual[bool]("organization.user_.user_.user__organization_id_fkey") + organizationWithParentsCascadingCtx = newContextual[bool]("organizationWithParentsCascading") + organizationRelEmailContactsCtx = newContextual[bool]("comms.email_contact.organization.district_subscription_email.district_subscription_email_email_contact_address_fkeydistrict_subscription_email.district_subscription_email_organization_id_fkey") + organizationRelPhonesCtx = newContextual[bool]("comms.phone.organization.district_subscription_phone.district_subscription_phone_organization_id_fkeydistrict_subscription_phone.district_subscription_phone_phone_e164_fkey") + organizationRelContainerrelatesCtx = newContextual[bool]("fieldseeker.containerrelate.organization.fieldseeker.containerrelate.containerrelate_organization_id_fkey") + organizationRelFieldscoutinglogsCtx = newContextual[bool]("fieldseeker.fieldscoutinglog.organization.fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey") + organizationRelHabitatrelatesCtx = newContextual[bool]("fieldseeker.habitatrelate.organization.fieldseeker.habitatrelate.habitatrelate_organization_id_fkey") + organizationRelInspectionsamplesCtx = newContextual[bool]("fieldseeker.inspectionsample.organization.fieldseeker.inspectionsample.inspectionsample_organization_id_fkey") + organizationRelInspectionsampledetailsCtx = newContextual[bool]("fieldseeker.inspectionsampledetail.organization.fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey") + organizationRelLinelocationsCtx = newContextual[bool]("fieldseeker.linelocation.organization.fieldseeker.linelocation.linelocation_organization_id_fkey") + organizationRelLocationtrackingsCtx = newContextual[bool]("fieldseeker.locationtracking.organization.fieldseeker.locationtracking.locationtracking_organization_id_fkey") + organizationRelMosquitoinspectionsCtx = newContextual[bool]("fieldseeker.mosquitoinspection.organization.fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey") + organizationRelPointlocationsCtx = newContextual[bool]("fieldseeker.pointlocation.organization.fieldseeker.pointlocation.pointlocation_organization_id_fkey") + organizationRelPolygonlocationsCtx = newContextual[bool]("fieldseeker.polygonlocation.organization.fieldseeker.polygonlocation.polygonlocation_organization_id_fkey") + organizationRelFieldseekerPoolCtx = newContextual[bool]("fieldseeker.pool.organization.fieldseeker.pool.pool_organization_id_fkey") + organizationRelPooldetailsCtx = newContextual[bool]("fieldseeker.pooldetail.organization.fieldseeker.pooldetail.pooldetail_organization_id_fkey") + organizationRelProposedtreatmentareasCtx = newContextual[bool]("fieldseeker.proposedtreatmentarea.organization.fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey") + organizationRelQamosquitoinspectionsCtx = newContextual[bool]("fieldseeker.qamosquitoinspection.organization.fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey") + organizationRelRodentlocationsCtx = newContextual[bool]("fieldseeker.rodentlocation.organization.fieldseeker.rodentlocation.rodentlocation_organization_id_fkey") + organizationRelSamplecollectionsCtx = newContextual[bool]("fieldseeker.samplecollection.organization.fieldseeker.samplecollection.samplecollection_organization_id_fkey") + organizationRelSamplelocationsCtx = newContextual[bool]("fieldseeker.samplelocation.organization.fieldseeker.samplelocation.samplelocation_organization_id_fkey") + organizationRelServicerequestsCtx = newContextual[bool]("fieldseeker.servicerequest.organization.fieldseeker.servicerequest.servicerequest_organization_id_fkey") + organizationRelSpeciesabundancesCtx = newContextual[bool]("fieldseeker.speciesabundance.organization.fieldseeker.speciesabundance.speciesabundance_organization_id_fkey") + organizationRelStormdrainsCtx = newContextual[bool]("fieldseeker.stormdrain.organization.fieldseeker.stormdrain.stormdrain_organization_id_fkey") + organizationRelTimecardsCtx = newContextual[bool]("fieldseeker.timecard.organization.fieldseeker.timecard.timecard_organization_id_fkey") + organizationRelTrapdataCtx = newContextual[bool]("fieldseeker.trapdata.organization.fieldseeker.trapdata.trapdata_organization_id_fkey") + organizationRelTraplocationsCtx = newContextual[bool]("fieldseeker.traplocation.organization.fieldseeker.traplocation.traplocation_organization_id_fkey") + organizationRelTreatmentsCtx = newContextual[bool]("fieldseeker.treatment.organization.fieldseeker.treatment.treatment_organization_id_fkey") + organizationRelTreatmentareasCtx = newContextual[bool]("fieldseeker.treatmentarea.organization.fieldseeker.treatmentarea.treatmentarea_organization_id_fkey") + organizationRelZonesCtx = newContextual[bool]("fieldseeker.zones.organization.fieldseeker.zones.zones_organization_id_fkey") + organizationRelZones2sCtx = newContextual[bool]("fieldseeker.zones2.organization.fieldseeker.zones2.zones2_organization_id_fkey") + organizationRelFieldseekerSyncsCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey") + organizationRelFilesCtx = newContextual[bool]("fileupload.file.organization.fileupload.file.file_organization_id_fkey") + organizationRelPoolsCtx = newContextual[bool]("fileupload.pool.organization.fileupload.pool.pool_organization_id_fkey") + organizationRelH3AggregationsCtx = newContextual[bool]("h3_aggregation.organization.h3_aggregation.h3_aggregation_organization_id_fkey") + organizationRelNoteAudiosCtx = newContextual[bool]("note_audio.organization.note_audio.note_audio_organization_id_fkey") + organizationRelNoteImagesCtx = newContextual[bool]("note_image.organization.note_image.note_image_organization_id_fkey") + organizationRelNuisancesCtx = newContextual[bool]("organization.publicreport.nuisance.publicreport.nuisance.nuisance_organization_id_fkey") + organizationRelPublicreportPoolCtx = newContextual[bool]("organization.publicreport.pool.publicreport.pool.pool_organization_id_fkey") + organizationRelQuicksCtx = newContextual[bool]("organization.publicreport.quick.publicreport.quick.quick_organization_id_fkey") + organizationRelUserCtx = newContextual[bool]("organization.user_.user_.user__organization_id_fkey") // Relationship Contexts for publicreport.image publicreportImageWithParentsCascadingCtx = newContextual[bool]("publicreportImageWithParentsCascading") diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go index 4c72bfc5..e593b5d0 100644 --- a/db/factory/bobfactory_main.bob.go +++ b/db/factory/bobfactory_main.bob.go @@ -66,7 +66,6 @@ type Factory struct { baseGeometryColumnMods GeometryColumnModSlice baseGooseDBVersionMods GooseDBVersionModSlice baseH3AggregationMods H3AggregationModSlice - baseImportDistrictMods ImportDistrictModSlice baseNoteAudioMods NoteAudioModSlice baseNoteAudioBreadcrumbMods NoteAudioBreadcrumbModSlice baseNoteAudioDatumMods NoteAudioDatumModSlice @@ -2581,60 +2580,6 @@ func (f *Factory) FromExistingH3Aggregation(m *models.H3Aggregation) *H3Aggregat return o } -func (f *Factory) NewImportDistrict(mods ...ImportDistrictMod) *ImportDistrictTemplate { - return f.NewImportDistrictWithContext(context.Background(), mods...) -} - -func (f *Factory) NewImportDistrictWithContext(ctx context.Context, mods ...ImportDistrictMod) *ImportDistrictTemplate { - o := &ImportDistrictTemplate{f: f} - - if f != nil { - f.baseImportDistrictMods.Apply(ctx, o) - } - - ImportDistrictModSlice(mods).Apply(ctx, o) - - return o -} - -func (f *Factory) FromExistingImportDistrict(m *models.ImportDistrict) *ImportDistrictTemplate { - o := &ImportDistrictTemplate{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 } - o.Geom4326 = func() null.Val[string] { return m.Geom4326 } - o.Centroid4326 = func() null.Val[string] { return m.Centroid4326 } - o.Extent4326 = func() null.Val[string] { return m.Extent4326 } - o.Area4326SQM = func() null.Val[decimal.Decimal] { return m.Area4326SQM } - - ctx := context.Background() - if m.R.ImportDistrictGidOrganization != nil { - ImportDistrictMods.WithExistingImportDistrictGidOrganization(m.R.ImportDistrictGidOrganization).Apply(ctx, o) - } - - return o -} - func (f *Factory) NewNoteAudio(mods ...NoteAudioMod) *NoteAudioTemplate { return f.NewNoteAudioWithContext(context.Background(), mods...) } @@ -2966,6 +2911,24 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization o.Website = func() null.Val[string] { return m.Website } o.LogoUUID = func() null.Val[uuid.UUID] { return m.LogoUUID } o.Slug = func() null.Val[string] { return m.Slug } + o.GeneralManagerName = func() null.Val[string] { return m.GeneralManagerName } + o.MailingAddressCity = func() null.Val[string] { return m.MailingAddressCity } + o.MailingAddressPostalCode = func() null.Val[string] { return m.MailingAddressPostalCode } + o.MailingAddressStreet = func() null.Val[string] { return m.MailingAddressStreet } + o.OfficeAddressCity = func() null.Val[string] { return m.OfficeAddressCity } + o.OfficeAddressPostalCode = func() null.Val[string] { return m.OfficeAddressPostalCode } + o.OfficeAddressStreet = func() null.Val[string] { return m.OfficeAddressStreet } + o.ServiceAreaGeometry = func() null.Val[string] { return m.ServiceAreaGeometry } + o.ServiceAreaSquareMeters = func() null.Val[decimal.Decimal] { return m.ServiceAreaSquareMeters } + o.ServiceAreaCentroid = func() null.Val[string] { return m.ServiceAreaCentroid } + o.ServiceAreaExtent = func() null.Val[string] { return m.ServiceAreaExtent } + o.OfficeFax = func() null.Val[string] { return m.OfficeFax } + o.OfficePhone = func() null.Val[string] { return m.OfficePhone } + o.ServiceAreaXmin = func() null.Val[float64] { return m.ServiceAreaXmin } + o.ServiceAreaYmin = func() null.Val[float64] { return m.ServiceAreaYmin } + o.ServiceAreaXmax = func() null.Val[float64] { return m.ServiceAreaXmax } + o.ServiceAreaYmax = func() null.Val[float64] { return m.ServiceAreaYmax } + o.ServiceAreaCentroidGeojson = func() null.Val[string] { return m.ServiceAreaCentroidGeojson } ctx := context.Background() if len(m.R.EmailContacts) > 0 { @@ -3073,9 +3036,6 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization if len(m.R.NoteImages) > 0 { OrganizationMods.AddExistingNoteImages(m.R.NoteImages...).Apply(ctx, o) } - if m.R.ImportDistrictGidDistrict != nil { - OrganizationMods.WithExistingImportDistrictGidDistrict(m.R.ImportDistrictGidDistrict).Apply(ctx, o) - } if len(m.R.Nuisances) > 0 { OrganizationMods.AddExistingNuisances(m.R.Nuisances...).Apply(ctx, o) } @@ -4256,14 +4216,6 @@ func (f *Factory) AddBaseH3AggregationMod(mods ...H3AggregationMod) { f.baseH3AggregationMods = append(f.baseH3AggregationMods, mods...) } -func (f *Factory) ClearBaseImportDistrictMods() { - f.baseImportDistrictMods = nil -} - -func (f *Factory) AddBaseImportDistrictMod(mods ...ImportDistrictMod) { - f.baseImportDistrictMods = append(f.baseImportDistrictMods, mods...) -} - func (f *Factory) ClearBaseNoteAudioMods() { f.baseNoteAudioMods = nil } diff --git a/db/factory/import.district.bob.go b/db/factory/import.district.bob.go deleted file mode 100644 index 20891cc3..00000000 --- a/db/factory/import.district.bob.go +++ /dev/null @@ -1,1858 +0,0 @@ -// Code generated by BobGen psql v0.42.5. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package factory - -import ( - "context" - "testing" - - "github.com/Gleipnir-Technology/bob" - 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/shopspring/decimal" -) - -type ImportDistrictMod interface { - Apply(context.Context, *ImportDistrictTemplate) -} - -type ImportDistrictModFunc func(context.Context, *ImportDistrictTemplate) - -func (f ImportDistrictModFunc) Apply(ctx context.Context, n *ImportDistrictTemplate) { - f(ctx, n) -} - -type ImportDistrictModSlice []ImportDistrictMod - -func (mods ImportDistrictModSlice) Apply(ctx context.Context, n *ImportDistrictTemplate) { - for _, f := range mods { - f.Apply(ctx, n) - } -} - -// ImportDistrictTemplate is an object representing the database table. -// all columns are optional and should be set by mods -type ImportDistrictTemplate struct { - Gid func() int32 - ID func() null.Val[decimal.Decimal] - Website func() null.Val[string] - Contact func() null.Val[string] - Address func() null.Val[string] - Regionid func() null.Val[decimal.Decimal] - PostalCod func() null.Val[decimal.Decimal] - Phone1 func() null.Val[string] - Fax1 func() null.Val[string] - Agency func() null.Val[string] - Code1 func() null.Val[string] - City1 func() null.Val[string] - ShapeLeng func() null.Val[decimal.Decimal] - Address2 func() null.Val[string] - GeneralMG func() null.Val[string] - City2 func() null.Val[string] - PostalC1 func() null.Val[decimal.Decimal] - Fax2 func() null.Val[string] - Phone2 func() null.Val[string] - ShapeLe1 func() null.Val[decimal.Decimal] - ShapeArea func() null.Val[decimal.Decimal] - Geom func() null.Val[string] - Geom4326 func() null.Val[string] - Centroid4326 func() null.Val[string] - Extent4326 func() null.Val[string] - Area4326SQM func() null.Val[decimal.Decimal] - - r importDistrictR - f *Factory - - alreadyPersisted bool -} - -type importDistrictR struct { - ImportDistrictGidOrganization *importDistrictRImportDistrictGidOrganizationR -} - -type importDistrictRImportDistrictGidOrganizationR struct { - o *OrganizationTemplate -} - -// Apply mods to the ImportDistrictTemplate -func (o *ImportDistrictTemplate) Apply(ctx context.Context, mods ...ImportDistrictMod) { - for _, mod := range mods { - mod.Apply(ctx, o) - } -} - -// setModelRels creates and sets the relationships on *models.ImportDistrict -// according to the relationships in the template. Nothing is inserted into the db -func (t ImportDistrictTemplate) setModelRels(o *models.ImportDistrict) { - if t.r.ImportDistrictGidOrganization != nil { - rel := t.r.ImportDistrictGidOrganization.o.Build() - rel.R.ImportDistrictGidDistrict = o - rel.ImportDistrictGid = null.From(o.Gid) // h2 - o.R.ImportDistrictGidOrganization = rel - } -} - -// BuildSetter returns an *models.ImportDistrictSetter -// this does nothing with the relationship templates -func (o ImportDistrictTemplate) BuildSetter() *models.ImportDistrictSetter { - m := &models.ImportDistrictSetter{} - - if o.Gid != nil { - val := o.Gid() - m.Gid = omit.From(val) - } - if o.ID != nil { - val := o.ID() - m.ID = omitnull.FromNull(val) - } - if o.Website != nil { - val := o.Website() - m.Website = omitnull.FromNull(val) - } - if o.Contact != nil { - val := o.Contact() - m.Contact = omitnull.FromNull(val) - } - if o.Address != nil { - val := o.Address() - m.Address = omitnull.FromNull(val) - } - if o.Regionid != nil { - val := o.Regionid() - m.Regionid = omitnull.FromNull(val) - } - if o.PostalCod != nil { - val := o.PostalCod() - m.PostalCod = omitnull.FromNull(val) - } - if o.Phone1 != nil { - val := o.Phone1() - m.Phone1 = omitnull.FromNull(val) - } - if o.Fax1 != nil { - val := o.Fax1() - m.Fax1 = omitnull.FromNull(val) - } - if o.Agency != nil { - val := o.Agency() - m.Agency = omitnull.FromNull(val) - } - if o.Code1 != nil { - val := o.Code1() - m.Code1 = omitnull.FromNull(val) - } - if o.City1 != nil { - val := o.City1() - m.City1 = omitnull.FromNull(val) - } - if o.ShapeLeng != nil { - val := o.ShapeLeng() - m.ShapeLeng = omitnull.FromNull(val) - } - if o.Address2 != nil { - val := o.Address2() - m.Address2 = omitnull.FromNull(val) - } - if o.GeneralMG != nil { - val := o.GeneralMG() - m.GeneralMG = omitnull.FromNull(val) - } - if o.City2 != nil { - val := o.City2() - m.City2 = omitnull.FromNull(val) - } - if o.PostalC1 != nil { - val := o.PostalC1() - m.PostalC1 = omitnull.FromNull(val) - } - if o.Fax2 != nil { - val := o.Fax2() - m.Fax2 = omitnull.FromNull(val) - } - if o.Phone2 != nil { - val := o.Phone2() - m.Phone2 = omitnull.FromNull(val) - } - if o.ShapeLe1 != nil { - val := o.ShapeLe1() - m.ShapeLe1 = omitnull.FromNull(val) - } - if o.ShapeArea != nil { - val := o.ShapeArea() - m.ShapeArea = omitnull.FromNull(val) - } - if o.Geom != nil { - val := o.Geom() - m.Geom = omitnull.FromNull(val) - } - - return m -} - -// BuildManySetter returns an []*models.ImportDistrictSetter -// this does nothing with the relationship templates -func (o ImportDistrictTemplate) BuildManySetter(number int) []*models.ImportDistrictSetter { - m := make([]*models.ImportDistrictSetter, number) - - for i := range m { - m[i] = o.BuildSetter() - } - - return m -} - -// Build returns an *models.ImportDistrict -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use ImportDistrictTemplate.Create -func (o ImportDistrictTemplate) Build() *models.ImportDistrict { - m := &models.ImportDistrict{} - - if o.Gid != nil { - m.Gid = o.Gid() - } - if o.ID != nil { - m.ID = o.ID() - } - if o.Website != nil { - m.Website = o.Website() - } - if o.Contact != nil { - m.Contact = o.Contact() - } - if o.Address != nil { - m.Address = o.Address() - } - if o.Regionid != nil { - m.Regionid = o.Regionid() - } - if o.PostalCod != nil { - m.PostalCod = o.PostalCod() - } - if o.Phone1 != nil { - m.Phone1 = o.Phone1() - } - if o.Fax1 != nil { - m.Fax1 = o.Fax1() - } - if o.Agency != nil { - m.Agency = o.Agency() - } - if o.Code1 != nil { - m.Code1 = o.Code1() - } - if o.City1 != nil { - m.City1 = o.City1() - } - if o.ShapeLeng != nil { - m.ShapeLeng = o.ShapeLeng() - } - if o.Address2 != nil { - m.Address2 = o.Address2() - } - if o.GeneralMG != nil { - m.GeneralMG = o.GeneralMG() - } - if o.City2 != nil { - m.City2 = o.City2() - } - if o.PostalC1 != nil { - m.PostalC1 = o.PostalC1() - } - if o.Fax2 != nil { - m.Fax2 = o.Fax2() - } - if o.Phone2 != nil { - m.Phone2 = o.Phone2() - } - if o.ShapeLe1 != nil { - m.ShapeLe1 = o.ShapeLe1() - } - if o.ShapeArea != nil { - m.ShapeArea = o.ShapeArea() - } - if o.Geom != nil { - m.Geom = o.Geom() - } - if o.Geom4326 != nil { - m.Geom4326 = o.Geom4326() - } - if o.Centroid4326 != nil { - m.Centroid4326 = o.Centroid4326() - } - if o.Extent4326 != nil { - m.Extent4326 = o.Extent4326() - } - if o.Area4326SQM != nil { - m.Area4326SQM = o.Area4326SQM() - } - - o.setModelRels(m) - - return m -} - -// BuildMany returns an models.ImportDistrictSlice -// Related objects are also created and placed in the .R field -// NOTE: Objects are not inserted into the database. Use ImportDistrictTemplate.CreateMany -func (o ImportDistrictTemplate) BuildMany(number int) models.ImportDistrictSlice { - m := make(models.ImportDistrictSlice, number) - - for i := range m { - m[i] = o.Build() - } - - return m -} - -func ensureCreatableImportDistrict(m *models.ImportDistrictSetter) { -} - -// insertOptRels creates and inserts any optional the relationships on *models.ImportDistrict -// according to the relationships in the template. -// any required relationship should have already exist on the model -func (o *ImportDistrictTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ImportDistrict) error { - var err error - - isImportDistrictGidOrganizationDone, _ := importDistrictRelImportDistrictGidOrganizationCtx.Value(ctx) - if !isImportDistrictGidOrganizationDone && o.r.ImportDistrictGidOrganization != nil { - ctx = importDistrictRelImportDistrictGidOrganizationCtx.WithValue(ctx, true) - if o.r.ImportDistrictGidOrganization.o.alreadyPersisted { - m.R.ImportDistrictGidOrganization = o.r.ImportDistrictGidOrganization.o.Build() - } else { - var rel0 *models.Organization - rel0, err = o.r.ImportDistrictGidOrganization.o.Create(ctx, exec) - if err != nil { - return err - } - err = m.AttachImportDistrictGidOrganization(ctx, exec, rel0) - if err != nil { - return err - } - } - - } - - return err -} - -// Create builds a importDistrict and inserts it into the database -// Relations objects are also inserted and placed in the .R field -func (o *ImportDistrictTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ImportDistrict, error) { - var err error - opt := o.BuildSetter() - ensureCreatableImportDistrict(opt) - - m, err := models.ImportDistricts.Insert(opt).One(ctx, exec) - if err != nil { - return nil, err - } - - if err := o.insertOptRels(ctx, exec, m); err != nil { - return nil, err - } - return m, err -} - -// MustCreate builds a importDistrict and inserts it into the database -// Relations objects are also inserted and placed in the .R field -// panics if an error occurs -func (o *ImportDistrictTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ImportDistrict { - m, err := o.Create(ctx, exec) - if err != nil { - panic(err) - } - return m -} - -// CreateOrFail builds a importDistrict and inserts it into the database -// Relations objects are also inserted and placed in the .R field -// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs -func (o *ImportDistrictTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ImportDistrict { - tb.Helper() - m, err := o.Create(ctx, exec) - if err != nil { - tb.Fatal(err) - return nil - } - return m -} - -// CreateMany builds multiple importDistricts and inserts them into the database -// Relations objects are also inserted and placed in the .R field -func (o ImportDistrictTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ImportDistrictSlice, error) { - var err error - m := make(models.ImportDistrictSlice, number) - - for i := range m { - m[i], err = o.Create(ctx, exec) - if err != nil { - return nil, err - } - } - - return m, nil -} - -// MustCreateMany builds multiple importDistricts and inserts them into the database -// Relations objects are also inserted and placed in the .R field -// panics if an error occurs -func (o ImportDistrictTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ImportDistrictSlice { - m, err := o.CreateMany(ctx, exec, number) - if err != nil { - panic(err) - } - return m -} - -// CreateManyOrFail builds multiple importDistricts and inserts them into the database -// Relations objects are also inserted and placed in the .R field -// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs -func (o ImportDistrictTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ImportDistrictSlice { - tb.Helper() - m, err := o.CreateMany(ctx, exec, number) - if err != nil { - tb.Fatal(err) - return nil - } - return m -} - -// ImportDistrict has methods that act as mods for the ImportDistrictTemplate -var ImportDistrictMods importDistrictMods - -type importDistrictMods struct{} - -func (m importDistrictMods) RandomizeAllColumns(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModSlice{ - ImportDistrictMods.RandomGid(f), - ImportDistrictMods.RandomID(f), - ImportDistrictMods.RandomWebsite(f), - ImportDistrictMods.RandomContact(f), - ImportDistrictMods.RandomAddress(f), - ImportDistrictMods.RandomRegionid(f), - ImportDistrictMods.RandomPostalCod(f), - ImportDistrictMods.RandomPhone1(f), - ImportDistrictMods.RandomFax1(f), - ImportDistrictMods.RandomAgency(f), - ImportDistrictMods.RandomCode1(f), - ImportDistrictMods.RandomCity1(f), - ImportDistrictMods.RandomShapeLeng(f), - ImportDistrictMods.RandomAddress2(f), - ImportDistrictMods.RandomGeneralMG(f), - ImportDistrictMods.RandomCity2(f), - ImportDistrictMods.RandomPostalC1(f), - ImportDistrictMods.RandomFax2(f), - ImportDistrictMods.RandomPhone2(f), - ImportDistrictMods.RandomShapeLe1(f), - ImportDistrictMods.RandomShapeArea(f), - ImportDistrictMods.RandomGeom(f), - ImportDistrictMods.RandomGeom4326(f), - ImportDistrictMods.RandomCentroid4326(f), - ImportDistrictMods.RandomExtent4326(f), - ImportDistrictMods.RandomArea4326SQM(f), - } -} - -// Set the model columns to this value -func (m importDistrictMods) Gid(val int32) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Gid = func() int32 { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) GidFunc(f func() int32) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Gid = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetGid() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Gid = nil - }) -} - -// Generates a random value for the column using the given faker -// if faker is nil, a default faker is used -func (m importDistrictMods) RandomGid(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Gid = func() int32 { - return random_int32(f) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) ID(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ID = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) IDFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ID = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetID() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - 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 importDistrictMods) RandomID(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ID = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomIDNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ID = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Website(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Website = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) WebsiteFunc(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Website = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetWebsite() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Website = 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 importDistrictMods) RandomWebsite(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Website = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomWebsiteNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Website = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Contact(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Contact = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) ContactFunc(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Contact = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetContact() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Contact = 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 importDistrictMods) RandomContact(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Contact = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomContactNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Contact = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Address(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) AddressFunc(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetAddress() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - 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 importDistrictMods) RandomAddress(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomAddressNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Regionid(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Regionid = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) RegionidFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Regionid = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetRegionid() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Regionid = 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 importDistrictMods) RandomRegionid(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Regionid = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomRegionidNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Regionid = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) PostalCod(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalCod = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) PostalCodFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalCod = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetPostalCod() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalCod = 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 importDistrictMods) RandomPostalCod(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalCod = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomPostalCodNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalCod = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Phone1(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone1 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Phone1Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone1 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetPhone1() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone1 = 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 importDistrictMods) RandomPhone1(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomPhone1NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Fax1(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax1 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Fax1Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax1 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetFax1() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax1 = 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 importDistrictMods) RandomFax1(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomFax1NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Agency(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Agency = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) AgencyFunc(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Agency = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetAgency() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Agency = 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 importDistrictMods) RandomAgency(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Agency = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomAgencyNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Agency = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Code1(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Code1 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Code1Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Code1 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetCode1() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Code1 = 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 importDistrictMods) RandomCode1(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Code1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomCode1NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Code1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) City1(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City1 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) City1Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City1 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetCity1() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City1 = 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 importDistrictMods) RandomCity1(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomCity1NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City1 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) ShapeLeng(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLeng = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) ShapeLengFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLeng = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetShapeLeng() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLeng = 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 importDistrictMods) RandomShapeLeng(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLeng = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomShapeLengNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLeng = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Address2(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address2 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Address2Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address2 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetAddress2() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address2 = 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 importDistrictMods) RandomAddress2(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomAddress2NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Address2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) GeneralMG(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.GeneralMG = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) GeneralMGFunc(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.GeneralMG = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetGeneralMG() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.GeneralMG = 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 importDistrictMods) RandomGeneralMG(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.GeneralMG = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomGeneralMGNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.GeneralMG = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) City2(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City2 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) City2Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City2 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetCity2() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City2 = 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 importDistrictMods) RandomCity2(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomCity2NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.City2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) PostalC1(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalC1 = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) PostalC1Func(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalC1 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetPostalC1() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalC1 = 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 importDistrictMods) RandomPostalC1(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalC1 = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomPostalC1NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.PostalC1 = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Fax2(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax2 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Fax2Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax2 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetFax2() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax2 = 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 importDistrictMods) RandomFax2(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomFax2NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Fax2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Phone2(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone2 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Phone2Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone2 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetPhone2() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone2 = 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 importDistrictMods) RandomPhone2(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - 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 importDistrictMods) RandomPhone2NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Phone2 = func() null.Val[string] { - if f == nil { - f = &defaultFaker - } - - val := random_string(f, "254") - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) ShapeLe1(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLe1 = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) ShapeLe1Func(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLe1 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetShapeLe1() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLe1 = 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 importDistrictMods) RandomShapeLe1(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLe1 = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomShapeLe1NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeLe1 = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) ShapeArea(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeArea = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) ShapeAreaFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeArea = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetShapeArea() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeArea = 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 importDistrictMods) RandomShapeArea(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeArea = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomShapeAreaNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.ShapeArea = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -// Set the model columns to this value -func (m importDistrictMods) Geom(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) GeomFunc(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetGeom() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom = 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 importDistrictMods) RandomGeom(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom = 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 importDistrictMods) RandomGeomNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom = 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 importDistrictMods) Geom4326(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom4326 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Geom4326Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom4326 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetGeom4326() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom4326 = 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 importDistrictMods) RandomGeom4326(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom4326 = 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 importDistrictMods) RandomGeom4326NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Geom4326 = 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 importDistrictMods) Centroid4326(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Centroid4326 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Centroid4326Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Centroid4326 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetCentroid4326() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Centroid4326 = 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 importDistrictMods) RandomCentroid4326(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Centroid4326 = 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 importDistrictMods) RandomCentroid4326NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Centroid4326 = 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 importDistrictMods) Extent4326(val null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Extent4326 = func() null.Val[string] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Extent4326Func(f func() null.Val[string]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Extent4326 = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetExtent4326() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Extent4326 = 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 importDistrictMods) RandomExtent4326(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Extent4326 = 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 importDistrictMods) RandomExtent4326NotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Extent4326 = 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 importDistrictMods) Area4326SQM(val null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Area4326SQM = func() null.Val[decimal.Decimal] { return val } - }) -} - -// Set the Column from the function -func (m importDistrictMods) Area4326SQMFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Area4326SQM = f - }) -} - -// Clear any values for the column -func (m importDistrictMods) UnsetArea4326SQM() ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Area4326SQM = 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 importDistrictMods) RandomArea4326SQM(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Area4326SQM = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(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 importDistrictMods) RandomArea4326SQMNotNull(f *faker.Faker) ImportDistrictMod { - return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) { - o.Area4326SQM = func() null.Val[decimal.Decimal] { - if f == nil { - f = &defaultFaker - } - - val := random_decimal_Decimal(f) - return null.From(val) - } - }) -} - -func (m importDistrictMods) WithParentsCascading() ImportDistrictMod { - return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) { - if isDone, _ := importDistrictWithParentsCascadingCtx.Value(ctx); isDone { - return - } - ctx = importDistrictWithParentsCascadingCtx.WithValue(ctx, true) - { - - related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading()) - m.WithImportDistrictGidOrganization(related).Apply(ctx, o) - } - }) -} - -func (m importDistrictMods) WithImportDistrictGidOrganization(rel *OrganizationTemplate) ImportDistrictMod { - return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) { - o.r.ImportDistrictGidOrganization = &importDistrictRImportDistrictGidOrganizationR{ - o: rel, - } - }) -} - -func (m importDistrictMods) WithNewImportDistrictGidOrganization(mods ...OrganizationMod) ImportDistrictMod { - return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) { - related := o.f.NewOrganizationWithContext(ctx, mods...) - - m.WithImportDistrictGidOrganization(related).Apply(ctx, o) - }) -} - -func (m importDistrictMods) WithExistingImportDistrictGidOrganization(em *models.Organization) ImportDistrictMod { - return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) { - o.r.ImportDistrictGidOrganization = &importDistrictRImportDistrictGidOrganizationR{ - o: o.f.FromExistingOrganization(em), - } - }) -} - -func (m importDistrictMods) WithoutImportDistrictGidOrganization() ImportDistrictMod { - return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) { - o.r.ImportDistrictGidOrganization = nil - }) -} diff --git a/db/factory/organization.bob.go b/db/factory/organization.bob.go index 5cc58818..fca80892 100644 --- a/db/factory/organization.bob.go +++ b/db/factory/organization.bob.go @@ -14,6 +14,7 @@ import ( "github.com/aarondl/opt/omitnull" "github.com/google/uuid" "github.com/jaswdr/faker/v2" + "github.com/shopspring/decimal" ) type OrganizationMod interface { @@ -37,15 +38,33 @@ func (mods OrganizationModSlice) Apply(ctx context.Context, n *OrganizationTempl // OrganizationTemplate is an object representing the database table. // all columns are optional and should be set by mods type OrganizationTemplate struct { - ID func() int32 - Name func() string - ArcgisID func() null.Val[string] - ArcgisName func() null.Val[string] - FieldseekerURL func() null.Val[string] - ImportDistrictGid func() null.Val[int32] - Website func() null.Val[string] - LogoUUID func() null.Val[uuid.UUID] - Slug func() null.Val[string] + ID func() int32 + Name func() string + ArcgisID func() null.Val[string] + ArcgisName func() null.Val[string] + FieldseekerURL func() null.Val[string] + ImportDistrictGid func() null.Val[int32] + Website func() null.Val[string] + LogoUUID func() null.Val[uuid.UUID] + Slug func() null.Val[string] + GeneralManagerName func() null.Val[string] + MailingAddressCity func() null.Val[string] + MailingAddressPostalCode func() null.Val[string] + MailingAddressStreet func() null.Val[string] + OfficeAddressCity func() null.Val[string] + OfficeAddressPostalCode func() null.Val[string] + OfficeAddressStreet func() null.Val[string] + ServiceAreaGeometry func() null.Val[string] + ServiceAreaSquareMeters func() null.Val[decimal.Decimal] + ServiceAreaCentroid func() null.Val[string] + ServiceAreaExtent func() null.Val[string] + OfficeFax func() null.Val[string] + OfficePhone func() null.Val[string] + ServiceAreaXmin func() null.Val[float64] + ServiceAreaYmin func() null.Val[float64] + ServiceAreaXmax func() null.Val[float64] + ServiceAreaYmax func() null.Val[float64] + ServiceAreaCentroidGeojson func() null.Val[string] r organizationR f *Factory @@ -54,46 +73,45 @@ type OrganizationTemplate struct { } type organizationR struct { - EmailContacts []*organizationREmailContactsR - Phones []*organizationRPhonesR - Containerrelates []*organizationRContainerrelatesR - Fieldscoutinglogs []*organizationRFieldscoutinglogsR - Habitatrelates []*organizationRHabitatrelatesR - Inspectionsamples []*organizationRInspectionsamplesR - Inspectionsampledetails []*organizationRInspectionsampledetailsR - Linelocations []*organizationRLinelocationsR - Locationtrackings []*organizationRLocationtrackingsR - Mosquitoinspections []*organizationRMosquitoinspectionsR - Pointlocations []*organizationRPointlocationsR - Polygonlocations []*organizationRPolygonlocationsR - FieldseekerPool []*organizationRFieldseekerPoolR - Pooldetails []*organizationRPooldetailsR - Proposedtreatmentareas []*organizationRProposedtreatmentareasR - Qamosquitoinspections []*organizationRQamosquitoinspectionsR - Rodentlocations []*organizationRRodentlocationsR - Samplecollections []*organizationRSamplecollectionsR - Samplelocations []*organizationRSamplelocationsR - Servicerequests []*organizationRServicerequestsR - Speciesabundances []*organizationRSpeciesabundancesR - Stormdrains []*organizationRStormdrainsR - Timecards []*organizationRTimecardsR - Trapdata []*organizationRTrapdataR - Traplocations []*organizationRTraplocationsR - Treatments []*organizationRTreatmentsR - Treatmentareas []*organizationRTreatmentareasR - Zones []*organizationRZonesR - Zones2s []*organizationRZones2sR - FieldseekerSyncs []*organizationRFieldseekerSyncsR - Files []*organizationRFilesR - Pools []*organizationRPoolsR - H3Aggregations []*organizationRH3AggregationsR - NoteAudios []*organizationRNoteAudiosR - NoteImages []*organizationRNoteImagesR - ImportDistrictGidDistrict *organizationRImportDistrictGidDistrictR - Nuisances []*organizationRNuisancesR - PublicreportPool []*organizationRPublicreportPoolR - Quicks []*organizationRQuicksR - User []*organizationRUserR + EmailContacts []*organizationREmailContactsR + Phones []*organizationRPhonesR + Containerrelates []*organizationRContainerrelatesR + Fieldscoutinglogs []*organizationRFieldscoutinglogsR + Habitatrelates []*organizationRHabitatrelatesR + Inspectionsamples []*organizationRInspectionsamplesR + Inspectionsampledetails []*organizationRInspectionsampledetailsR + Linelocations []*organizationRLinelocationsR + Locationtrackings []*organizationRLocationtrackingsR + Mosquitoinspections []*organizationRMosquitoinspectionsR + Pointlocations []*organizationRPointlocationsR + Polygonlocations []*organizationRPolygonlocationsR + FieldseekerPool []*organizationRFieldseekerPoolR + Pooldetails []*organizationRPooldetailsR + Proposedtreatmentareas []*organizationRProposedtreatmentareasR + Qamosquitoinspections []*organizationRQamosquitoinspectionsR + Rodentlocations []*organizationRRodentlocationsR + Samplecollections []*organizationRSamplecollectionsR + Samplelocations []*organizationRSamplelocationsR + Servicerequests []*organizationRServicerequestsR + Speciesabundances []*organizationRSpeciesabundancesR + Stormdrains []*organizationRStormdrainsR + Timecards []*organizationRTimecardsR + Trapdata []*organizationRTrapdataR + Traplocations []*organizationRTraplocationsR + Treatments []*organizationRTreatmentsR + Treatmentareas []*organizationRTreatmentareasR + Zones []*organizationRZonesR + Zones2s []*organizationRZones2sR + FieldseekerSyncs []*organizationRFieldseekerSyncsR + Files []*organizationRFilesR + Pools []*organizationRPoolsR + H3Aggregations []*organizationRH3AggregationsR + NoteAudios []*organizationRNoteAudiosR + NoteImages []*organizationRNoteImagesR + Nuisances []*organizationRNuisancesR + PublicreportPool []*organizationRPublicreportPoolR + Quicks []*organizationRQuicksR + User []*organizationRUserR } type organizationREmailContactsR struct { @@ -236,9 +254,6 @@ type organizationRNoteImagesR struct { number int o *NoteImageTemplate } -type organizationRImportDistrictGidDistrictR struct { - o *ImportDistrictTemplate -} type organizationRNuisancesR struct { number int o *PublicreportNuisanceTemplate @@ -719,13 +734,6 @@ func (t OrganizationTemplate) setModelRels(o *models.Organization) { o.R.NoteImages = rel } - if t.r.ImportDistrictGidDistrict != nil { - rel := t.r.ImportDistrictGidDistrict.o.Build() - rel.R.ImportDistrictGidOrganization = o - o.ImportDistrictGid = null.From(rel.Gid) // h2 - o.R.ImportDistrictGidDistrict = rel - } - if t.r.Nuisances != nil { rel := models.PublicreportNuisanceSlice{} for _, r := range t.r.Nuisances { @@ -820,6 +828,46 @@ func (o OrganizationTemplate) BuildSetter() *models.OrganizationSetter { val := o.Slug() m.Slug = omitnull.FromNull(val) } + if o.GeneralManagerName != nil { + val := o.GeneralManagerName() + m.GeneralManagerName = omitnull.FromNull(val) + } + if o.MailingAddressCity != nil { + val := o.MailingAddressCity() + m.MailingAddressCity = omitnull.FromNull(val) + } + if o.MailingAddressPostalCode != nil { + val := o.MailingAddressPostalCode() + m.MailingAddressPostalCode = omitnull.FromNull(val) + } + if o.MailingAddressStreet != nil { + val := o.MailingAddressStreet() + m.MailingAddressStreet = omitnull.FromNull(val) + } + if o.OfficeAddressCity != nil { + val := o.OfficeAddressCity() + m.OfficeAddressCity = omitnull.FromNull(val) + } + if o.OfficeAddressPostalCode != nil { + val := o.OfficeAddressPostalCode() + m.OfficeAddressPostalCode = omitnull.FromNull(val) + } + if o.OfficeAddressStreet != nil { + val := o.OfficeAddressStreet() + m.OfficeAddressStreet = omitnull.FromNull(val) + } + if o.ServiceAreaGeometry != nil { + val := o.ServiceAreaGeometry() + m.ServiceAreaGeometry = omitnull.FromNull(val) + } + if o.OfficeFax != nil { + val := o.OfficeFax() + m.OfficeFax = omitnull.FromNull(val) + } + if o.OfficePhone != nil { + val := o.OfficePhone() + m.OfficePhone = omitnull.FromNull(val) + } return m } @@ -869,6 +917,60 @@ func (o OrganizationTemplate) Build() *models.Organization { if o.Slug != nil { m.Slug = o.Slug() } + if o.GeneralManagerName != nil { + m.GeneralManagerName = o.GeneralManagerName() + } + if o.MailingAddressCity != nil { + m.MailingAddressCity = o.MailingAddressCity() + } + if o.MailingAddressPostalCode != nil { + m.MailingAddressPostalCode = o.MailingAddressPostalCode() + } + if o.MailingAddressStreet != nil { + m.MailingAddressStreet = o.MailingAddressStreet() + } + if o.OfficeAddressCity != nil { + m.OfficeAddressCity = o.OfficeAddressCity() + } + if o.OfficeAddressPostalCode != nil { + m.OfficeAddressPostalCode = o.OfficeAddressPostalCode() + } + if o.OfficeAddressStreet != nil { + m.OfficeAddressStreet = o.OfficeAddressStreet() + } + if o.ServiceAreaGeometry != nil { + m.ServiceAreaGeometry = o.ServiceAreaGeometry() + } + if o.ServiceAreaSquareMeters != nil { + m.ServiceAreaSquareMeters = o.ServiceAreaSquareMeters() + } + if o.ServiceAreaCentroid != nil { + m.ServiceAreaCentroid = o.ServiceAreaCentroid() + } + if o.ServiceAreaExtent != nil { + m.ServiceAreaExtent = o.ServiceAreaExtent() + } + if o.OfficeFax != nil { + m.OfficeFax = o.OfficeFax() + } + if o.OfficePhone != nil { + m.OfficePhone = o.OfficePhone() + } + if o.ServiceAreaXmin != nil { + m.ServiceAreaXmin = o.ServiceAreaXmin() + } + if o.ServiceAreaYmin != nil { + m.ServiceAreaYmin = o.ServiceAreaYmin() + } + if o.ServiceAreaXmax != nil { + m.ServiceAreaXmax = o.ServiceAreaXmax() + } + if o.ServiceAreaYmax != nil { + m.ServiceAreaYmax = o.ServiceAreaYmax() + } + if o.ServiceAreaCentroidGeojson != nil { + m.ServiceAreaCentroidGeojson = o.ServiceAreaCentroidGeojson() + } o.setModelRels(m) @@ -1601,25 +1703,6 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu } } - isImportDistrictGidDistrictDone, _ := organizationRelImportDistrictGidDistrictCtx.Value(ctx) - if !isImportDistrictGidDistrictDone && o.r.ImportDistrictGidDistrict != nil { - ctx = organizationRelImportDistrictGidDistrictCtx.WithValue(ctx, true) - if o.r.ImportDistrictGidDistrict.o.alreadyPersisted { - m.R.ImportDistrictGidDistrict = o.r.ImportDistrictGidDistrict.o.Build() - } else { - var rel35 *models.ImportDistrict - rel35, err = o.r.ImportDistrictGidDistrict.o.Create(ctx, exec) - if err != nil { - return err - } - err = m.AttachImportDistrictGidDistrict(ctx, exec, rel35) - if err != nil { - return err - } - } - - } - isNuisancesDone, _ := organizationRelNuisancesCtx.Value(ctx) if !isNuisancesDone && o.r.Nuisances != nil { ctx = organizationRelNuisancesCtx.WithValue(ctx, true) @@ -1627,12 +1710,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.Nuisances = append(m.R.Nuisances, r.o.Build()) } else { - rel36, err := r.o.CreateMany(ctx, exec, r.number) + rel35, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachNuisances(ctx, exec, rel36...) + err = m.AttachNuisances(ctx, exec, rel35...) if err != nil { return err } @@ -1647,12 +1730,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.PublicreportPool = append(m.R.PublicreportPool, r.o.Build()) } else { - rel37, err := r.o.CreateMany(ctx, exec, r.number) + rel36, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachPublicreportPool(ctx, exec, rel37...) + err = m.AttachPublicreportPool(ctx, exec, rel36...) if err != nil { return err } @@ -1667,12 +1750,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.Quicks = append(m.R.Quicks, r.o.Build()) } else { - rel38, err := r.o.CreateMany(ctx, exec, r.number) + rel37, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachQuicks(ctx, exec, rel38...) + err = m.AttachQuicks(ctx, exec, rel37...) if err != nil { return err } @@ -1687,12 +1770,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu if r.o.alreadyPersisted { m.R.User = append(m.R.User, r.o.Build()) } else { - rel39, err := r.o.CreateMany(ctx, exec, r.number) + rel38, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachUser(ctx, exec, rel39...) + err = m.AttachUser(ctx, exec, rel38...) if err != nil { return err } @@ -1801,6 +1884,24 @@ func (m organizationMods) RandomizeAllColumns(f *faker.Faker) OrganizationMod { OrganizationMods.RandomWebsite(f), OrganizationMods.RandomLogoUUID(f), OrganizationMods.RandomSlug(f), + OrganizationMods.RandomGeneralManagerName(f), + OrganizationMods.RandomMailingAddressCity(f), + OrganizationMods.RandomMailingAddressPostalCode(f), + OrganizationMods.RandomMailingAddressStreet(f), + OrganizationMods.RandomOfficeAddressCity(f), + OrganizationMods.RandomOfficeAddressPostalCode(f), + OrganizationMods.RandomOfficeAddressStreet(f), + OrganizationMods.RandomServiceAreaGeometry(f), + OrganizationMods.RandomServiceAreaSquareMeters(f), + OrganizationMods.RandomServiceAreaCentroid(f), + OrganizationMods.RandomServiceAreaExtent(f), + OrganizationMods.RandomOfficeFax(f), + OrganizationMods.RandomOfficePhone(f), + OrganizationMods.RandomServiceAreaXmin(f), + OrganizationMods.RandomServiceAreaYmin(f), + OrganizationMods.RandomServiceAreaXmax(f), + OrganizationMods.RandomServiceAreaYmax(f), + OrganizationMods.RandomServiceAreaCentroidGeojson(f), } } @@ -2237,47 +2338,966 @@ func (m organizationMods) RandomSlugNotNull(f *faker.Faker) OrganizationMod { }) } +// Set the model columns to this value +func (m organizationMods) GeneralManagerName(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.GeneralManagerName = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) GeneralManagerNameFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.GeneralManagerName = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetGeneralManagerName() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.GeneralManagerName = 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 organizationMods) RandomGeneralManagerName(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.GeneralManagerName = 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 organizationMods) RandomGeneralManagerNameNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.GeneralManagerName = 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 organizationMods) MailingAddressCity(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressCity = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) MailingAddressCityFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressCity = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetMailingAddressCity() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressCity = 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 organizationMods) RandomMailingAddressCity(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressCity = 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 organizationMods) RandomMailingAddressCityNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressCity = 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 organizationMods) MailingAddressPostalCode(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressPostalCode = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) MailingAddressPostalCodeFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressPostalCode = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetMailingAddressPostalCode() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressPostalCode = 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 organizationMods) RandomMailingAddressPostalCode(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressPostalCode = 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 organizationMods) RandomMailingAddressPostalCodeNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressPostalCode = 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 organizationMods) MailingAddressStreet(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressStreet = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) MailingAddressStreetFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressStreet = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetMailingAddressStreet() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressStreet = 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 organizationMods) RandomMailingAddressStreet(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressStreet = 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 organizationMods) RandomMailingAddressStreetNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.MailingAddressStreet = 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 organizationMods) OfficeAddressCity(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressCity = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) OfficeAddressCityFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressCity = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetOfficeAddressCity() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressCity = 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 organizationMods) RandomOfficeAddressCity(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressCity = 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 organizationMods) RandomOfficeAddressCityNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressCity = 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 organizationMods) OfficeAddressPostalCode(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressPostalCode = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) OfficeAddressPostalCodeFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressPostalCode = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetOfficeAddressPostalCode() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressPostalCode = 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 organizationMods) RandomOfficeAddressPostalCode(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressPostalCode = 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 organizationMods) RandomOfficeAddressPostalCodeNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressPostalCode = 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 organizationMods) OfficeAddressStreet(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressStreet = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) OfficeAddressStreetFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressStreet = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetOfficeAddressStreet() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressStreet = 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 organizationMods) RandomOfficeAddressStreet(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressStreet = 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 organizationMods) RandomOfficeAddressStreetNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeAddressStreet = 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 organizationMods) ServiceAreaGeometry(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaGeometry = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaGeometryFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaGeometry = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaGeometry() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaGeometry = 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 organizationMods) RandomServiceAreaGeometry(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaGeometry = 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 organizationMods) RandomServiceAreaGeometryNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaGeometry = 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 organizationMods) ServiceAreaSquareMeters(val null.Val[decimal.Decimal]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaSquareMeters = func() null.Val[decimal.Decimal] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaSquareMetersFunc(f func() null.Val[decimal.Decimal]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaSquareMeters = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaSquareMeters() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaSquareMeters = 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 organizationMods) RandomServiceAreaSquareMeters(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaSquareMeters = func() null.Val[decimal.Decimal] { + if f == nil { + f = &defaultFaker + } + + val := random_decimal_Decimal(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 organizationMods) RandomServiceAreaSquareMetersNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaSquareMeters = func() null.Val[decimal.Decimal] { + if f == nil { + f = &defaultFaker + } + + val := random_decimal_Decimal(f) + return null.From(val) + } + }) +} + +// Set the model columns to this value +func (m organizationMods) ServiceAreaCentroid(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroid = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaCentroidFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroid = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaCentroid() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroid = 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 organizationMods) RandomServiceAreaCentroid(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroid = 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 organizationMods) RandomServiceAreaCentroidNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroid = 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 organizationMods) ServiceAreaExtent(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaExtent = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaExtentFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaExtent = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaExtent() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaExtent = 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 organizationMods) RandomServiceAreaExtent(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaExtent = 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 organizationMods) RandomServiceAreaExtentNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaExtent = 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 organizationMods) OfficeFax(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeFax = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) OfficeFaxFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeFax = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetOfficeFax() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeFax = 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 organizationMods) RandomOfficeFax(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeFax = 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 organizationMods) RandomOfficeFaxNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficeFax = 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 organizationMods) OfficePhone(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficePhone = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) OfficePhoneFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficePhone = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetOfficePhone() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficePhone = 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 organizationMods) RandomOfficePhone(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficePhone = 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 organizationMods) RandomOfficePhoneNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.OfficePhone = 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 organizationMods) ServiceAreaXmin(val null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmin = func() null.Val[float64] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaXminFunc(f func() null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmin = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaXmin() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmin = 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 organizationMods) RandomServiceAreaXmin(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmin = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(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 organizationMods) RandomServiceAreaXminNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmin = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(f) + return null.From(val) + } + }) +} + +// Set the model columns to this value +func (m organizationMods) ServiceAreaYmin(val null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmin = func() null.Val[float64] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaYminFunc(f func() null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmin = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaYmin() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmin = 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 organizationMods) RandomServiceAreaYmin(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmin = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(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 organizationMods) RandomServiceAreaYminNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmin = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(f) + return null.From(val) + } + }) +} + +// Set the model columns to this value +func (m organizationMods) ServiceAreaXmax(val null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmax = func() null.Val[float64] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaXmaxFunc(f func() null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmax = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaXmax() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmax = 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 organizationMods) RandomServiceAreaXmax(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmax = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(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 organizationMods) RandomServiceAreaXmaxNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaXmax = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(f) + return null.From(val) + } + }) +} + +// Set the model columns to this value +func (m organizationMods) ServiceAreaYmax(val null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmax = func() null.Val[float64] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaYmaxFunc(f func() null.Val[float64]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmax = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaYmax() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmax = 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 organizationMods) RandomServiceAreaYmax(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmax = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(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 organizationMods) RandomServiceAreaYmaxNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaYmax = func() null.Val[float64] { + if f == nil { + f = &defaultFaker + } + + val := random_float64(f) + return null.From(val) + } + }) +} + +// Set the model columns to this value +func (m organizationMods) ServiceAreaCentroidGeojson(val null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroidGeojson = func() null.Val[string] { return val } + }) +} + +// Set the Column from the function +func (m organizationMods) ServiceAreaCentroidGeojsonFunc(f func() null.Val[string]) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroidGeojson = f + }) +} + +// Clear any values for the column +func (m organizationMods) UnsetServiceAreaCentroidGeojson() OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroidGeojson = 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 organizationMods) RandomServiceAreaCentroidGeojson(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroidGeojson = 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 organizationMods) RandomServiceAreaCentroidGeojsonNotNull(f *faker.Faker) OrganizationMod { + return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) { + o.ServiceAreaCentroidGeojson = func() null.Val[string] { + if f == nil { + f = &defaultFaker + } + + val := random_string(f) + return null.From(val) + } + }) +} + func (m organizationMods) WithParentsCascading() OrganizationMod { return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { if isDone, _ := organizationWithParentsCascadingCtx.Value(ctx); isDone { return } ctx = organizationWithParentsCascadingCtx.WithValue(ctx, true) - { - - related := o.f.NewImportDistrictWithContext(ctx, ImportDistrictMods.WithParentsCascading()) - m.WithImportDistrictGidDistrict(related).Apply(ctx, o) - } - }) -} - -func (m organizationMods) WithImportDistrictGidDistrict(rel *ImportDistrictTemplate) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - o.r.ImportDistrictGidDistrict = &organizationRImportDistrictGidDistrictR{ - o: rel, - } - }) -} - -func (m organizationMods) WithNewImportDistrictGidDistrict(mods ...ImportDistrictMod) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - related := o.f.NewImportDistrictWithContext(ctx, mods...) - - m.WithImportDistrictGidDistrict(related).Apply(ctx, o) - }) -} - -func (m organizationMods) WithExistingImportDistrictGidDistrict(em *models.ImportDistrict) OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - o.r.ImportDistrictGidDistrict = &organizationRImportDistrictGidDistrictR{ - o: o.f.FromExistingImportDistrict(em), - } - }) -} - -func (m organizationMods) WithoutImportDistrictGidDistrict() OrganizationMod { - return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) { - o.r.ImportDistrictGidDistrict = nil }) } diff --git a/db/migrations/00064_organization_eats_district.sql b/db/migrations/00064_organization_eats_district.sql new file mode 100644 index 00000000..e231f02b --- /dev/null +++ b/db/migrations/00064_organization_eats_district.sql @@ -0,0 +1,24 @@ +-- +goose Up +ALTER TABLE organization ADD COLUMN general_manager_name TEXT; +ALTER TABLE organization ADD COLUMN mailing_address_city TEXT; +ALTER TABLE organization ADD COLUMN mailing_address_postal_code TEXT; +ALTER TABLE organization ADD COLUMN mailing_address_street TEXT; +ALTER TABLE organization ADD COLUMN office_address_city TEXT; +ALTER TABLE organization ADD COLUMN office_address_postal_code TEXT; +ALTER TABLE organization ADD COLUMN office_address_street TEXT; +ALTER TABLE organization ADD COLUMN office_fax TEXT; +ALTER TABLE organization ADD COLUMN office_phone TEXT; + +ALTER TABLE organization ADD COLUMN service_area_geometry geometry(MultiPolygon,4326); + +ALTER TABLE organization ADD COLUMN service_area_square_meters numeric GENERATED ALWAYS AS (ST_Area(service_area_geometry)) STORED; +ALTER TABLE organization ADD COLUMN service_area_centroid geometry(Point,4326) GENERATED ALWAYS AS (ST_Centroid(service_area_geometry)) STORED; +ALTER TABLE organization ADD COLUMN service_area_centroid_geojson TEXT GENERATED ALWAYS AS (ST_AsGeoJSON(ST_Centroid(service_area_geometry))) STORED; +ALTER TABLE organization ADD COLUMN service_area_extent geometry(Polygon,4326) GENERATED ALWAYS AS (ST_Envelope(service_area_geometry)) STORED; +ALTER TABLE organization ADD COLUMN service_area_xmin DOUBLE PRECISION GENERATED ALWAYS AS (ST_XMin(ST_Envelope(service_area_geometry))) STORED; +ALTER TABLE organization ADD COLUMN service_area_ymin DOUBLE PRECISION GENERATED ALWAYS AS (ST_YMin(ST_Envelope(service_area_geometry))) STORED; +ALTER TABLE organization ADD COLUMN service_area_xmax DOUBLE PRECISION GENERATED ALWAYS AS (ST_XMax(ST_Envelope(service_area_geometry))) STORED; +ALTER TABLE organization ADD COLUMN service_area_ymax DOUBLE PRECISION GENERATED ALWAYS AS (ST_YMax(ST_Envelope(service_area_geometry))) STORED; + +ALTER TABLE organization DROP CONSTRAINT organization_website_key; +-- +goose Down diff --git a/db/models/bob_joins.bob.go b/db/models/bob_joins.bob.go index 3a404754..26ad0ce8 100644 --- a/db/models/bob_joins.bob.go +++ b/db/models/bob_joins.bob.go @@ -76,7 +76,6 @@ type joins[Q dialect.Joinable] struct { FileuploadFiles joinSet[fileuploadFileJoins[Q]] FileuploadPools joinSet[fileuploadPoolJoins[Q]] H3Aggregations joinSet[h3AggregationJoins[Q]] - ImportDistricts joinSet[importDistrictJoins[Q]] NoteAudios joinSet[noteAudioJoins[Q]] NoteAudioBreadcrumbs joinSet[noteAudioBreadcrumbJoins[Q]] NoteAudioData joinSet[noteAudioDatumJoins[Q]] @@ -157,7 +156,6 @@ func getJoins[Q dialect.Joinable]() joins[Q] { FileuploadFiles: buildJoinSet[fileuploadFileJoins[Q]](FileuploadFiles.Columns, buildFileuploadFileJoins), FileuploadPools: buildJoinSet[fileuploadPoolJoins[Q]](FileuploadPools.Columns, buildFileuploadPoolJoins), H3Aggregations: buildJoinSet[h3AggregationJoins[Q]](H3Aggregations.Columns, buildH3AggregationJoins), - ImportDistricts: buildJoinSet[importDistrictJoins[Q]](ImportDistricts.Columns, buildImportDistrictJoins), NoteAudios: buildJoinSet[noteAudioJoins[Q]](NoteAudios.Columns, buildNoteAudioJoins), NoteAudioBreadcrumbs: buildJoinSet[noteAudioBreadcrumbJoins[Q]](NoteAudioBreadcrumbs.Columns, buildNoteAudioBreadcrumbJoins), NoteAudioData: buildJoinSet[noteAudioDatumJoins[Q]](NoteAudioData.Columns, buildNoteAudioDatumJoins), diff --git a/db/models/bob_loaders.bob.go b/db/models/bob_loaders.bob.go index 7bea80ed..11a9ad25 100644 --- a/db/models/bob_loaders.bob.go +++ b/db/models/bob_loaders.bob.go @@ -61,7 +61,6 @@ type preloaders struct { FileuploadFile fileuploadFilePreloader FileuploadPool fileuploadPoolPreloader H3Aggregation h3AggregationPreloader - ImportDistrict importDistrictPreloader NoteAudio noteAudioPreloader NoteAudioBreadcrumb noteAudioBreadcrumbPreloader NoteAudioDatum noteAudioDatumPreloader @@ -134,7 +133,6 @@ func getPreloaders() preloaders { FileuploadFile: buildFileuploadFilePreloader(), FileuploadPool: buildFileuploadPoolPreloader(), H3Aggregation: buildH3AggregationPreloader(), - ImportDistrict: buildImportDistrictPreloader(), NoteAudio: buildNoteAudioPreloader(), NoteAudioBreadcrumb: buildNoteAudioBreadcrumbPreloader(), NoteAudioDatum: buildNoteAudioDatumPreloader(), @@ -213,7 +211,6 @@ type thenLoaders[Q orm.Loadable] struct { FileuploadFile fileuploadFileThenLoader[Q] FileuploadPool fileuploadPoolThenLoader[Q] H3Aggregation h3AggregationThenLoader[Q] - ImportDistrict importDistrictThenLoader[Q] NoteAudio noteAudioThenLoader[Q] NoteAudioBreadcrumb noteAudioBreadcrumbThenLoader[Q] NoteAudioDatum noteAudioDatumThenLoader[Q] @@ -286,7 +283,6 @@ func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] { FileuploadFile: buildFileuploadFileThenLoader[Q](), FileuploadPool: buildFileuploadPoolThenLoader[Q](), H3Aggregation: buildH3AggregationThenLoader[Q](), - ImportDistrict: buildImportDistrictThenLoader[Q](), NoteAudio: buildNoteAudioThenLoader[Q](), NoteAudioBreadcrumb: buildNoteAudioBreadcrumbThenLoader[Q](), NoteAudioDatum: buildNoteAudioDatumThenLoader[Q](), diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go index 16a7045c..b9582fe8 100644 --- a/db/models/bob_where.bob.go +++ b/db/models/bob_where.bob.go @@ -64,7 +64,6 @@ func Where[Q psql.Filterable]() struct { GeometryColumns geometryColumnWhere[Q] GooseDBVersions gooseDBVersionWhere[Q] H3Aggregations h3AggregationWhere[Q] - ImportDistricts importDistrictWhere[Q] NoteAudios noteAudioWhere[Q] NoteAudioBreadcrumbs noteAudioBreadcrumbWhere[Q] NoteAudioData noteAudioDatumWhere[Q] @@ -143,7 +142,6 @@ func Where[Q psql.Filterable]() struct { GeometryColumns geometryColumnWhere[Q] GooseDBVersions gooseDBVersionWhere[Q] H3Aggregations h3AggregationWhere[Q] - ImportDistricts importDistrictWhere[Q] NoteAudios noteAudioWhere[Q] NoteAudioBreadcrumbs noteAudioBreadcrumbWhere[Q] NoteAudioData noteAudioDatumWhere[Q] @@ -221,7 +219,6 @@ func Where[Q psql.Filterable]() struct { GeometryColumns: buildGeometryColumnWhere[Q](GeometryColumns.Columns), GooseDBVersions: buildGooseDBVersionWhere[Q](GooseDBVersions.Columns), H3Aggregations: buildH3AggregationWhere[Q](H3Aggregations.Columns), - ImportDistricts: buildImportDistrictWhere[Q](ImportDistricts.Columns), NoteAudios: buildNoteAudioWhere[Q](NoteAudios.Columns), NoteAudioBreadcrumbs: buildNoteAudioBreadcrumbWhere[Q](NoteAudioBreadcrumbs.Columns), NoteAudioData: buildNoteAudioDatumWhere[Q](NoteAudioData.Columns), diff --git a/db/models/import.district.bob.go b/db/models/import.district.bob.go deleted file mode 100644 index 4821c30c..00000000 --- a/db/models/import.district.bob.go +++ /dev/null @@ -1,1134 +0,0 @@ -// Code generated by BobGen psql v0.42.5. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package models - -import ( - "context" - "fmt" - "io" - - "github.com/Gleipnir-Technology/bob" - "github.com/Gleipnir-Technology/bob/dialect/psql" - "github.com/Gleipnir-Technology/bob/dialect/psql/dialect" - "github.com/Gleipnir-Technology/bob/dialect/psql/dm" - "github.com/Gleipnir-Technology/bob/dialect/psql/sm" - "github.com/Gleipnir-Technology/bob/dialect/psql/um" - "github.com/Gleipnir-Technology/bob/expr" - "github.com/Gleipnir-Technology/bob/mods" - "github.com/Gleipnir-Technology/bob/orm" - "github.com/Gleipnir-Technology/bob/types/pgtypes" - "github.com/aarondl/opt/null" - "github.com/aarondl/opt/omit" - "github.com/aarondl/opt/omitnull" - "github.com/shopspring/decimal" -) - -// ImportDistrict is an object representing the database table. -type ImportDistrict 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" ` - Geom4326 null.Val[string] `db:"geom_4326,generated" ` - Centroid4326 null.Val[string] `db:"centroid_4326,generated" ` - Extent4326 null.Val[string] `db:"extent_4326,generated" ` - Area4326SQM null.Val[decimal.Decimal] `db:"area_4326_sqm,generated" ` - - R importDistrictR `db:"-" ` -} - -// ImportDistrictSlice is an alias for a slice of pointers to ImportDistrict. -// This should almost always be used instead of []*ImportDistrict. -type ImportDistrictSlice []*ImportDistrict - -// ImportDistricts contains methods to work with the district table -var ImportDistricts = psql.NewTablex[*ImportDistrict, ImportDistrictSlice, *ImportDistrictSetter]("import", "district", buildImportDistrictColumns("import.district")) - -// ImportDistrictsQuery is a query on the district table -type ImportDistrictsQuery = *psql.ViewQuery[*ImportDistrict, ImportDistrictSlice] - -// importDistrictR is where relationships are stored. -type importDistrictR struct { - ImportDistrictGidOrganization *Organization // organization.organization_import_district_gid_fkey -} - -func buildImportDistrictColumns(alias string) importDistrictColumns { - return importDistrictColumns{ - 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", "geom_4326", "centroid_4326", "extent_4326", "area_4326_sqm", - ).WithParent("import.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"), - Geom4326: psql.Quote(alias, "geom_4326"), - Centroid4326: psql.Quote(alias, "centroid_4326"), - Extent4326: psql.Quote(alias, "extent_4326"), - Area4326SQM: psql.Quote(alias, "area_4326_sqm"), - } -} - -type importDistrictColumns 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 - Geom4326 psql.Expression - Centroid4326 psql.Expression - Extent4326 psql.Expression - Area4326SQM psql.Expression -} - -func (c importDistrictColumns) Alias() string { - return c.tableAlias -} - -func (importDistrictColumns) AliasedAs(alias string) importDistrictColumns { - return buildImportDistrictColumns(alias) -} - -// ImportDistrictSetter is used for insert/upsert/update operations -// All values are optional, and do not have to be set -// Generated columns are not included -type ImportDistrictSetter 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 ImportDistrictSetter) 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 ImportDistrictSetter) Overwrite(t *ImportDistrict) { - 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 *ImportDistrictSetter) Apply(q *dialect.InsertQuery) { - q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { - return ImportDistricts.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 ImportDistrictSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { - return um.Set(s.Expressions()...) -} - -func (s ImportDistrictSetter) 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 -} - -// FindImportDistrict retrieves a single record by primary key -// If cols is empty Find will return all columns. -func FindImportDistrict(ctx context.Context, exec bob.Executor, GidPK int32, cols ...string) (*ImportDistrict, error) { - if len(cols) == 0 { - return ImportDistricts.Query( - sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(GidPK))), - ).One(ctx, exec) - } - - return ImportDistricts.Query( - sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(GidPK))), - sm.Columns(ImportDistricts.Columns.Only(cols...)), - ).One(ctx, exec) -} - -// ImportDistrictExists checks the presence of a single record by primary key -func ImportDistrictExists(ctx context.Context, exec bob.Executor, GidPK int32) (bool, error) { - return ImportDistricts.Query( - sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(GidPK))), - ).Exists(ctx, exec) -} - -// AfterQueryHook is called after ImportDistrict is retrieved from the database -func (o *ImportDistrict) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = ImportDistricts.AfterSelectHooks.RunHooks(ctx, exec, ImportDistrictSlice{o}) - case bob.QueryTypeInsert: - ctx, err = ImportDistricts.AfterInsertHooks.RunHooks(ctx, exec, ImportDistrictSlice{o}) - case bob.QueryTypeUpdate: - ctx, err = ImportDistricts.AfterUpdateHooks.RunHooks(ctx, exec, ImportDistrictSlice{o}) - case bob.QueryTypeDelete: - ctx, err = ImportDistricts.AfterDeleteHooks.RunHooks(ctx, exec, ImportDistrictSlice{o}) - } - - return err -} - -// primaryKeyVals returns the primary key values of the ImportDistrict -func (o *ImportDistrict) primaryKeyVals() bob.Expression { - return psql.Arg(o.Gid) -} - -func (o *ImportDistrict) pkEQ() dialect.Expression { - return psql.Quote("import.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 ImportDistrict -func (o *ImportDistrict) Update(ctx context.Context, exec bob.Executor, s *ImportDistrictSetter) error { - v, err := ImportDistricts.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec) - if err != nil { - return err - } - - o.R = v.R - *o = *v - - return nil -} - -// Delete deletes a single ImportDistrict record with an executor -func (o *ImportDistrict) Delete(ctx context.Context, exec bob.Executor) error { - _, err := ImportDistricts.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec) - return err -} - -// Reload refreshes the ImportDistrict using the executor -func (o *ImportDistrict) Reload(ctx context.Context, exec bob.Executor) error { - o2, err := ImportDistricts.Query( - sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(o.Gid))), - ).One(ctx, exec) - if err != nil { - return err - } - o2.R = o.R - *o = *o2 - - return nil -} - -// AfterQueryHook is called after ImportDistrictSlice is retrieved from the database -func (o ImportDistrictSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { - var err error - - switch queryType { - case bob.QueryTypeSelect: - ctx, err = ImportDistricts.AfterSelectHooks.RunHooks(ctx, exec, o) - case bob.QueryTypeInsert: - ctx, err = ImportDistricts.AfterInsertHooks.RunHooks(ctx, exec, o) - case bob.QueryTypeUpdate: - ctx, err = ImportDistricts.AfterUpdateHooks.RunHooks(ctx, exec, o) - case bob.QueryTypeDelete: - ctx, err = ImportDistricts.AfterDeleteHooks.RunHooks(ctx, exec, o) - } - - return err -} - -func (o ImportDistrictSlice) pkIN() dialect.Expression { - if len(o) == 0 { - return psql.Raw("NULL") - } - - return psql.Quote("import.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 ImportDistrictSlice) copyMatchingRows(from ...*ImportDistrict) { - for i, old := range o { - for _, new := range from { - if new.Gid != old.Gid { - continue - } - new.R = old.R - o[i] = new - break - } - } -} - -// UpdateMod modifies an update query with "WHERE primary_key IN (o...)" -func (o ImportDistrictSlice) 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 ImportDistricts.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 *ImportDistrict: - o.copyMatchingRows(retrieved) - case []*ImportDistrict: - o.copyMatchingRows(retrieved...) - case ImportDistrictSlice: - o.copyMatchingRows(retrieved...) - default: - // If the retrieved value is not a ImportDistrict or a slice of ImportDistrict - // then run the AfterUpdateHooks on the slice - _, err = ImportDistricts.AfterUpdateHooks.RunHooks(ctx, exec, o) - } - - return err - })) - - q.AppendWhere(o.pkIN()) - }) -} - -// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)" -func (o ImportDistrictSlice) 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 ImportDistricts.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 *ImportDistrict: - o.copyMatchingRows(retrieved) - case []*ImportDistrict: - o.copyMatchingRows(retrieved...) - case ImportDistrictSlice: - o.copyMatchingRows(retrieved...) - default: - // If the retrieved value is not a ImportDistrict or a slice of ImportDistrict - // then run the AfterDeleteHooks on the slice - _, err = ImportDistricts.AfterDeleteHooks.RunHooks(ctx, exec, o) - } - - return err - })) - - q.AppendWhere(o.pkIN()) - }) -} - -func (o ImportDistrictSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals ImportDistrictSetter) error { - if len(o) == 0 { - return nil - } - - _, err := ImportDistricts.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec) - return err -} - -func (o ImportDistrictSlice) DeleteAll(ctx context.Context, exec bob.Executor) error { - if len(o) == 0 { - return nil - } - - _, err := ImportDistricts.Delete(o.DeleteMod()).Exec(ctx, exec) - return err -} - -func (o ImportDistrictSlice) ReloadAll(ctx context.Context, exec bob.Executor) error { - if len(o) == 0 { - return nil - } - - o2, err := ImportDistricts.Query(sm.Where(o.pkIN())).All(ctx, exec) - if err != nil { - return err - } - - o.copyMatchingRows(o2...) - - return nil -} - -// ImportDistrictGidOrganization starts a query for related objects on organization -func (o *ImportDistrict) ImportDistrictGidOrganization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery { - return Organizations.Query(append(mods, - sm.Where(Organizations.Columns.ImportDistrictGid.EQ(psql.Arg(o.Gid))), - )...) -} - -func (os ImportDistrictSlice) ImportDistrictGidOrganization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery { - pkGid := make(pgtypes.Array[int32], 0, len(os)) - for _, o := range os { - if o == nil { - continue - } - pkGid = append(pkGid, o.Gid) - } - PKArgExpr := psql.Select(sm.Columns( - psql.F("unnest", psql.Cast(psql.Arg(pkGid), "integer[]")), - )) - - return Organizations.Query(append(mods, - sm.Where(psql.Group(Organizations.Columns.ImportDistrictGid).OP("IN", PKArgExpr)), - )...) -} - -func insertImportDistrictImportDistrictGidOrganization0(ctx context.Context, exec bob.Executor, organization1 *OrganizationSetter, importDistrict0 *ImportDistrict) (*Organization, error) { - organization1.ImportDistrictGid = omitnull.From(importDistrict0.Gid) - - ret, err := Organizations.Insert(organization1).One(ctx, exec) - if err != nil { - return ret, fmt.Errorf("insertImportDistrictImportDistrictGidOrganization0: %w", err) - } - - return ret, nil -} - -func attachImportDistrictImportDistrictGidOrganization0(ctx context.Context, exec bob.Executor, count int, organization1 *Organization, importDistrict0 *ImportDistrict) (*Organization, error) { - setter := &OrganizationSetter{ - ImportDistrictGid: omitnull.From(importDistrict0.Gid), - } - - err := organization1.Update(ctx, exec, setter) - if err != nil { - return nil, fmt.Errorf("attachImportDistrictImportDistrictGidOrganization0: %w", err) - } - - return organization1, nil -} - -func (importDistrict0 *ImportDistrict) InsertImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error { - var err error - - organization1, err := insertImportDistrictImportDistrictGidOrganization0(ctx, exec, related, importDistrict0) - if err != nil { - return err - } - - importDistrict0.R.ImportDistrictGidOrganization = organization1 - - organization1.R.ImportDistrictGidDistrict = importDistrict0 - - return nil -} - -func (importDistrict0 *ImportDistrict) AttachImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error { - var err error - - _, err = attachImportDistrictImportDistrictGidOrganization0(ctx, exec, 1, organization1, importDistrict0) - if err != nil { - return err - } - - importDistrict0.R.ImportDistrictGidOrganization = organization1 - - organization1.R.ImportDistrictGidDistrict = importDistrict0 - - return nil -} - -type importDistrictWhere[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] - Geom4326 psql.WhereNullMod[Q, string] - Centroid4326 psql.WhereNullMod[Q, string] - Extent4326 psql.WhereNullMod[Q, string] - Area4326SQM psql.WhereNullMod[Q, decimal.Decimal] -} - -func (importDistrictWhere[Q]) AliasedAs(alias string) importDistrictWhere[Q] { - return buildImportDistrictWhere[Q](buildImportDistrictColumns(alias)) -} - -func buildImportDistrictWhere[Q psql.Filterable](cols importDistrictColumns) importDistrictWhere[Q] { - return importDistrictWhere[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), - Geom4326: psql.WhereNull[Q, string](cols.Geom4326), - Centroid4326: psql.WhereNull[Q, string](cols.Centroid4326), - Extent4326: psql.WhereNull[Q, string](cols.Extent4326), - Area4326SQM: psql.WhereNull[Q, decimal.Decimal](cols.Area4326SQM), - } -} - -func (o *ImportDistrict) Preload(name string, retrieved any) error { - if o == nil { - return nil - } - - switch name { - case "ImportDistrictGidOrganization": - rel, ok := retrieved.(*Organization) - if !ok { - return fmt.Errorf("importDistrict cannot load %T as %q", retrieved, name) - } - - o.R.ImportDistrictGidOrganization = rel - - if rel != nil { - rel.R.ImportDistrictGidDistrict = o - } - return nil - default: - return fmt.Errorf("importDistrict has no relationship %q", name) - } -} - -type importDistrictPreloader struct { - ImportDistrictGidOrganization func(...psql.PreloadOption) psql.Preloader -} - -func buildImportDistrictPreloader() importDistrictPreloader { - return importDistrictPreloader{ - ImportDistrictGidOrganization: func(opts ...psql.PreloadOption) psql.Preloader { - return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{ - Name: "ImportDistrictGidOrganization", - Sides: []psql.PreloadSide{ - { - From: ImportDistricts, - To: Organizations, - FromColumns: []string{"gid"}, - ToColumns: []string{"import_district_gid"}, - }, - }, - }, Organizations.Columns.Names(), opts...) - }, - } -} - -type importDistrictThenLoader[Q orm.Loadable] struct { - ImportDistrictGidOrganization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] -} - -func buildImportDistrictThenLoader[Q orm.Loadable]() importDistrictThenLoader[Q] { - type ImportDistrictGidOrganizationLoadInterface interface { - LoadImportDistrictGidOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error - } - - return importDistrictThenLoader[Q]{ - ImportDistrictGidOrganization: thenLoadBuilder[Q]( - "ImportDistrictGidOrganization", - func(ctx context.Context, exec bob.Executor, retrieved ImportDistrictGidOrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { - return retrieved.LoadImportDistrictGidOrganization(ctx, exec, mods...) - }, - ), - } -} - -// LoadImportDistrictGidOrganization loads the importDistrict's ImportDistrictGidOrganization into the .R struct -func (o *ImportDistrict) LoadImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if o == nil { - return nil - } - - // Reset the relationship - o.R.ImportDistrictGidOrganization = nil - - related, err := o.ImportDistrictGidOrganization(mods...).One(ctx, exec) - if err != nil { - return err - } - - related.R.ImportDistrictGidDistrict = o - - o.R.ImportDistrictGidOrganization = related - return nil -} - -// LoadImportDistrictGidOrganization loads the importDistrict's ImportDistrictGidOrganization into the .R struct -func (os ImportDistrictSlice) LoadImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if len(os) == 0 { - return nil - } - - organizations, err := os.ImportDistrictGidOrganization(mods...).All(ctx, exec) - if err != nil { - return err - } - - for _, o := range os { - if o == nil { - continue - } - - for _, rel := range organizations { - - if !rel.ImportDistrictGid.IsValue() { - continue - } - if !(rel.ImportDistrictGid.IsValue() && o.Gid == rel.ImportDistrictGid.MustGet()) { - continue - } - - rel.R.ImportDistrictGidDistrict = o - - o.R.ImportDistrictGidOrganization = rel - break - } - } - - return nil -} - -type importDistrictJoins[Q dialect.Joinable] struct { - typ string - ImportDistrictGidOrganization modAs[Q, organizationColumns] -} - -func (j importDistrictJoins[Q]) aliasedAs(alias string) importDistrictJoins[Q] { - return buildImportDistrictJoins[Q](buildImportDistrictColumns(alias), j.typ) -} - -func buildImportDistrictJoins[Q dialect.Joinable](cols importDistrictColumns, typ string) importDistrictJoins[Q] { - return importDistrictJoins[Q]{ - typ: typ, - ImportDistrictGidOrganization: modAs[Q, organizationColumns]{ - c: Organizations.Columns, - f: func(to organizationColumns) bob.Mod[Q] { - mods := make(mods.QueryMods[Q], 0, 1) - - { - mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On( - to.ImportDistrictGid.EQ(cols.Gid), - )) - } - - return mods - }, - }, - } -} diff --git a/db/models/organization.bob.go b/db/models/organization.bob.go index 40f482ba..59de9e1b 100644 --- a/db/models/organization.bob.go +++ b/db/models/organization.bob.go @@ -23,20 +23,39 @@ import ( "github.com/aarondl/opt/omit" "github.com/aarondl/opt/omitnull" "github.com/google/uuid" + "github.com/shopspring/decimal" "github.com/stephenafamo/scan" ) // Organization is an object representing the database table. type Organization struct { - ID int32 `db:"id,pk" ` - Name string `db:"name" ` - ArcgisID null.Val[string] `db:"arcgis_id" ` - ArcgisName null.Val[string] `db:"arcgis_name" ` - FieldseekerURL null.Val[string] `db:"fieldseeker_url" ` - ImportDistrictGid null.Val[int32] `db:"import_district_gid" ` - Website null.Val[string] `db:"website" ` - LogoUUID null.Val[uuid.UUID] `db:"logo_uuid" ` - Slug null.Val[string] `db:"slug" ` + ID int32 `db:"id,pk" ` + Name string `db:"name" ` + ArcgisID null.Val[string] `db:"arcgis_id" ` + ArcgisName null.Val[string] `db:"arcgis_name" ` + FieldseekerURL null.Val[string] `db:"fieldseeker_url" ` + ImportDistrictGid null.Val[int32] `db:"import_district_gid" ` + Website null.Val[string] `db:"website" ` + LogoUUID null.Val[uuid.UUID] `db:"logo_uuid" ` + Slug null.Val[string] `db:"slug" ` + GeneralManagerName null.Val[string] `db:"general_manager_name" ` + MailingAddressCity null.Val[string] `db:"mailing_address_city" ` + MailingAddressPostalCode null.Val[string] `db:"mailing_address_postal_code" ` + MailingAddressStreet null.Val[string] `db:"mailing_address_street" ` + OfficeAddressCity null.Val[string] `db:"office_address_city" ` + OfficeAddressPostalCode null.Val[string] `db:"office_address_postal_code" ` + OfficeAddressStreet null.Val[string] `db:"office_address_street" ` + ServiceAreaGeometry null.Val[string] `db:"service_area_geometry" ` + ServiceAreaSquareMeters null.Val[decimal.Decimal] `db:"service_area_square_meters,generated" ` + ServiceAreaCentroid null.Val[string] `db:"service_area_centroid,generated" ` + ServiceAreaExtent null.Val[string] `db:"service_area_extent,generated" ` + OfficeFax null.Val[string] `db:"office_fax" ` + OfficePhone null.Val[string] `db:"office_phone" ` + ServiceAreaXmin null.Val[float64] `db:"service_area_xmin,generated" ` + ServiceAreaYmin null.Val[float64] `db:"service_area_ymin,generated" ` + ServiceAreaXmax null.Val[float64] `db:"service_area_xmax,generated" ` + ServiceAreaYmax null.Val[float64] `db:"service_area_ymax,generated" ` + ServiceAreaCentroidGeojson null.Val[string] `db:"service_area_centroid_geojson,generated" ` R organizationR `db:"-" ` @@ -55,78 +74,113 @@ type OrganizationsQuery = *psql.ViewQuery[*Organization, OrganizationSlice] // organizationR is where relationships are stored. type organizationR struct { - EmailContacts CommsEmailContactSlice // district_subscription_email.district_subscription_email_email_contact_address_fkeydistrict_subscription_email.district_subscription_email_organization_id_fkey - Phones CommsPhoneSlice // district_subscription_phone.district_subscription_phone_organization_id_fkeydistrict_subscription_phone.district_subscription_phone_phone_e164_fkey - Containerrelates FieldseekerContainerrelateSlice // fieldseeker.containerrelate.containerrelate_organization_id_fkey - Fieldscoutinglogs FieldseekerFieldscoutinglogSlice // fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey - Habitatrelates FieldseekerHabitatrelateSlice // fieldseeker.habitatrelate.habitatrelate_organization_id_fkey - Inspectionsamples FieldseekerInspectionsampleSlice // fieldseeker.inspectionsample.inspectionsample_organization_id_fkey - Inspectionsampledetails FieldseekerInspectionsampledetailSlice // fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey - Linelocations FieldseekerLinelocationSlice // fieldseeker.linelocation.linelocation_organization_id_fkey - Locationtrackings FieldseekerLocationtrackingSlice // fieldseeker.locationtracking.locationtracking_organization_id_fkey - Mosquitoinspections FieldseekerMosquitoinspectionSlice // fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey - Pointlocations FieldseekerPointlocationSlice // fieldseeker.pointlocation.pointlocation_organization_id_fkey - Polygonlocations FieldseekerPolygonlocationSlice // fieldseeker.polygonlocation.polygonlocation_organization_id_fkey - FieldseekerPool FieldseekerPoolSlice // fieldseeker.pool.pool_organization_id_fkey - Pooldetails FieldseekerPooldetailSlice // fieldseeker.pooldetail.pooldetail_organization_id_fkey - Proposedtreatmentareas FieldseekerProposedtreatmentareaSlice // fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey - Qamosquitoinspections FieldseekerQamosquitoinspectionSlice // fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey - Rodentlocations FieldseekerRodentlocationSlice // fieldseeker.rodentlocation.rodentlocation_organization_id_fkey - Samplecollections FieldseekerSamplecollectionSlice // fieldseeker.samplecollection.samplecollection_organization_id_fkey - Samplelocations FieldseekerSamplelocationSlice // fieldseeker.samplelocation.samplelocation_organization_id_fkey - Servicerequests FieldseekerServicerequestSlice // fieldseeker.servicerequest.servicerequest_organization_id_fkey - Speciesabundances FieldseekerSpeciesabundanceSlice // fieldseeker.speciesabundance.speciesabundance_organization_id_fkey - Stormdrains FieldseekerStormdrainSlice // fieldseeker.stormdrain.stormdrain_organization_id_fkey - Timecards FieldseekerTimecardSlice // fieldseeker.timecard.timecard_organization_id_fkey - Trapdata FieldseekerTrapdatumSlice // fieldseeker.trapdata.trapdata_organization_id_fkey - Traplocations FieldseekerTraplocationSlice // fieldseeker.traplocation.traplocation_organization_id_fkey - Treatments FieldseekerTreatmentSlice // fieldseeker.treatment.treatment_organization_id_fkey - Treatmentareas FieldseekerTreatmentareaSlice // fieldseeker.treatmentarea.treatmentarea_organization_id_fkey - Zones FieldseekerZoneSlice // fieldseeker.zones.zones_organization_id_fkey - Zones2s FieldseekerZones2Slice // fieldseeker.zones2.zones2_organization_id_fkey - FieldseekerSyncs FieldseekerSyncSlice // fieldseeker_sync.fieldseeker_sync_organization_id_fkey - Files FileuploadFileSlice // fileupload.file.file_organization_id_fkey - Pools FileuploadPoolSlice // fileupload.pool.pool_organization_id_fkey - H3Aggregations H3AggregationSlice // h3_aggregation.h3_aggregation_organization_id_fkey - NoteAudios NoteAudioSlice // note_audio.note_audio_organization_id_fkey - NoteImages NoteImageSlice // note_image.note_image_organization_id_fkey - ImportDistrictGidDistrict *ImportDistrict // organization.organization_import_district_gid_fkey - Nuisances PublicreportNuisanceSlice // publicreport.nuisance.nuisance_organization_id_fkey - PublicreportPool PublicreportPoolSlice // publicreport.pool.pool_organization_id_fkey - Quicks PublicreportQuickSlice // publicreport.quick.quick_organization_id_fkey - User UserSlice // user_.user__organization_id_fkey + EmailContacts CommsEmailContactSlice // district_subscription_email.district_subscription_email_email_contact_address_fkeydistrict_subscription_email.district_subscription_email_organization_id_fkey + Phones CommsPhoneSlice // district_subscription_phone.district_subscription_phone_organization_id_fkeydistrict_subscription_phone.district_subscription_phone_phone_e164_fkey + Containerrelates FieldseekerContainerrelateSlice // fieldseeker.containerrelate.containerrelate_organization_id_fkey + Fieldscoutinglogs FieldseekerFieldscoutinglogSlice // fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey + Habitatrelates FieldseekerHabitatrelateSlice // fieldseeker.habitatrelate.habitatrelate_organization_id_fkey + Inspectionsamples FieldseekerInspectionsampleSlice // fieldseeker.inspectionsample.inspectionsample_organization_id_fkey + Inspectionsampledetails FieldseekerInspectionsampledetailSlice // fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey + Linelocations FieldseekerLinelocationSlice // fieldseeker.linelocation.linelocation_organization_id_fkey + Locationtrackings FieldseekerLocationtrackingSlice // fieldseeker.locationtracking.locationtracking_organization_id_fkey + Mosquitoinspections FieldseekerMosquitoinspectionSlice // fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey + Pointlocations FieldseekerPointlocationSlice // fieldseeker.pointlocation.pointlocation_organization_id_fkey + Polygonlocations FieldseekerPolygonlocationSlice // fieldseeker.polygonlocation.polygonlocation_organization_id_fkey + FieldseekerPool FieldseekerPoolSlice // fieldseeker.pool.pool_organization_id_fkey + Pooldetails FieldseekerPooldetailSlice // fieldseeker.pooldetail.pooldetail_organization_id_fkey + Proposedtreatmentareas FieldseekerProposedtreatmentareaSlice // fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey + Qamosquitoinspections FieldseekerQamosquitoinspectionSlice // fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey + Rodentlocations FieldseekerRodentlocationSlice // fieldseeker.rodentlocation.rodentlocation_organization_id_fkey + Samplecollections FieldseekerSamplecollectionSlice // fieldseeker.samplecollection.samplecollection_organization_id_fkey + Samplelocations FieldseekerSamplelocationSlice // fieldseeker.samplelocation.samplelocation_organization_id_fkey + Servicerequests FieldseekerServicerequestSlice // fieldseeker.servicerequest.servicerequest_organization_id_fkey + Speciesabundances FieldseekerSpeciesabundanceSlice // fieldseeker.speciesabundance.speciesabundance_organization_id_fkey + Stormdrains FieldseekerStormdrainSlice // fieldseeker.stormdrain.stormdrain_organization_id_fkey + Timecards FieldseekerTimecardSlice // fieldseeker.timecard.timecard_organization_id_fkey + Trapdata FieldseekerTrapdatumSlice // fieldseeker.trapdata.trapdata_organization_id_fkey + Traplocations FieldseekerTraplocationSlice // fieldseeker.traplocation.traplocation_organization_id_fkey + Treatments FieldseekerTreatmentSlice // fieldseeker.treatment.treatment_organization_id_fkey + Treatmentareas FieldseekerTreatmentareaSlice // fieldseeker.treatmentarea.treatmentarea_organization_id_fkey + Zones FieldseekerZoneSlice // fieldseeker.zones.zones_organization_id_fkey + Zones2s FieldseekerZones2Slice // fieldseeker.zones2.zones2_organization_id_fkey + FieldseekerSyncs FieldseekerSyncSlice // fieldseeker_sync.fieldseeker_sync_organization_id_fkey + Files FileuploadFileSlice // fileupload.file.file_organization_id_fkey + Pools FileuploadPoolSlice // fileupload.pool.pool_organization_id_fkey + H3Aggregations H3AggregationSlice // h3_aggregation.h3_aggregation_organization_id_fkey + NoteAudios NoteAudioSlice // note_audio.note_audio_organization_id_fkey + NoteImages NoteImageSlice // note_image.note_image_organization_id_fkey + Nuisances PublicreportNuisanceSlice // publicreport.nuisance.nuisance_organization_id_fkey + PublicreportPool PublicreportPoolSlice // publicreport.pool.pool_organization_id_fkey + Quicks PublicreportQuickSlice // publicreport.quick.quick_organization_id_fkey + User UserSlice // user_.user__organization_id_fkey } func buildOrganizationColumns(alias string) organizationColumns { return organizationColumns{ ColumnsExpr: expr.NewColumnsExpr( - "id", "name", "arcgis_id", "arcgis_name", "fieldseeker_url", "import_district_gid", "website", "logo_uuid", "slug", + "id", "name", "arcgis_id", "arcgis_name", "fieldseeker_url", "import_district_gid", "website", "logo_uuid", "slug", "general_manager_name", "mailing_address_city", "mailing_address_postal_code", "mailing_address_street", "office_address_city", "office_address_postal_code", "office_address_street", "service_area_geometry", "service_area_square_meters", "service_area_centroid", "service_area_extent", "office_fax", "office_phone", "service_area_xmin", "service_area_ymin", "service_area_xmax", "service_area_ymax", "service_area_centroid_geojson", ).WithParent("organization"), - tableAlias: alias, - ID: psql.Quote(alias, "id"), - Name: psql.Quote(alias, "name"), - ArcgisID: psql.Quote(alias, "arcgis_id"), - ArcgisName: psql.Quote(alias, "arcgis_name"), - FieldseekerURL: psql.Quote(alias, "fieldseeker_url"), - ImportDistrictGid: psql.Quote(alias, "import_district_gid"), - Website: psql.Quote(alias, "website"), - LogoUUID: psql.Quote(alias, "logo_uuid"), - Slug: psql.Quote(alias, "slug"), + tableAlias: alias, + ID: psql.Quote(alias, "id"), + Name: psql.Quote(alias, "name"), + ArcgisID: psql.Quote(alias, "arcgis_id"), + ArcgisName: psql.Quote(alias, "arcgis_name"), + FieldseekerURL: psql.Quote(alias, "fieldseeker_url"), + ImportDistrictGid: psql.Quote(alias, "import_district_gid"), + Website: psql.Quote(alias, "website"), + LogoUUID: psql.Quote(alias, "logo_uuid"), + Slug: psql.Quote(alias, "slug"), + GeneralManagerName: psql.Quote(alias, "general_manager_name"), + MailingAddressCity: psql.Quote(alias, "mailing_address_city"), + MailingAddressPostalCode: psql.Quote(alias, "mailing_address_postal_code"), + MailingAddressStreet: psql.Quote(alias, "mailing_address_street"), + OfficeAddressCity: psql.Quote(alias, "office_address_city"), + OfficeAddressPostalCode: psql.Quote(alias, "office_address_postal_code"), + OfficeAddressStreet: psql.Quote(alias, "office_address_street"), + ServiceAreaGeometry: psql.Quote(alias, "service_area_geometry"), + ServiceAreaSquareMeters: psql.Quote(alias, "service_area_square_meters"), + ServiceAreaCentroid: psql.Quote(alias, "service_area_centroid"), + ServiceAreaExtent: psql.Quote(alias, "service_area_extent"), + OfficeFax: psql.Quote(alias, "office_fax"), + OfficePhone: psql.Quote(alias, "office_phone"), + ServiceAreaXmin: psql.Quote(alias, "service_area_xmin"), + ServiceAreaYmin: psql.Quote(alias, "service_area_ymin"), + ServiceAreaXmax: psql.Quote(alias, "service_area_xmax"), + ServiceAreaYmax: psql.Quote(alias, "service_area_ymax"), + ServiceAreaCentroidGeojson: psql.Quote(alias, "service_area_centroid_geojson"), } } type organizationColumns struct { expr.ColumnsExpr - tableAlias string - ID psql.Expression - Name psql.Expression - ArcgisID psql.Expression - ArcgisName psql.Expression - FieldseekerURL psql.Expression - ImportDistrictGid psql.Expression - Website psql.Expression - LogoUUID psql.Expression - Slug psql.Expression + tableAlias string + ID psql.Expression + Name psql.Expression + ArcgisID psql.Expression + ArcgisName psql.Expression + FieldseekerURL psql.Expression + ImportDistrictGid psql.Expression + Website psql.Expression + LogoUUID psql.Expression + Slug psql.Expression + GeneralManagerName psql.Expression + MailingAddressCity psql.Expression + MailingAddressPostalCode psql.Expression + MailingAddressStreet psql.Expression + OfficeAddressCity psql.Expression + OfficeAddressPostalCode psql.Expression + OfficeAddressStreet psql.Expression + ServiceAreaGeometry psql.Expression + ServiceAreaSquareMeters psql.Expression + ServiceAreaCentroid psql.Expression + ServiceAreaExtent psql.Expression + OfficeFax psql.Expression + OfficePhone psql.Expression + ServiceAreaXmin psql.Expression + ServiceAreaYmin psql.Expression + ServiceAreaXmax psql.Expression + ServiceAreaYmax psql.Expression + ServiceAreaCentroidGeojson psql.Expression } func (c organizationColumns) Alias() string { @@ -141,19 +195,29 @@ func (organizationColumns) AliasedAs(alias string) organizationColumns { // All values are optional, and do not have to be set // Generated columns are not included type OrganizationSetter struct { - ID omit.Val[int32] `db:"id,pk" ` - Name omit.Val[string] `db:"name" ` - ArcgisID omitnull.Val[string] `db:"arcgis_id" ` - ArcgisName omitnull.Val[string] `db:"arcgis_name" ` - FieldseekerURL omitnull.Val[string] `db:"fieldseeker_url" ` - ImportDistrictGid omitnull.Val[int32] `db:"import_district_gid" ` - Website omitnull.Val[string] `db:"website" ` - LogoUUID omitnull.Val[uuid.UUID] `db:"logo_uuid" ` - Slug omitnull.Val[string] `db:"slug" ` + ID omit.Val[int32] `db:"id,pk" ` + Name omit.Val[string] `db:"name" ` + ArcgisID omitnull.Val[string] `db:"arcgis_id" ` + ArcgisName omitnull.Val[string] `db:"arcgis_name" ` + FieldseekerURL omitnull.Val[string] `db:"fieldseeker_url" ` + ImportDistrictGid omitnull.Val[int32] `db:"import_district_gid" ` + Website omitnull.Val[string] `db:"website" ` + LogoUUID omitnull.Val[uuid.UUID] `db:"logo_uuid" ` + Slug omitnull.Val[string] `db:"slug" ` + GeneralManagerName omitnull.Val[string] `db:"general_manager_name" ` + MailingAddressCity omitnull.Val[string] `db:"mailing_address_city" ` + MailingAddressPostalCode omitnull.Val[string] `db:"mailing_address_postal_code" ` + MailingAddressStreet omitnull.Val[string] `db:"mailing_address_street" ` + OfficeAddressCity omitnull.Val[string] `db:"office_address_city" ` + OfficeAddressPostalCode omitnull.Val[string] `db:"office_address_postal_code" ` + OfficeAddressStreet omitnull.Val[string] `db:"office_address_street" ` + ServiceAreaGeometry omitnull.Val[string] `db:"service_area_geometry" ` + OfficeFax omitnull.Val[string] `db:"office_fax" ` + OfficePhone omitnull.Val[string] `db:"office_phone" ` } func (s OrganizationSetter) SetColumns() []string { - vals := make([]string, 0, 9) + vals := make([]string, 0, 19) if s.ID.IsValue() { vals = append(vals, "id") } @@ -181,6 +245,36 @@ func (s OrganizationSetter) SetColumns() []string { if !s.Slug.IsUnset() { vals = append(vals, "slug") } + if !s.GeneralManagerName.IsUnset() { + vals = append(vals, "general_manager_name") + } + if !s.MailingAddressCity.IsUnset() { + vals = append(vals, "mailing_address_city") + } + if !s.MailingAddressPostalCode.IsUnset() { + vals = append(vals, "mailing_address_postal_code") + } + if !s.MailingAddressStreet.IsUnset() { + vals = append(vals, "mailing_address_street") + } + if !s.OfficeAddressCity.IsUnset() { + vals = append(vals, "office_address_city") + } + if !s.OfficeAddressPostalCode.IsUnset() { + vals = append(vals, "office_address_postal_code") + } + if !s.OfficeAddressStreet.IsUnset() { + vals = append(vals, "office_address_street") + } + if !s.ServiceAreaGeometry.IsUnset() { + vals = append(vals, "service_area_geometry") + } + if !s.OfficeFax.IsUnset() { + vals = append(vals, "office_fax") + } + if !s.OfficePhone.IsUnset() { + vals = append(vals, "office_phone") + } return vals } @@ -212,6 +306,36 @@ func (s OrganizationSetter) Overwrite(t *Organization) { if !s.Slug.IsUnset() { t.Slug = s.Slug.MustGetNull() } + if !s.GeneralManagerName.IsUnset() { + t.GeneralManagerName = s.GeneralManagerName.MustGetNull() + } + if !s.MailingAddressCity.IsUnset() { + t.MailingAddressCity = s.MailingAddressCity.MustGetNull() + } + if !s.MailingAddressPostalCode.IsUnset() { + t.MailingAddressPostalCode = s.MailingAddressPostalCode.MustGetNull() + } + if !s.MailingAddressStreet.IsUnset() { + t.MailingAddressStreet = s.MailingAddressStreet.MustGetNull() + } + if !s.OfficeAddressCity.IsUnset() { + t.OfficeAddressCity = s.OfficeAddressCity.MustGetNull() + } + if !s.OfficeAddressPostalCode.IsUnset() { + t.OfficeAddressPostalCode = s.OfficeAddressPostalCode.MustGetNull() + } + if !s.OfficeAddressStreet.IsUnset() { + t.OfficeAddressStreet = s.OfficeAddressStreet.MustGetNull() + } + if !s.ServiceAreaGeometry.IsUnset() { + t.ServiceAreaGeometry = s.ServiceAreaGeometry.MustGetNull() + } + if !s.OfficeFax.IsUnset() { + t.OfficeFax = s.OfficeFax.MustGetNull() + } + if !s.OfficePhone.IsUnset() { + t.OfficePhone = s.OfficePhone.MustGetNull() + } } func (s *OrganizationSetter) Apply(q *dialect.InsertQuery) { @@ -220,7 +344,7 @@ func (s *OrganizationSetter) 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, 9) + vals := make([]bob.Expression, 19) if s.ID.IsValue() { vals[0] = psql.Arg(s.ID.MustGet()) } else { @@ -275,6 +399,66 @@ func (s *OrganizationSetter) Apply(q *dialect.InsertQuery) { vals[8] = psql.Raw("DEFAULT") } + if !s.GeneralManagerName.IsUnset() { + vals[9] = psql.Arg(s.GeneralManagerName.MustGetNull()) + } else { + vals[9] = psql.Raw("DEFAULT") + } + + if !s.MailingAddressCity.IsUnset() { + vals[10] = psql.Arg(s.MailingAddressCity.MustGetNull()) + } else { + vals[10] = psql.Raw("DEFAULT") + } + + if !s.MailingAddressPostalCode.IsUnset() { + vals[11] = psql.Arg(s.MailingAddressPostalCode.MustGetNull()) + } else { + vals[11] = psql.Raw("DEFAULT") + } + + if !s.MailingAddressStreet.IsUnset() { + vals[12] = psql.Arg(s.MailingAddressStreet.MustGetNull()) + } else { + vals[12] = psql.Raw("DEFAULT") + } + + if !s.OfficeAddressCity.IsUnset() { + vals[13] = psql.Arg(s.OfficeAddressCity.MustGetNull()) + } else { + vals[13] = psql.Raw("DEFAULT") + } + + if !s.OfficeAddressPostalCode.IsUnset() { + vals[14] = psql.Arg(s.OfficeAddressPostalCode.MustGetNull()) + } else { + vals[14] = psql.Raw("DEFAULT") + } + + if !s.OfficeAddressStreet.IsUnset() { + vals[15] = psql.Arg(s.OfficeAddressStreet.MustGetNull()) + } else { + vals[15] = psql.Raw("DEFAULT") + } + + if !s.ServiceAreaGeometry.IsUnset() { + vals[16] = psql.Arg(s.ServiceAreaGeometry.MustGetNull()) + } else { + vals[16] = psql.Raw("DEFAULT") + } + + if !s.OfficeFax.IsUnset() { + vals[17] = psql.Arg(s.OfficeFax.MustGetNull()) + } else { + vals[17] = psql.Raw("DEFAULT") + } + + if !s.OfficePhone.IsUnset() { + vals[18] = psql.Arg(s.OfficePhone.MustGetNull()) + } else { + vals[18] = psql.Raw("DEFAULT") + } + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") })) } @@ -284,7 +468,7 @@ func (s OrganizationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { } func (s OrganizationSetter) Expressions(prefix ...string) []bob.Expression { - exprs := make([]bob.Expression, 0, 9) + exprs := make([]bob.Expression, 0, 19) if s.ID.IsValue() { exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ @@ -349,6 +533,76 @@ func (s OrganizationSetter) Expressions(prefix ...string) []bob.Expression { }}) } + if !s.GeneralManagerName.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "general_manager_name")...), + psql.Arg(s.GeneralManagerName), + }}) + } + + if !s.MailingAddressCity.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "mailing_address_city")...), + psql.Arg(s.MailingAddressCity), + }}) + } + + if !s.MailingAddressPostalCode.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "mailing_address_postal_code")...), + psql.Arg(s.MailingAddressPostalCode), + }}) + } + + if !s.MailingAddressStreet.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "mailing_address_street")...), + psql.Arg(s.MailingAddressStreet), + }}) + } + + if !s.OfficeAddressCity.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "office_address_city")...), + psql.Arg(s.OfficeAddressCity), + }}) + } + + if !s.OfficeAddressPostalCode.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "office_address_postal_code")...), + psql.Arg(s.OfficeAddressPostalCode), + }}) + } + + if !s.OfficeAddressStreet.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "office_address_street")...), + psql.Arg(s.OfficeAddressStreet), + }}) + } + + if !s.ServiceAreaGeometry.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "service_area_geometry")...), + psql.Arg(s.ServiceAreaGeometry), + }}) + } + + if !s.OfficeFax.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "office_fax")...), + psql.Arg(s.OfficeFax), + }}) + } + + if !s.OfficePhone.IsUnset() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "office_phone")...), + psql.Arg(s.OfficePhone), + }}) + } + return exprs } @@ -1425,30 +1679,6 @@ func (os OrganizationSlice) NoteImages(mods ...bob.Mod[*dialect.SelectQuery]) No )...) } -// ImportDistrictGidDistrict starts a query for related objects on import.district -func (o *Organization) ImportDistrictGidDistrict(mods ...bob.Mod[*dialect.SelectQuery]) ImportDistrictsQuery { - return ImportDistricts.Query(append(mods, - sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(o.ImportDistrictGid))), - )...) -} - -func (os OrganizationSlice) ImportDistrictGidDistrict(mods ...bob.Mod[*dialect.SelectQuery]) ImportDistrictsQuery { - pkImportDistrictGid := make(pgtypes.Array[null.Val[int32]], 0, len(os)) - for _, o := range os { - if o == nil { - continue - } - pkImportDistrictGid = append(pkImportDistrictGid, o.ImportDistrictGid) - } - PKArgExpr := psql.Select(sm.Columns( - psql.F("unnest", psql.Cast(psql.Arg(pkImportDistrictGid), "integer[]")), - )) - - return ImportDistricts.Query(append(mods, - sm.Where(psql.Group(ImportDistricts.Columns.Gid).OP("IN", PKArgExpr)), - )...) -} - // Nuisances starts a query for related objects on publicreport.nuisance func (o *Organization) Nuisances(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNuisancesQuery { return PublicreportNuisances.Query(append(mods, @@ -3919,54 +4149,6 @@ func (organization0 *Organization) AttachNoteImages(ctx context.Context, exec bo return nil } -func attachOrganizationImportDistrictGidDistrict0(ctx context.Context, exec bob.Executor, count int, organization0 *Organization, importDistrict1 *ImportDistrict) (*Organization, error) { - setter := &OrganizationSetter{ - ImportDistrictGid: omitnull.From(importDistrict1.Gid), - } - - err := organization0.Update(ctx, exec, setter) - if err != nil { - return nil, fmt.Errorf("attachOrganizationImportDistrictGidDistrict0: %w", err) - } - - return organization0, nil -} - -func (organization0 *Organization) InsertImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, related *ImportDistrictSetter) error { - var err error - - importDistrict1, err := ImportDistricts.Insert(related).One(ctx, exec) - if err != nil { - return fmt.Errorf("inserting related objects: %w", err) - } - - _, err = attachOrganizationImportDistrictGidDistrict0(ctx, exec, 1, organization0, importDistrict1) - if err != nil { - return err - } - - organization0.R.ImportDistrictGidDistrict = importDistrict1 - - importDistrict1.R.ImportDistrictGidOrganization = organization0 - - return nil -} - -func (organization0 *Organization) AttachImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, importDistrict1 *ImportDistrict) error { - var err error - - _, err = attachOrganizationImportDistrictGidDistrict0(ctx, exec, 1, organization0, importDistrict1) - if err != nil { - return err - } - - organization0.R.ImportDistrictGidDistrict = importDistrict1 - - importDistrict1.R.ImportDistrictGidOrganization = organization0 - - return nil -} - func insertOrganizationNuisances0(ctx context.Context, exec bob.Executor, publicreportNuisances1 []*PublicreportNuisanceSetter, organization0 *Organization) (PublicreportNuisanceSlice, error) { for i := range publicreportNuisances1 { publicreportNuisances1[i].OrganizationID = omitnull.From(organization0.ID) @@ -4240,15 +4422,33 @@ func (organization0 *Organization) AttachUser(ctx context.Context, exec bob.Exec } type organizationWhere[Q psql.Filterable] struct { - ID psql.WhereMod[Q, int32] - Name psql.WhereMod[Q, string] - ArcgisID psql.WhereNullMod[Q, string] - ArcgisName psql.WhereNullMod[Q, string] - FieldseekerURL psql.WhereNullMod[Q, string] - ImportDistrictGid psql.WhereNullMod[Q, int32] - Website psql.WhereNullMod[Q, string] - LogoUUID psql.WhereNullMod[Q, uuid.UUID] - Slug psql.WhereNullMod[Q, string] + ID psql.WhereMod[Q, int32] + Name psql.WhereMod[Q, string] + ArcgisID psql.WhereNullMod[Q, string] + ArcgisName psql.WhereNullMod[Q, string] + FieldseekerURL psql.WhereNullMod[Q, string] + ImportDistrictGid psql.WhereNullMod[Q, int32] + Website psql.WhereNullMod[Q, string] + LogoUUID psql.WhereNullMod[Q, uuid.UUID] + Slug psql.WhereNullMod[Q, string] + GeneralManagerName psql.WhereNullMod[Q, string] + MailingAddressCity psql.WhereNullMod[Q, string] + MailingAddressPostalCode psql.WhereNullMod[Q, string] + MailingAddressStreet psql.WhereNullMod[Q, string] + OfficeAddressCity psql.WhereNullMod[Q, string] + OfficeAddressPostalCode psql.WhereNullMod[Q, string] + OfficeAddressStreet psql.WhereNullMod[Q, string] + ServiceAreaGeometry psql.WhereNullMod[Q, string] + ServiceAreaSquareMeters psql.WhereNullMod[Q, decimal.Decimal] + ServiceAreaCentroid psql.WhereNullMod[Q, string] + ServiceAreaExtent psql.WhereNullMod[Q, string] + OfficeFax psql.WhereNullMod[Q, string] + OfficePhone psql.WhereNullMod[Q, string] + ServiceAreaXmin psql.WhereNullMod[Q, float64] + ServiceAreaYmin psql.WhereNullMod[Q, float64] + ServiceAreaXmax psql.WhereNullMod[Q, float64] + ServiceAreaYmax psql.WhereNullMod[Q, float64] + ServiceAreaCentroidGeojson psql.WhereNullMod[Q, string] } func (organizationWhere[Q]) AliasedAs(alias string) organizationWhere[Q] { @@ -4257,15 +4457,33 @@ func (organizationWhere[Q]) AliasedAs(alias string) organizationWhere[Q] { func buildOrganizationWhere[Q psql.Filterable](cols organizationColumns) organizationWhere[Q] { return organizationWhere[Q]{ - ID: psql.Where[Q, int32](cols.ID), - Name: psql.Where[Q, string](cols.Name), - ArcgisID: psql.WhereNull[Q, string](cols.ArcgisID), - ArcgisName: psql.WhereNull[Q, string](cols.ArcgisName), - FieldseekerURL: psql.WhereNull[Q, string](cols.FieldseekerURL), - ImportDistrictGid: psql.WhereNull[Q, int32](cols.ImportDistrictGid), - Website: psql.WhereNull[Q, string](cols.Website), - LogoUUID: psql.WhereNull[Q, uuid.UUID](cols.LogoUUID), - Slug: psql.WhereNull[Q, string](cols.Slug), + ID: psql.Where[Q, int32](cols.ID), + Name: psql.Where[Q, string](cols.Name), + ArcgisID: psql.WhereNull[Q, string](cols.ArcgisID), + ArcgisName: psql.WhereNull[Q, string](cols.ArcgisName), + FieldseekerURL: psql.WhereNull[Q, string](cols.FieldseekerURL), + ImportDistrictGid: psql.WhereNull[Q, int32](cols.ImportDistrictGid), + Website: psql.WhereNull[Q, string](cols.Website), + LogoUUID: psql.WhereNull[Q, uuid.UUID](cols.LogoUUID), + Slug: psql.WhereNull[Q, string](cols.Slug), + GeneralManagerName: psql.WhereNull[Q, string](cols.GeneralManagerName), + MailingAddressCity: psql.WhereNull[Q, string](cols.MailingAddressCity), + MailingAddressPostalCode: psql.WhereNull[Q, string](cols.MailingAddressPostalCode), + MailingAddressStreet: psql.WhereNull[Q, string](cols.MailingAddressStreet), + OfficeAddressCity: psql.WhereNull[Q, string](cols.OfficeAddressCity), + OfficeAddressPostalCode: psql.WhereNull[Q, string](cols.OfficeAddressPostalCode), + OfficeAddressStreet: psql.WhereNull[Q, string](cols.OfficeAddressStreet), + ServiceAreaGeometry: psql.WhereNull[Q, string](cols.ServiceAreaGeometry), + ServiceAreaSquareMeters: psql.WhereNull[Q, decimal.Decimal](cols.ServiceAreaSquareMeters), + ServiceAreaCentroid: psql.WhereNull[Q, string](cols.ServiceAreaCentroid), + ServiceAreaExtent: psql.WhereNull[Q, string](cols.ServiceAreaExtent), + OfficeFax: psql.WhereNull[Q, string](cols.OfficeFax), + OfficePhone: psql.WhereNull[Q, string](cols.OfficePhone), + ServiceAreaXmin: psql.WhereNull[Q, float64](cols.ServiceAreaXmin), + ServiceAreaYmin: psql.WhereNull[Q, float64](cols.ServiceAreaYmin), + ServiceAreaXmax: psql.WhereNull[Q, float64](cols.ServiceAreaXmax), + ServiceAreaYmax: psql.WhereNull[Q, float64](cols.ServiceAreaYmax), + ServiceAreaCentroidGeojson: psql.WhereNull[Q, string](cols.ServiceAreaCentroidGeojson), } } @@ -4765,18 +4983,6 @@ func (o *Organization) Preload(name string, retrieved any) error { } } return nil - case "ImportDistrictGidDistrict": - rel, ok := retrieved.(*ImportDistrict) - if !ok { - return fmt.Errorf("organization cannot load %T as %q", retrieved, name) - } - - o.R.ImportDistrictGidDistrict = rel - - if rel != nil { - rel.R.ImportDistrictGidOrganization = o - } - return nil case "Nuisances": rels, ok := retrieved.(PublicreportNuisanceSlice) if !ok { @@ -4838,69 +5044,52 @@ func (o *Organization) Preload(name string, retrieved any) error { } } -type organizationPreloader struct { - ImportDistrictGidDistrict func(...psql.PreloadOption) psql.Preloader -} +type organizationPreloader struct{} func buildOrganizationPreloader() organizationPreloader { - return organizationPreloader{ - ImportDistrictGidDistrict: func(opts ...psql.PreloadOption) psql.Preloader { - return psql.Preload[*ImportDistrict, ImportDistrictSlice](psql.PreloadRel{ - Name: "ImportDistrictGidDistrict", - Sides: []psql.PreloadSide{ - { - From: Organizations, - To: ImportDistricts, - FromColumns: []string{"import_district_gid"}, - ToColumns: []string{"gid"}, - }, - }, - }, ImportDistricts.Columns.Names(), opts...) - }, - } + return organizationPreloader{} } type organizationThenLoader[Q orm.Loadable] struct { - EmailContacts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Phones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Containerrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Linelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Pointlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - FieldseekerPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Pooldetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Samplecollections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Samplelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Servicerequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Stormdrains func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Timecards func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Trapdata func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Traplocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Treatments func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Zones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Files func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - ImportDistrictGidDistrict func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Nuisances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - PublicreportPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - Quicks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] - User func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + EmailContacts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Phones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Containerrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Linelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Pointlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + FieldseekerPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Pooldetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Samplecollections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Samplelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Servicerequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Stormdrains func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Timecards func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Trapdata func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Traplocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Treatments func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Zones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Files func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Nuisances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + PublicreportPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Quicks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + User func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] } func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] { @@ -5009,9 +5198,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] { type NoteImagesLoadInterface interface { LoadNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error } - type ImportDistrictGidDistrictLoadInterface interface { - LoadImportDistrictGidDistrict(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error - } type NuisancesLoadInterface interface { LoadNuisances(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error } @@ -5236,12 +5422,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] { return retrieved.LoadNoteImages(ctx, exec, mods...) }, ), - ImportDistrictGidDistrict: thenLoadBuilder[Q]( - "ImportDistrictGidDistrict", - func(ctx context.Context, exec bob.Executor, retrieved ImportDistrictGidDistrictLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { - return retrieved.LoadImportDistrictGidDistrict(ctx, exec, mods...) - }, - ), Nuisances: thenLoadBuilder[Q]( "Nuisances", func(ctx context.Context, exec bob.Executor, retrieved NuisancesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { @@ -7444,61 +7624,6 @@ func (os OrganizationSlice) LoadNoteImages(ctx context.Context, exec bob.Executo return nil } -// LoadImportDistrictGidDistrict loads the organization's ImportDistrictGidDistrict into the .R struct -func (o *Organization) LoadImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if o == nil { - return nil - } - - // Reset the relationship - o.R.ImportDistrictGidDistrict = nil - - related, err := o.ImportDistrictGidDistrict(mods...).One(ctx, exec) - if err != nil { - return err - } - - related.R.ImportDistrictGidOrganization = o - - o.R.ImportDistrictGidDistrict = related - return nil -} - -// LoadImportDistrictGidDistrict loads the organization's ImportDistrictGidDistrict into the .R struct -func (os OrganizationSlice) LoadImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { - if len(os) == 0 { - return nil - } - - importDistricts, err := os.ImportDistrictGidDistrict(mods...).All(ctx, exec) - if err != nil { - return err - } - - for _, o := range os { - if o == nil { - continue - } - - for _, rel := range importDistricts { - if !o.ImportDistrictGid.IsValue() { - continue - } - - if !(o.ImportDistrictGid.IsValue() && o.ImportDistrictGid.MustGet() == rel.Gid) { - continue - } - - rel.R.ImportDistrictGidOrganization = o - - o.R.ImportDistrictGidDistrict = rel - break - } - } - - return nil -} - // LoadNuisances loads the organization's Nuisances into the .R struct func (o *Organization) LoadNuisances(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { if o == nil { @@ -10170,47 +10295,46 @@ func (os OrganizationSlice) LoadCountUser(ctx context.Context, exec bob.Executor } type organizationJoins[Q dialect.Joinable] struct { - typ string - EmailContacts modAs[Q, commsEmailContactColumns] - Phones modAs[Q, commsPhoneColumns] - Containerrelates modAs[Q, fieldseekerContainerrelateColumns] - Fieldscoutinglogs modAs[Q, fieldseekerFieldscoutinglogColumns] - Habitatrelates modAs[Q, fieldseekerHabitatrelateColumns] - Inspectionsamples modAs[Q, fieldseekerInspectionsampleColumns] - Inspectionsampledetails modAs[Q, fieldseekerInspectionsampledetailColumns] - Linelocations modAs[Q, fieldseekerLinelocationColumns] - Locationtrackings modAs[Q, fieldseekerLocationtrackingColumns] - Mosquitoinspections modAs[Q, fieldseekerMosquitoinspectionColumns] - Pointlocations modAs[Q, fieldseekerPointlocationColumns] - Polygonlocations modAs[Q, fieldseekerPolygonlocationColumns] - FieldseekerPool modAs[Q, fieldseekerPoolColumns] - Pooldetails modAs[Q, fieldseekerPooldetailColumns] - Proposedtreatmentareas modAs[Q, fieldseekerProposedtreatmentareaColumns] - Qamosquitoinspections modAs[Q, fieldseekerQamosquitoinspectionColumns] - Rodentlocations modAs[Q, fieldseekerRodentlocationColumns] - Samplecollections modAs[Q, fieldseekerSamplecollectionColumns] - Samplelocations modAs[Q, fieldseekerSamplelocationColumns] - Servicerequests modAs[Q, fieldseekerServicerequestColumns] - Speciesabundances modAs[Q, fieldseekerSpeciesabundanceColumns] - Stormdrains modAs[Q, fieldseekerStormdrainColumns] - Timecards modAs[Q, fieldseekerTimecardColumns] - Trapdata modAs[Q, fieldseekerTrapdatumColumns] - Traplocations modAs[Q, fieldseekerTraplocationColumns] - Treatments modAs[Q, fieldseekerTreatmentColumns] - Treatmentareas modAs[Q, fieldseekerTreatmentareaColumns] - Zones modAs[Q, fieldseekerZoneColumns] - Zones2s modAs[Q, fieldseekerZones2Columns] - FieldseekerSyncs modAs[Q, fieldseekerSyncColumns] - Files modAs[Q, fileuploadFileColumns] - Pools modAs[Q, fileuploadPoolColumns] - H3Aggregations modAs[Q, h3AggregationColumns] - NoteAudios modAs[Q, noteAudioColumns] - NoteImages modAs[Q, noteImageColumns] - ImportDistrictGidDistrict modAs[Q, importDistrictColumns] - Nuisances modAs[Q, publicreportNuisanceColumns] - PublicreportPool modAs[Q, publicreportPoolColumns] - Quicks modAs[Q, publicreportQuickColumns] - User modAs[Q, userColumns] + typ string + EmailContacts modAs[Q, commsEmailContactColumns] + Phones modAs[Q, commsPhoneColumns] + Containerrelates modAs[Q, fieldseekerContainerrelateColumns] + Fieldscoutinglogs modAs[Q, fieldseekerFieldscoutinglogColumns] + Habitatrelates modAs[Q, fieldseekerHabitatrelateColumns] + Inspectionsamples modAs[Q, fieldseekerInspectionsampleColumns] + Inspectionsampledetails modAs[Q, fieldseekerInspectionsampledetailColumns] + Linelocations modAs[Q, fieldseekerLinelocationColumns] + Locationtrackings modAs[Q, fieldseekerLocationtrackingColumns] + Mosquitoinspections modAs[Q, fieldseekerMosquitoinspectionColumns] + Pointlocations modAs[Q, fieldseekerPointlocationColumns] + Polygonlocations modAs[Q, fieldseekerPolygonlocationColumns] + FieldseekerPool modAs[Q, fieldseekerPoolColumns] + Pooldetails modAs[Q, fieldseekerPooldetailColumns] + Proposedtreatmentareas modAs[Q, fieldseekerProposedtreatmentareaColumns] + Qamosquitoinspections modAs[Q, fieldseekerQamosquitoinspectionColumns] + Rodentlocations modAs[Q, fieldseekerRodentlocationColumns] + Samplecollections modAs[Q, fieldseekerSamplecollectionColumns] + Samplelocations modAs[Q, fieldseekerSamplelocationColumns] + Servicerequests modAs[Q, fieldseekerServicerequestColumns] + Speciesabundances modAs[Q, fieldseekerSpeciesabundanceColumns] + Stormdrains modAs[Q, fieldseekerStormdrainColumns] + Timecards modAs[Q, fieldseekerTimecardColumns] + Trapdata modAs[Q, fieldseekerTrapdatumColumns] + Traplocations modAs[Q, fieldseekerTraplocationColumns] + Treatments modAs[Q, fieldseekerTreatmentColumns] + Treatmentareas modAs[Q, fieldseekerTreatmentareaColumns] + Zones modAs[Q, fieldseekerZoneColumns] + Zones2s modAs[Q, fieldseekerZones2Columns] + FieldseekerSyncs modAs[Q, fieldseekerSyncColumns] + Files modAs[Q, fileuploadFileColumns] + Pools modAs[Q, fileuploadPoolColumns] + H3Aggregations modAs[Q, h3AggregationColumns] + NoteAudios modAs[Q, noteAudioColumns] + NoteImages modAs[Q, noteImageColumns] + Nuisances modAs[Q, publicreportNuisanceColumns] + PublicreportPool modAs[Q, publicreportPoolColumns] + Quicks modAs[Q, publicreportQuickColumns] + User modAs[Q, userColumns] } func (j organizationJoins[Q]) aliasedAs(alias string) organizationJoins[Q] { @@ -10726,20 +10850,6 @@ func buildOrganizationJoins[Q dialect.Joinable](cols organizationColumns, typ st return mods }, }, - ImportDistrictGidDistrict: modAs[Q, importDistrictColumns]{ - c: ImportDistricts.Columns, - f: func(to importDistrictColumns) bob.Mod[Q] { - mods := make(mods.QueryMods[Q], 0, 1) - - { - mods = append(mods, dialect.Join[Q](typ, ImportDistricts.Name().As(to.Alias())).On( - to.Gid.EQ(cols.ImportDistrictGid), - )) - } - - return mods - }, - }, Nuisances: modAs[Q, publicreportNuisanceColumns]{ c: PublicreportNuisances.Columns, f: func(to publicreportNuisanceColumns) bob.Mod[Q] { diff --git a/html/static/js/map-district.js b/html/static/js/map-service-area.js similarity index 90% rename from html/static/js/map-district.js rename to html/static/js/map-service-area.js index 3becf557..503ff6d3 100644 --- a/html/static/js/map-district.js +++ b/html/static/js/map-service-area.js @@ -1,5 +1,5 @@ // A test of maplibre-gl in a custom element -class MapDistrict extends HTMLElement { +class MapServiceArea extends HTMLElement { constructor() { super(); @@ -31,7 +31,7 @@ class MapDistrict extends HTMLElement { const apiKey = this.getAttribute("api-key"); const centroid = JSON.parse(this.getAttribute("centroid")); const csv_file = this.getAttribute("csv-file"); - const district_id = this.getAttribute("district-id"); + const organization_id = this.getAttribute("organization-id"); const lat = Number(this.getAttribute("latitude") || 36.2); const lng = Number(this.getAttribute("longitude") || -119.2); const mapElement = this.shadowRoot.querySelector("#map"); @@ -55,14 +55,12 @@ class MapDistrict extends HTMLElement { this._map.on("load", () => { this._map.addSource("tegola-nidus", { type: "vector", - tiles: [ - `${tegola}maps/district/{z}/{x}/{y}?district_id=${district_id}`, - ], + tiles: [`${tegola}maps/nidus/{z}/{x}/{y}?id=${organization_id}`], }); this._map.addLayer({ - id: "bounds", + id: "service-area", source: "tegola-nidus", - "source-layer": "bounds", + "source-layer": "service-area-bounds", type: "fill", paint: { "fill-opacity": 0.4, @@ -132,4 +130,4 @@ class MapDistrict extends HTMLElement { } } -customElements.define("map-district", MapDistrict); +customElements.define("map-service-area", MapServiceArea); diff --git a/html/template/sync/setting-district.html b/html/template/sync/setting-organization.html similarity index 72% rename from html/template/sync/setting-district.html rename to html/template/sync/setting-organization.html index 60a62d83..184537fc 100644 --- a/html/template/sync/setting-district.html +++ b/html/template/sync/setting-organization.html @@ -6,7 +6,7 @@ type="text/javascript" src="//unpkg.com/maplibre-gl@5.0.1/dist/maplibre-gl.js" > - +