Remove now-extraneous latitude/longitude generated columns

Now that we can pull out the geometry directly into a go object we don't
need these and they complicate our insertions
This commit is contained in:
Eli Ribble 2026-05-07 16:38:42 +00:00
parent 34a136eba5
commit 7a361a330d
No known key found for this signature in database
40 changed files with 426 additions and 464 deletions

View file

@ -18,27 +18,24 @@ import (
"github.com/Gleipnir-Technology/bob/expr"
"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"
)
// Address is an object representing the database table.
type Address struct {
Country string `db:"country" `
Created time.Time `db:"created" `
Location string `db:"location" `
H3cell string `db:"h3cell" `
ID int32 `db:"id,pk" `
Locality string `db:"locality" `
PostalCode string `db:"postal_code" `
Street string `db:"street" `
Unit string `db:"unit" `
Region string `db:"region" `
Number string `db:"number_" `
Gid string `db:"gid" `
LocationLatitude null.Val[float64] `db:"location_latitude,generated" `
LocationLongitude null.Val[float64] `db:"location_longitude,generated" `
Country string `db:"country" `
Created time.Time `db:"created" `
Location string `db:"location" `
H3cell string `db:"h3cell" `
ID int32 `db:"id,pk" `
Locality string `db:"locality" `
PostalCode string `db:"postal_code" `
Street string `db:"street" `
Unit string `db:"unit" `
Region string `db:"region" `
Number string `db:"number_" `
Gid string `db:"gid" `
R addressR `db:"-" `
}
@ -67,43 +64,39 @@ type addressR struct {
func buildAddressColumns(alias string) addressColumns {
return addressColumns{
ColumnsExpr: expr.NewColumnsExpr(
"country", "created", "location", "h3cell", "id", "locality", "postal_code", "street", "unit", "region", "number_", "gid", "location_latitude", "location_longitude",
"country", "created", "location", "h3cell", "id", "locality", "postal_code", "street", "unit", "region", "number_", "gid",
).WithParent("address"),
tableAlias: alias,
Country: psql.Quote(alias, "country"),
Created: psql.Quote(alias, "created"),
Location: psql.Quote(alias, "location"),
H3cell: psql.Quote(alias, "h3cell"),
ID: psql.Quote(alias, "id"),
Locality: psql.Quote(alias, "locality"),
PostalCode: psql.Quote(alias, "postal_code"),
Street: psql.Quote(alias, "street"),
Unit: psql.Quote(alias, "unit"),
Region: psql.Quote(alias, "region"),
Number: psql.Quote(alias, "number_"),
Gid: psql.Quote(alias, "gid"),
LocationLatitude: psql.Quote(alias, "location_latitude"),
LocationLongitude: psql.Quote(alias, "location_longitude"),
tableAlias: alias,
Country: psql.Quote(alias, "country"),
Created: psql.Quote(alias, "created"),
Location: psql.Quote(alias, "location"),
H3cell: psql.Quote(alias, "h3cell"),
ID: psql.Quote(alias, "id"),
Locality: psql.Quote(alias, "locality"),
PostalCode: psql.Quote(alias, "postal_code"),
Street: psql.Quote(alias, "street"),
Unit: psql.Quote(alias, "unit"),
Region: psql.Quote(alias, "region"),
Number: psql.Quote(alias, "number_"),
Gid: psql.Quote(alias, "gid"),
}
}
type addressColumns struct {
expr.ColumnsExpr
tableAlias string
Country psql.Expression
Created psql.Expression
Location psql.Expression
H3cell psql.Expression
ID psql.Expression
Locality psql.Expression
PostalCode psql.Expression
Street psql.Expression
Unit psql.Expression
Region psql.Expression
Number psql.Expression
Gid psql.Expression
LocationLatitude psql.Expression
LocationLongitude psql.Expression
tableAlias string
Country psql.Expression
Created psql.Expression
Location psql.Expression
H3cell psql.Expression
ID psql.Expression
Locality psql.Expression
PostalCode psql.Expression
Street psql.Expression
Unit psql.Expression
Region psql.Expression
Number psql.Expression
Gid psql.Expression
}
func (c addressColumns) Alias() string {
@ -1243,20 +1236,18 @@ func (address0 *Address) AttachSite(ctx context.Context, exec bob.Executor, site
}
type addressWhere[Q psql.Filterable] struct {
Country psql.WhereMod[Q, string]
Created psql.WhereMod[Q, time.Time]
Location psql.WhereMod[Q, string]
H3cell psql.WhereMod[Q, string]
ID psql.WhereMod[Q, int32]
Locality psql.WhereMod[Q, string]
PostalCode psql.WhereMod[Q, string]
Street psql.WhereMod[Q, string]
Unit psql.WhereMod[Q, string]
Region psql.WhereMod[Q, string]
Number psql.WhereMod[Q, string]
Gid psql.WhereMod[Q, string]
LocationLatitude psql.WhereNullMod[Q, float64]
LocationLongitude psql.WhereNullMod[Q, float64]
Country psql.WhereMod[Q, string]
Created psql.WhereMod[Q, time.Time]
Location psql.WhereMod[Q, string]
H3cell psql.WhereMod[Q, string]
ID psql.WhereMod[Q, int32]
Locality psql.WhereMod[Q, string]
PostalCode psql.WhereMod[Q, string]
Street psql.WhereMod[Q, string]
Unit psql.WhereMod[Q, string]
Region psql.WhereMod[Q, string]
Number psql.WhereMod[Q, string]
Gid psql.WhereMod[Q, string]
}
func (addressWhere[Q]) AliasedAs(alias string) addressWhere[Q] {
@ -1265,20 +1256,18 @@ func (addressWhere[Q]) AliasedAs(alias string) addressWhere[Q] {
func buildAddressWhere[Q psql.Filterable](cols addressColumns) addressWhere[Q] {
return addressWhere[Q]{
Country: psql.Where[Q, string](cols.Country),
Created: psql.Where[Q, time.Time](cols.Created),
Location: psql.Where[Q, string](cols.Location),
H3cell: psql.Where[Q, string](cols.H3cell),
ID: psql.Where[Q, int32](cols.ID),
Locality: psql.Where[Q, string](cols.Locality),
PostalCode: psql.Where[Q, string](cols.PostalCode),
Street: psql.Where[Q, string](cols.Street),
Unit: psql.Where[Q, string](cols.Unit),
Region: psql.Where[Q, string](cols.Region),
Number: psql.Where[Q, string](cols.Number),
Gid: psql.Where[Q, string](cols.Gid),
LocationLatitude: psql.WhereNull[Q, float64](cols.LocationLatitude),
LocationLongitude: psql.WhereNull[Q, float64](cols.LocationLongitude),
Country: psql.Where[Q, string](cols.Country),
Created: psql.Where[Q, time.Time](cols.Created),
Location: psql.Where[Q, string](cols.Location),
H3cell: psql.Where[Q, string](cols.H3cell),
ID: psql.Where[Q, int32](cols.ID),
Locality: psql.Where[Q, string](cols.Locality),
PostalCode: psql.Where[Q, string](cols.PostalCode),
Street: psql.Where[Q, string](cols.Street),
Unit: psql.Where[Q, string](cols.Unit),
Region: psql.Where[Q, string](cols.Region),
Number: psql.Where[Q, string](cols.Number),
Gid: psql.Where[Q, string](cols.Gid),
}
}

View file

@ -25,14 +25,12 @@ import (
// Feature is an object representing the database table.
type Feature struct {
Created time.Time `db:"created" `
CreatorID int32 `db:"creator_id" `
ID int32 `db:"id,pk" `
OrganizationID int32 `db:"organization_id" `
SiteID int32 `db:"site_id" `
Location null.Val[string] `db:"location" `
LocationLatitude null.Val[float64] `db:"location_latitude,generated" `
LocationLongitude null.Val[float64] `db:"location_longitude,generated" `
Created time.Time `db:"created" `
CreatorID int32 `db:"creator_id" `
ID int32 `db:"id,pk" `
OrganizationID int32 `db:"organization_id" `
SiteID int32 `db:"site_id" `
Location null.Val[string] `db:"location" `
R featureR `db:"-" `
}
@ -58,31 +56,27 @@ type featureR struct {
func buildFeatureColumns(alias string) featureColumns {
return featureColumns{
ColumnsExpr: expr.NewColumnsExpr(
"created", "creator_id", "id", "organization_id", "site_id", "location", "location_latitude", "location_longitude",
"created", "creator_id", "id", "organization_id", "site_id", "location",
).WithParent("feature"),
tableAlias: alias,
Created: psql.Quote(alias, "created"),
CreatorID: psql.Quote(alias, "creator_id"),
ID: psql.Quote(alias, "id"),
OrganizationID: psql.Quote(alias, "organization_id"),
SiteID: psql.Quote(alias, "site_id"),
Location: psql.Quote(alias, "location"),
LocationLatitude: psql.Quote(alias, "location_latitude"),
LocationLongitude: psql.Quote(alias, "location_longitude"),
tableAlias: alias,
Created: psql.Quote(alias, "created"),
CreatorID: psql.Quote(alias, "creator_id"),
ID: psql.Quote(alias, "id"),
OrganizationID: psql.Quote(alias, "organization_id"),
SiteID: psql.Quote(alias, "site_id"),
Location: psql.Quote(alias, "location"),
}
}
type featureColumns struct {
expr.ColumnsExpr
tableAlias string
Created psql.Expression
CreatorID psql.Expression
ID psql.Expression
OrganizationID psql.Expression
SiteID psql.Expression
Location psql.Expression
LocationLatitude psql.Expression
LocationLongitude psql.Expression
tableAlias string
Created psql.Expression
CreatorID psql.Expression
ID psql.Expression
OrganizationID psql.Expression
SiteID psql.Expression
Location psql.Expression
}
func (c featureColumns) Alias() string {
@ -766,14 +760,12 @@ func (feature0 *Feature) AttachFeaturePool(ctx context.Context, exec bob.Executo
}
type featureWhere[Q psql.Filterable] struct {
Created psql.WhereMod[Q, time.Time]
CreatorID psql.WhereMod[Q, int32]
ID psql.WhereMod[Q, int32]
OrganizationID psql.WhereMod[Q, int32]
SiteID psql.WhereMod[Q, int32]
Location psql.WhereNullMod[Q, string]
LocationLatitude psql.WhereNullMod[Q, float64]
LocationLongitude psql.WhereNullMod[Q, float64]
Created psql.WhereMod[Q, time.Time]
CreatorID psql.WhereMod[Q, int32]
ID psql.WhereMod[Q, int32]
OrganizationID psql.WhereMod[Q, int32]
SiteID psql.WhereMod[Q, int32]
Location psql.WhereNullMod[Q, string]
}
func (featureWhere[Q]) AliasedAs(alias string) featureWhere[Q] {
@ -782,14 +774,12 @@ func (featureWhere[Q]) AliasedAs(alias string) featureWhere[Q] {
func buildFeatureWhere[Q psql.Filterable](cols featureColumns) featureWhere[Q] {
return featureWhere[Q]{
Created: psql.Where[Q, time.Time](cols.Created),
CreatorID: psql.Where[Q, int32](cols.CreatorID),
ID: psql.Where[Q, int32](cols.ID),
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
SiteID: psql.Where[Q, int32](cols.SiteID),
Location: psql.WhereNull[Q, string](cols.Location),
LocationLatitude: psql.WhereNull[Q, float64](cols.LocationLatitude),
LocationLongitude: psql.WhereNull[Q, float64](cols.LocationLongitude),
Created: psql.Where[Q, time.Time](cols.Created),
CreatorID: psql.Where[Q, int32](cols.CreatorID),
ID: psql.Where[Q, int32](cols.ID),
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
SiteID: psql.Where[Q, int32](cols.SiteID),
Location: psql.WhereNull[Q, string](cols.Location),
}
}

View file

@ -47,8 +47,6 @@ type PublicreportReport struct {
Reviewed null.Val[time.Time] `db:"reviewed" `
ReviewerID null.Val[int32] `db:"reviewer_id" `
Status enums.PublicreportReportstatustype `db:"status" `
LocationLatitude null.Val[float64] `db:"location_latitude,generated" `
LocationLongitude null.Val[float64] `db:"location_longitude,generated" `
AddressGid string `db:"address_gid" `
ClientUUID null.Val[uuid.UUID] `db:"client_uuid" `
ReporterPhoneCanSMS bool `db:"reporter_phone_can_sms" `
@ -88,7 +86,7 @@ type publicreportReportR struct {
func buildPublicreportReportColumns(alias string) publicreportReportColumns {
return publicreportReportColumns{
ColumnsExpr: expr.NewColumnsExpr(
"address_raw", "address_id", "created", "location", "h3cell", "id", "latlng_accuracy_type", "latlng_accuracy_value", "map_zoom", "organization_id", "public_id", "reporter_name", "reporter_email", "reporter_phone", "reporter_contact_consent", "report_type", "reviewed", "reviewer_id", "status", "location_latitude", "location_longitude", "address_gid", "client_uuid", "reporter_phone_can_sms",
"address_raw", "address_id", "created", "location", "h3cell", "id", "latlng_accuracy_type", "latlng_accuracy_value", "map_zoom", "organization_id", "public_id", "reporter_name", "reporter_email", "reporter_phone", "reporter_contact_consent", "report_type", "reviewed", "reviewer_id", "status", "address_gid", "client_uuid", "reporter_phone_can_sms",
).WithParent("publicreport.report"),
tableAlias: alias,
AddressRaw: psql.Quote(alias, "address_raw"),
@ -110,8 +108,6 @@ func buildPublicreportReportColumns(alias string) publicreportReportColumns {
Reviewed: psql.Quote(alias, "reviewed"),
ReviewerID: psql.Quote(alias, "reviewer_id"),
Status: psql.Quote(alias, "status"),
LocationLatitude: psql.Quote(alias, "location_latitude"),
LocationLongitude: psql.Quote(alias, "location_longitude"),
AddressGid: psql.Quote(alias, "address_gid"),
ClientUUID: psql.Quote(alias, "client_uuid"),
ReporterPhoneCanSMS: psql.Quote(alias, "reporter_phone_can_sms"),
@ -140,8 +136,6 @@ type publicreportReportColumns struct {
Reviewed psql.Expression
ReviewerID psql.Expression
Status psql.Expression
LocationLatitude psql.Expression
LocationLongitude psql.Expression
AddressGid psql.Expression
ClientUUID psql.Expression
ReporterPhoneCanSMS psql.Expression
@ -2133,8 +2127,6 @@ type publicreportReportWhere[Q psql.Filterable] struct {
Reviewed psql.WhereNullMod[Q, time.Time]
ReviewerID psql.WhereNullMod[Q, int32]
Status psql.WhereMod[Q, enums.PublicreportReportstatustype]
LocationLatitude psql.WhereNullMod[Q, float64]
LocationLongitude psql.WhereNullMod[Q, float64]
AddressGid psql.WhereMod[Q, string]
ClientUUID psql.WhereNullMod[Q, uuid.UUID]
ReporterPhoneCanSMS psql.WhereMod[Q, bool]
@ -2165,8 +2157,6 @@ func buildPublicreportReportWhere[Q psql.Filterable](cols publicreportReportColu
Reviewed: psql.WhereNull[Q, time.Time](cols.Reviewed),
ReviewerID: psql.WhereNull[Q, int32](cols.ReviewerID),
Status: psql.Where[Q, enums.PublicreportReportstatustype](cols.Status),
LocationLatitude: psql.WhereNull[Q, float64](cols.LocationLatitude),
LocationLongitude: psql.WhereNull[Q, float64](cols.LocationLongitude),
AddressGid: psql.Where[Q, string](cols.AddressGid),
ClientUUID: psql.WhereNull[Q, uuid.UUID](cols.ClientUUID),
ReporterPhoneCanSMS: psql.Where[Q, bool](cols.ReporterPhoneCanSMS),

View file

@ -36,7 +36,6 @@ type Signal struct {
Type enums.Signaltype `db:"type_" `
SiteID null.Val[int32] `db:"site_id" `
Location string `db:"location" `
LocationType null.Val[string] `db:"location_type,generated" `
FeaturePoolFeatureID null.Val[int32] `db:"feature_pool_feature_id" `
ReportID null.Val[int32] `db:"report_id" `
@ -66,7 +65,7 @@ type signalR struct {
func buildSignalColumns(alias string) signalColumns {
return signalColumns{
ColumnsExpr: expr.NewColumnsExpr(
"addressed", "addressor", "created", "creator", "id", "organization_id", "species", "type_", "site_id", "location", "location_type", "feature_pool_feature_id", "report_id",
"addressed", "addressor", "created", "creator", "id", "organization_id", "species", "type_", "site_id", "location", "feature_pool_feature_id", "report_id",
).WithParent("signal"),
tableAlias: alias,
Addressed: psql.Quote(alias, "addressed"),
@ -79,7 +78,6 @@ func buildSignalColumns(alias string) signalColumns {
Type: psql.Quote(alias, "type_"),
SiteID: psql.Quote(alias, "site_id"),
Location: psql.Quote(alias, "location"),
LocationType: psql.Quote(alias, "location_type"),
FeaturePoolFeatureID: psql.Quote(alias, "feature_pool_feature_id"),
ReportID: psql.Quote(alias, "report_id"),
}
@ -98,7 +96,6 @@ type signalColumns struct {
Type psql.Expression
SiteID psql.Expression
Location psql.Expression
LocationType psql.Expression
FeaturePoolFeatureID psql.Expression
ReportID psql.Expression
}
@ -1052,7 +1049,6 @@ type signalWhere[Q psql.Filterable] struct {
Type psql.WhereMod[Q, enums.Signaltype]
SiteID psql.WhereNullMod[Q, int32]
Location psql.WhereMod[Q, string]
LocationType psql.WhereNullMod[Q, string]
FeaturePoolFeatureID psql.WhereNullMod[Q, int32]
ReportID psql.WhereNullMod[Q, int32]
}
@ -1073,7 +1069,6 @@ func buildSignalWhere[Q psql.Filterable](cols signalColumns) signalWhere[Q] {
Type: psql.Where[Q, enums.Signaltype](cols.Type),
SiteID: psql.WhereNull[Q, int32](cols.SiteID),
Location: psql.Where[Q, string](cols.Location),
LocationType: psql.WhereNull[Q, string](cols.LocationType),
FeaturePoolFeatureID: psql.WhereNull[Q, int32](cols.FeaturePoolFeatureID),
ReportID: psql.WhereNull[Q, int32](cols.ReportID),
}