Rename address.geom to address.location
It's a better name.
This commit is contained in:
parent
e44bc62325
commit
4494bd97cf
9 changed files with 93 additions and 88 deletions
|
|
@ -33,8 +33,8 @@ var Addresses = Table[
|
||||||
Generated: false,
|
Generated: false,
|
||||||
AutoIncr: false,
|
AutoIncr: false,
|
||||||
},
|
},
|
||||||
Geom: column{
|
Location: column{
|
||||||
Name: "geom",
|
Name: "location",
|
||||||
DBType: "geometry",
|
DBType: "geometry",
|
||||||
Default: "",
|
Default: "",
|
||||||
Comment: "",
|
Comment: "",
|
||||||
|
|
@ -138,7 +138,7 @@ var Addresses = Table[
|
||||||
Name: "idx_address_geom",
|
Name: "idx_address_geom",
|
||||||
Columns: []indexColumn{
|
Columns: []indexColumn{
|
||||||
{
|
{
|
||||||
Name: "geom",
|
Name: "location",
|
||||||
Desc: null.FromCond(false, true),
|
Desc: null.FromCond(false, true),
|
||||||
IsExpression: false,
|
IsExpression: false,
|
||||||
},
|
},
|
||||||
|
|
@ -163,7 +163,7 @@ var Addresses = Table[
|
||||||
type addressColumns struct {
|
type addressColumns struct {
|
||||||
Country column
|
Country column
|
||||||
Created column
|
Created column
|
||||||
Geom column
|
Location column
|
||||||
H3cell column
|
H3cell column
|
||||||
ID column
|
ID column
|
||||||
Locality column
|
Locality column
|
||||||
|
|
@ -176,7 +176,7 @@ type addressColumns struct {
|
||||||
|
|
||||||
func (c addressColumns) AsSlice() []column {
|
func (c addressColumns) AsSlice() []column {
|
||||||
return []column{
|
return []column{
|
||||||
c.Country, c.Created, c.Geom, c.H3cell, c.ID, c.Locality, c.PostalCode, c.Street, c.Unit, c.Region, c.Number,
|
c.Country, c.Created, c.Location, c.H3cell, c.ID, c.Locality, c.PostalCode, c.Street, c.Unit, c.Region, c.Number,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ var ReviewTaskPools = Table[
|
||||||
Schema: "",
|
Schema: "",
|
||||||
Name: "review_task_pool",
|
Name: "review_task_pool",
|
||||||
Columns: reviewTaskPoolColumns{
|
Columns: reviewTaskPoolColumns{
|
||||||
FeaturePool: column{
|
FeaturePoolID: column{
|
||||||
Name: "feature_pool",
|
Name: "feature_pool_id",
|
||||||
DBType: "integer",
|
DBType: "integer",
|
||||||
Default: "",
|
Default: "",
|
||||||
Comment: "",
|
Comment: "",
|
||||||
|
|
@ -80,7 +80,7 @@ var ReviewTaskPools = Table[
|
||||||
ReviewTaskPoolReviewTaskPoolFeaturePoolFkey: foreignKey{
|
ReviewTaskPoolReviewTaskPoolFeaturePoolFkey: foreignKey{
|
||||||
constraint: constraint{
|
constraint: constraint{
|
||||||
Name: "review_task_pool.review_task_pool_feature_pool_fkey",
|
Name: "review_task_pool.review_task_pool_feature_pool_fkey",
|
||||||
Columns: []string{"feature_pool"},
|
Columns: []string{"feature_pool_id"},
|
||||||
Comment: "",
|
Comment: "",
|
||||||
},
|
},
|
||||||
ForeignTable: "feature_pool",
|
ForeignTable: "feature_pool",
|
||||||
|
|
@ -101,15 +101,15 @@ var ReviewTaskPools = Table[
|
||||||
}
|
}
|
||||||
|
|
||||||
type reviewTaskPoolColumns struct {
|
type reviewTaskPoolColumns struct {
|
||||||
FeaturePool column
|
FeaturePoolID column
|
||||||
Location column
|
Location column
|
||||||
Geometry column
|
Geometry column
|
||||||
ReviewTaskID column
|
ReviewTaskID column
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c reviewTaskPoolColumns) AsSlice() []column {
|
func (c reviewTaskPoolColumns) AsSlice() []column {
|
||||||
return []column{
|
return []column{
|
||||||
c.FeaturePool, c.Location, c.Geometry, c.ReviewTaskID,
|
c.FeaturePoolID, c.Location, c.Geometry, c.ReviewTaskID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ CREATE TABLE review_task (
|
||||||
PRIMARY KEY(id)
|
PRIMARY KEY(id)
|
||||||
);
|
);
|
||||||
CREATE TABLE review_task_pool (
|
CREATE TABLE review_task_pool (
|
||||||
feature_pool INTEGER NOT NULL REFERENCES feature_pool(feature_id),
|
feature_pool_id INTEGER NOT NULL REFERENCES feature_pool(feature_id),
|
||||||
location geometry(Point, 4326),
|
location geometry(Point, 4326),
|
||||||
geometry geometry(Polygon, 4326),
|
geometry geometry(Polygon, 4326),
|
||||||
review_task_id INTEGER NOT NULL REFERENCES review_task(id),
|
review_task_id INTEGER NOT NULL REFERENCES review_task(id),
|
||||||
|
|
|
||||||
5
db/migrations/00091_address_location.sql
Normal file
5
db/migrations/00091_address_location.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- +goose Up
|
||||||
|
ALTER TABLE address RENAME COLUMN geom TO location;
|
||||||
|
-- +goose Down
|
||||||
|
ALTER TABLE address RENAME COLUMN location TO geom;
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
type Address struct {
|
type Address struct {
|
||||||
Country enums.Countrytype `db:"country" `
|
Country enums.Countrytype `db:"country" `
|
||||||
Created time.Time `db:"created" `
|
Created time.Time `db:"created" `
|
||||||
Geom string `db:"geom" `
|
Location string `db:"location" `
|
||||||
H3cell string `db:"h3cell" `
|
H3cell string `db:"h3cell" `
|
||||||
ID int32 `db:"id,pk" `
|
ID int32 `db:"id,pk" `
|
||||||
Locality string `db:"locality" `
|
Locality string `db:"locality" `
|
||||||
|
|
@ -59,12 +59,12 @@ type addressR struct {
|
||||||
func buildAddressColumns(alias string) addressColumns {
|
func buildAddressColumns(alias string) addressColumns {
|
||||||
return addressColumns{
|
return addressColumns{
|
||||||
ColumnsExpr: expr.NewColumnsExpr(
|
ColumnsExpr: expr.NewColumnsExpr(
|
||||||
"country", "created", "geom", "h3cell", "id", "locality", "postal_code", "street", "unit", "region", "number_",
|
"country", "created", "location", "h3cell", "id", "locality", "postal_code", "street", "unit", "region", "number_",
|
||||||
).WithParent("address"),
|
).WithParent("address"),
|
||||||
tableAlias: alias,
|
tableAlias: alias,
|
||||||
Country: psql.Quote(alias, "country"),
|
Country: psql.Quote(alias, "country"),
|
||||||
Created: psql.Quote(alias, "created"),
|
Created: psql.Quote(alias, "created"),
|
||||||
Geom: psql.Quote(alias, "geom"),
|
Location: psql.Quote(alias, "location"),
|
||||||
H3cell: psql.Quote(alias, "h3cell"),
|
H3cell: psql.Quote(alias, "h3cell"),
|
||||||
ID: psql.Quote(alias, "id"),
|
ID: psql.Quote(alias, "id"),
|
||||||
Locality: psql.Quote(alias, "locality"),
|
Locality: psql.Quote(alias, "locality"),
|
||||||
|
|
@ -81,7 +81,7 @@ type addressColumns struct {
|
||||||
tableAlias string
|
tableAlias string
|
||||||
Country psql.Expression
|
Country psql.Expression
|
||||||
Created psql.Expression
|
Created psql.Expression
|
||||||
Geom psql.Expression
|
Location psql.Expression
|
||||||
H3cell psql.Expression
|
H3cell psql.Expression
|
||||||
ID psql.Expression
|
ID psql.Expression
|
||||||
Locality psql.Expression
|
Locality psql.Expression
|
||||||
|
|
@ -106,7 +106,7 @@ func (addressColumns) AliasedAs(alias string) addressColumns {
|
||||||
type AddressSetter struct {
|
type AddressSetter struct {
|
||||||
Country omit.Val[enums.Countrytype] `db:"country" `
|
Country omit.Val[enums.Countrytype] `db:"country" `
|
||||||
Created omit.Val[time.Time] `db:"created" `
|
Created omit.Val[time.Time] `db:"created" `
|
||||||
Geom omit.Val[string] `db:"geom" `
|
Location omit.Val[string] `db:"location" `
|
||||||
H3cell omit.Val[string] `db:"h3cell" `
|
H3cell omit.Val[string] `db:"h3cell" `
|
||||||
ID omit.Val[int32] `db:"id,pk" `
|
ID omit.Val[int32] `db:"id,pk" `
|
||||||
Locality omit.Val[string] `db:"locality" `
|
Locality omit.Val[string] `db:"locality" `
|
||||||
|
|
@ -125,8 +125,8 @@ func (s AddressSetter) SetColumns() []string {
|
||||||
if s.Created.IsValue() {
|
if s.Created.IsValue() {
|
||||||
vals = append(vals, "created")
|
vals = append(vals, "created")
|
||||||
}
|
}
|
||||||
if s.Geom.IsValue() {
|
if s.Location.IsValue() {
|
||||||
vals = append(vals, "geom")
|
vals = append(vals, "location")
|
||||||
}
|
}
|
||||||
if s.H3cell.IsValue() {
|
if s.H3cell.IsValue() {
|
||||||
vals = append(vals, "h3cell")
|
vals = append(vals, "h3cell")
|
||||||
|
|
@ -162,8 +162,8 @@ func (s AddressSetter) Overwrite(t *Address) {
|
||||||
if s.Created.IsValue() {
|
if s.Created.IsValue() {
|
||||||
t.Created = s.Created.MustGet()
|
t.Created = s.Created.MustGet()
|
||||||
}
|
}
|
||||||
if s.Geom.IsValue() {
|
if s.Location.IsValue() {
|
||||||
t.Geom = s.Geom.MustGet()
|
t.Location = s.Location.MustGet()
|
||||||
}
|
}
|
||||||
if s.H3cell.IsValue() {
|
if s.H3cell.IsValue() {
|
||||||
t.H3cell = s.H3cell.MustGet()
|
t.H3cell = s.H3cell.MustGet()
|
||||||
|
|
@ -210,8 +210,8 @@ func (s *AddressSetter) Apply(q *dialect.InsertQuery) {
|
||||||
vals[1] = psql.Raw("DEFAULT")
|
vals[1] = psql.Raw("DEFAULT")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Geom.IsValue() {
|
if s.Location.IsValue() {
|
||||||
vals[2] = psql.Arg(s.Geom.MustGet())
|
vals[2] = psql.Arg(s.Location.MustGet())
|
||||||
} else {
|
} else {
|
||||||
vals[2] = psql.Raw("DEFAULT")
|
vals[2] = psql.Raw("DEFAULT")
|
||||||
}
|
}
|
||||||
|
|
@ -289,10 +289,10 @@ func (s AddressSetter) Expressions(prefix ...string) []bob.Expression {
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Geom.IsValue() {
|
if s.Location.IsValue() {
|
||||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||||
psql.Quote(append(prefix, "geom")...),
|
psql.Quote(append(prefix, "location")...),
|
||||||
psql.Arg(s.Geom),
|
psql.Arg(s.Location),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -843,7 +843,7 @@ func (address0 *Address) AttachSite(ctx context.Context, exec bob.Executor, site
|
||||||
type addressWhere[Q psql.Filterable] struct {
|
type addressWhere[Q psql.Filterable] struct {
|
||||||
Country psql.WhereMod[Q, enums.Countrytype]
|
Country psql.WhereMod[Q, enums.Countrytype]
|
||||||
Created psql.WhereMod[Q, time.Time]
|
Created psql.WhereMod[Q, time.Time]
|
||||||
Geom psql.WhereMod[Q, string]
|
Location psql.WhereMod[Q, string]
|
||||||
H3cell psql.WhereMod[Q, string]
|
H3cell psql.WhereMod[Q, string]
|
||||||
ID psql.WhereMod[Q, int32]
|
ID psql.WhereMod[Q, int32]
|
||||||
Locality psql.WhereMod[Q, string]
|
Locality psql.WhereMod[Q, string]
|
||||||
|
|
@ -862,7 +862,7 @@ func buildAddressWhere[Q psql.Filterable](cols addressColumns) addressWhere[Q] {
|
||||||
return addressWhere[Q]{
|
return addressWhere[Q]{
|
||||||
Country: psql.Where[Q, enums.Countrytype](cols.Country),
|
Country: psql.Where[Q, enums.Countrytype](cols.Country),
|
||||||
Created: psql.Where[Q, time.Time](cols.Created),
|
Created: psql.Where[Q, time.Time](cols.Created),
|
||||||
Geom: psql.Where[Q, string](cols.Geom),
|
Location: psql.Where[Q, string](cols.Location),
|
||||||
H3cell: psql.Where[Q, string](cols.H3cell),
|
H3cell: psql.Where[Q, string](cols.H3cell),
|
||||||
ID: psql.Where[Q, int32](cols.ID),
|
ID: psql.Where[Q, int32](cols.ID),
|
||||||
Locality: psql.Where[Q, string](cols.Locality),
|
Locality: psql.Where[Q, string](cols.Locality),
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ func (os FeaturePoolSlice) Feature(mods ...bob.Mod[*dialect.SelectQuery]) Featur
|
||||||
// ReviewTaskPools starts a query for related objects on review_task_pool
|
// ReviewTaskPools starts a query for related objects on review_task_pool
|
||||||
func (o *FeaturePool) ReviewTaskPools(mods ...bob.Mod[*dialect.SelectQuery]) ReviewTaskPoolsQuery {
|
func (o *FeaturePool) ReviewTaskPools(mods ...bob.Mod[*dialect.SelectQuery]) ReviewTaskPoolsQuery {
|
||||||
return ReviewTaskPools.Query(append(mods,
|
return ReviewTaskPools.Query(append(mods,
|
||||||
sm.Where(ReviewTaskPools.Columns.FeaturePool.EQ(psql.Arg(o.FeatureID))),
|
sm.Where(ReviewTaskPools.Columns.FeaturePoolID.EQ(psql.Arg(o.FeatureID))),
|
||||||
)...)
|
)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -461,7 +461,7 @@ func (os FeaturePoolSlice) ReviewTaskPools(mods ...bob.Mod[*dialect.SelectQuery]
|
||||||
))
|
))
|
||||||
|
|
||||||
return ReviewTaskPools.Query(append(mods,
|
return ReviewTaskPools.Query(append(mods,
|
||||||
sm.Where(psql.Group(ReviewTaskPools.Columns.FeaturePool).OP("IN", PKArgExpr)),
|
sm.Where(psql.Group(ReviewTaskPools.Columns.FeaturePoolID).OP("IN", PKArgExpr)),
|
||||||
)...)
|
)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -515,7 +515,7 @@ func (featurePool0 *FeaturePool) AttachFeature(ctx context.Context, exec bob.Exe
|
||||||
|
|
||||||
func insertFeaturePoolReviewTaskPools0(ctx context.Context, exec bob.Executor, reviewTaskPools1 []*ReviewTaskPoolSetter, featurePool0 *FeaturePool) (ReviewTaskPoolSlice, error) {
|
func insertFeaturePoolReviewTaskPools0(ctx context.Context, exec bob.Executor, reviewTaskPools1 []*ReviewTaskPoolSetter, featurePool0 *FeaturePool) (ReviewTaskPoolSlice, error) {
|
||||||
for i := range reviewTaskPools1 {
|
for i := range reviewTaskPools1 {
|
||||||
reviewTaskPools1[i].FeaturePool = omit.From(featurePool0.FeatureID)
|
reviewTaskPools1[i].FeaturePoolID = omit.From(featurePool0.FeatureID)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err := ReviewTaskPools.Insert(bob.ToMods(reviewTaskPools1...)).All(ctx, exec)
|
ret, err := ReviewTaskPools.Insert(bob.ToMods(reviewTaskPools1...)).All(ctx, exec)
|
||||||
|
|
@ -528,7 +528,7 @@ func insertFeaturePoolReviewTaskPools0(ctx context.Context, exec bob.Executor, r
|
||||||
|
|
||||||
func attachFeaturePoolReviewTaskPools0(ctx context.Context, exec bob.Executor, count int, reviewTaskPools1 ReviewTaskPoolSlice, featurePool0 *FeaturePool) (ReviewTaskPoolSlice, error) {
|
func attachFeaturePoolReviewTaskPools0(ctx context.Context, exec bob.Executor, count int, reviewTaskPools1 ReviewTaskPoolSlice, featurePool0 *FeaturePool) (ReviewTaskPoolSlice, error) {
|
||||||
setter := &ReviewTaskPoolSetter{
|
setter := &ReviewTaskPoolSetter{
|
||||||
FeaturePool: omit.From(featurePool0.FeatureID),
|
FeaturePoolID: omit.From(featurePool0.FeatureID),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := reviewTaskPools1.UpdateAll(ctx, exec, *setter)
|
err := reviewTaskPools1.UpdateAll(ctx, exec, *setter)
|
||||||
|
|
@ -789,7 +789,7 @@ func (os FeaturePoolSlice) LoadReviewTaskPools(ctx context.Context, exec bob.Exe
|
||||||
|
|
||||||
for _, rel := range reviewTaskPools {
|
for _, rel := range reviewTaskPools {
|
||||||
|
|
||||||
if !(o.FeatureID == rel.FeaturePool) {
|
if !(o.FeatureID == rel.FeaturePoolID) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ import (
|
||||||
|
|
||||||
// ReviewTaskPool is an object representing the database table.
|
// ReviewTaskPool is an object representing the database table.
|
||||||
type ReviewTaskPool struct {
|
type ReviewTaskPool struct {
|
||||||
FeaturePool int32 `db:"feature_pool" `
|
FeaturePoolID int32 `db:"feature_pool_id" `
|
||||||
Location null.Val[string] `db:"location" `
|
Location null.Val[string] `db:"location" `
|
||||||
Geometry null.Val[string] `db:"geometry" `
|
Geometry null.Val[string] `db:"geometry" `
|
||||||
ReviewTaskID int32 `db:"review_task_id,pk" `
|
ReviewTaskID int32 `db:"review_task_id,pk" `
|
||||||
|
|
||||||
R reviewTaskPoolR `db:"-" `
|
R reviewTaskPoolR `db:"-" `
|
||||||
}
|
}
|
||||||
|
|
@ -51,23 +51,23 @@ type reviewTaskPoolR struct {
|
||||||
func buildReviewTaskPoolColumns(alias string) reviewTaskPoolColumns {
|
func buildReviewTaskPoolColumns(alias string) reviewTaskPoolColumns {
|
||||||
return reviewTaskPoolColumns{
|
return reviewTaskPoolColumns{
|
||||||
ColumnsExpr: expr.NewColumnsExpr(
|
ColumnsExpr: expr.NewColumnsExpr(
|
||||||
"feature_pool", "location", "geometry", "review_task_id",
|
"feature_pool_id", "location", "geometry", "review_task_id",
|
||||||
).WithParent("review_task_pool"),
|
).WithParent("review_task_pool"),
|
||||||
tableAlias: alias,
|
tableAlias: alias,
|
||||||
FeaturePool: psql.Quote(alias, "feature_pool"),
|
FeaturePoolID: psql.Quote(alias, "feature_pool_id"),
|
||||||
Location: psql.Quote(alias, "location"),
|
Location: psql.Quote(alias, "location"),
|
||||||
Geometry: psql.Quote(alias, "geometry"),
|
Geometry: psql.Quote(alias, "geometry"),
|
||||||
ReviewTaskID: psql.Quote(alias, "review_task_id"),
|
ReviewTaskID: psql.Quote(alias, "review_task_id"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type reviewTaskPoolColumns struct {
|
type reviewTaskPoolColumns struct {
|
||||||
expr.ColumnsExpr
|
expr.ColumnsExpr
|
||||||
tableAlias string
|
tableAlias string
|
||||||
FeaturePool psql.Expression
|
FeaturePoolID psql.Expression
|
||||||
Location psql.Expression
|
Location psql.Expression
|
||||||
Geometry psql.Expression
|
Geometry psql.Expression
|
||||||
ReviewTaskID psql.Expression
|
ReviewTaskID psql.Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c reviewTaskPoolColumns) Alias() string {
|
func (c reviewTaskPoolColumns) Alias() string {
|
||||||
|
|
@ -82,16 +82,16 @@ func (reviewTaskPoolColumns) AliasedAs(alias string) reviewTaskPoolColumns {
|
||||||
// All values are optional, and do not have to be set
|
// All values are optional, and do not have to be set
|
||||||
// Generated columns are not included
|
// Generated columns are not included
|
||||||
type ReviewTaskPoolSetter struct {
|
type ReviewTaskPoolSetter struct {
|
||||||
FeaturePool omit.Val[int32] `db:"feature_pool" `
|
FeaturePoolID omit.Val[int32] `db:"feature_pool_id" `
|
||||||
Location omitnull.Val[string] `db:"location" `
|
Location omitnull.Val[string] `db:"location" `
|
||||||
Geometry omitnull.Val[string] `db:"geometry" `
|
Geometry omitnull.Val[string] `db:"geometry" `
|
||||||
ReviewTaskID omit.Val[int32] `db:"review_task_id,pk" `
|
ReviewTaskID omit.Val[int32] `db:"review_task_id,pk" `
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s ReviewTaskPoolSetter) SetColumns() []string {
|
func (s ReviewTaskPoolSetter) SetColumns() []string {
|
||||||
vals := make([]string, 0, 4)
|
vals := make([]string, 0, 4)
|
||||||
if s.FeaturePool.IsValue() {
|
if s.FeaturePoolID.IsValue() {
|
||||||
vals = append(vals, "feature_pool")
|
vals = append(vals, "feature_pool_id")
|
||||||
}
|
}
|
||||||
if !s.Location.IsUnset() {
|
if !s.Location.IsUnset() {
|
||||||
vals = append(vals, "location")
|
vals = append(vals, "location")
|
||||||
|
|
@ -106,8 +106,8 @@ func (s ReviewTaskPoolSetter) SetColumns() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s ReviewTaskPoolSetter) Overwrite(t *ReviewTaskPool) {
|
func (s ReviewTaskPoolSetter) Overwrite(t *ReviewTaskPool) {
|
||||||
if s.FeaturePool.IsValue() {
|
if s.FeaturePoolID.IsValue() {
|
||||||
t.FeaturePool = s.FeaturePool.MustGet()
|
t.FeaturePoolID = s.FeaturePoolID.MustGet()
|
||||||
}
|
}
|
||||||
if !s.Location.IsUnset() {
|
if !s.Location.IsUnset() {
|
||||||
t.Location = s.Location.MustGetNull()
|
t.Location = s.Location.MustGetNull()
|
||||||
|
|
@ -127,8 +127,8 @@ func (s *ReviewTaskPoolSetter) Apply(q *dialect.InsertQuery) {
|
||||||
|
|
||||||
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||||
vals := make([]bob.Expression, 4)
|
vals := make([]bob.Expression, 4)
|
||||||
if s.FeaturePool.IsValue() {
|
if s.FeaturePoolID.IsValue() {
|
||||||
vals[0] = psql.Arg(s.FeaturePool.MustGet())
|
vals[0] = psql.Arg(s.FeaturePoolID.MustGet())
|
||||||
} else {
|
} else {
|
||||||
vals[0] = psql.Raw("DEFAULT")
|
vals[0] = psql.Raw("DEFAULT")
|
||||||
}
|
}
|
||||||
|
|
@ -162,10 +162,10 @@ func (s ReviewTaskPoolSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
||||||
func (s ReviewTaskPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
func (s ReviewTaskPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
||||||
exprs := make([]bob.Expression, 0, 4)
|
exprs := make([]bob.Expression, 0, 4)
|
||||||
|
|
||||||
if s.FeaturePool.IsValue() {
|
if s.FeaturePoolID.IsValue() {
|
||||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||||
psql.Quote(append(prefix, "feature_pool")...),
|
psql.Quote(append(prefix, "feature_pool_id")...),
|
||||||
psql.Arg(s.FeaturePool),
|
psql.Arg(s.FeaturePoolID),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -417,22 +417,22 @@ func (o ReviewTaskPoolSlice) ReloadAll(ctx context.Context, exec bob.Executor) e
|
||||||
}
|
}
|
||||||
|
|
||||||
// FeaturePool starts a query for related objects on feature_pool
|
// FeaturePool starts a query for related objects on feature_pool
|
||||||
func (o *ReviewTaskPool) RelatedFeaturePool(mods ...bob.Mod[*dialect.SelectQuery]) FeaturePoolsQuery {
|
func (o *ReviewTaskPool) FeaturePool(mods ...bob.Mod[*dialect.SelectQuery]) FeaturePoolsQuery {
|
||||||
return FeaturePools.Query(append(mods,
|
return FeaturePools.Query(append(mods,
|
||||||
sm.Where(FeaturePools.Columns.FeatureID.EQ(psql.Arg(o.FeaturePool))),
|
sm.Where(FeaturePools.Columns.FeatureID.EQ(psql.Arg(o.FeaturePoolID))),
|
||||||
)...)
|
)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (os ReviewTaskPoolSlice) RelatedFeaturePool(mods ...bob.Mod[*dialect.SelectQuery]) FeaturePoolsQuery {
|
func (os ReviewTaskPoolSlice) FeaturePool(mods ...bob.Mod[*dialect.SelectQuery]) FeaturePoolsQuery {
|
||||||
pkFeaturePool := make(pgtypes.Array[int32], 0, len(os))
|
pkFeaturePoolID := make(pgtypes.Array[int32], 0, len(os))
|
||||||
for _, o := range os {
|
for _, o := range os {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pkFeaturePool = append(pkFeaturePool, o.FeaturePool)
|
pkFeaturePoolID = append(pkFeaturePoolID, o.FeaturePoolID)
|
||||||
}
|
}
|
||||||
PKArgExpr := psql.Select(sm.Columns(
|
PKArgExpr := psql.Select(sm.Columns(
|
||||||
psql.F("unnest", psql.Cast(psql.Arg(pkFeaturePool), "integer[]")),
|
psql.F("unnest", psql.Cast(psql.Arg(pkFeaturePoolID), "integer[]")),
|
||||||
))
|
))
|
||||||
|
|
||||||
return FeaturePools.Query(append(mods,
|
return FeaturePools.Query(append(mods,
|
||||||
|
|
@ -466,7 +466,7 @@ func (os ReviewTaskPoolSlice) ReviewTask(mods ...bob.Mod[*dialect.SelectQuery])
|
||||||
|
|
||||||
func attachReviewTaskPoolFeaturePool0(ctx context.Context, exec bob.Executor, count int, reviewTaskPool0 *ReviewTaskPool, featurePool1 *FeaturePool) (*ReviewTaskPool, error) {
|
func attachReviewTaskPoolFeaturePool0(ctx context.Context, exec bob.Executor, count int, reviewTaskPool0 *ReviewTaskPool, featurePool1 *FeaturePool) (*ReviewTaskPool, error) {
|
||||||
setter := &ReviewTaskPoolSetter{
|
setter := &ReviewTaskPoolSetter{
|
||||||
FeaturePool: omit.From(featurePool1.FeatureID),
|
FeaturePoolID: omit.From(featurePool1.FeatureID),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := reviewTaskPool0.Update(ctx, exec, setter)
|
err := reviewTaskPool0.Update(ctx, exec, setter)
|
||||||
|
|
@ -561,10 +561,10 @@ func (reviewTaskPool0 *ReviewTaskPool) AttachReviewTask(ctx context.Context, exe
|
||||||
}
|
}
|
||||||
|
|
||||||
type reviewTaskPoolWhere[Q psql.Filterable] struct {
|
type reviewTaskPoolWhere[Q psql.Filterable] struct {
|
||||||
FeaturePool psql.WhereMod[Q, int32]
|
FeaturePoolID psql.WhereMod[Q, int32]
|
||||||
Location psql.WhereNullMod[Q, string]
|
Location psql.WhereNullMod[Q, string]
|
||||||
Geometry psql.WhereNullMod[Q, string]
|
Geometry psql.WhereNullMod[Q, string]
|
||||||
ReviewTaskID psql.WhereMod[Q, int32]
|
ReviewTaskID psql.WhereMod[Q, int32]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (reviewTaskPoolWhere[Q]) AliasedAs(alias string) reviewTaskPoolWhere[Q] {
|
func (reviewTaskPoolWhere[Q]) AliasedAs(alias string) reviewTaskPoolWhere[Q] {
|
||||||
|
|
@ -573,10 +573,10 @@ func (reviewTaskPoolWhere[Q]) AliasedAs(alias string) reviewTaskPoolWhere[Q] {
|
||||||
|
|
||||||
func buildReviewTaskPoolWhere[Q psql.Filterable](cols reviewTaskPoolColumns) reviewTaskPoolWhere[Q] {
|
func buildReviewTaskPoolWhere[Q psql.Filterable](cols reviewTaskPoolColumns) reviewTaskPoolWhere[Q] {
|
||||||
return reviewTaskPoolWhere[Q]{
|
return reviewTaskPoolWhere[Q]{
|
||||||
FeaturePool: psql.Where[Q, int32](cols.FeaturePool),
|
FeaturePoolID: psql.Where[Q, int32](cols.FeaturePoolID),
|
||||||
Location: psql.WhereNull[Q, string](cols.Location),
|
Location: psql.WhereNull[Q, string](cols.Location),
|
||||||
Geometry: psql.WhereNull[Q, string](cols.Geometry),
|
Geometry: psql.WhereNull[Q, string](cols.Geometry),
|
||||||
ReviewTaskID: psql.Where[Q, int32](cols.ReviewTaskID),
|
ReviewTaskID: psql.Where[Q, int32](cols.ReviewTaskID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -629,7 +629,7 @@ func buildReviewTaskPoolPreloader() reviewTaskPoolPreloader {
|
||||||
{
|
{
|
||||||
From: ReviewTaskPools,
|
From: ReviewTaskPools,
|
||||||
To: FeaturePools,
|
To: FeaturePools,
|
||||||
FromColumns: []string{"feature_pool"},
|
FromColumns: []string{"feature_pool_id"},
|
||||||
ToColumns: []string{"feature_id"},
|
ToColumns: []string{"feature_id"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -689,7 +689,7 @@ func (o *ReviewTaskPool) LoadFeaturePool(ctx context.Context, exec bob.Executor,
|
||||||
// Reset the relationship
|
// Reset the relationship
|
||||||
o.R.FeaturePool = nil
|
o.R.FeaturePool = nil
|
||||||
|
|
||||||
related, err := o.RelatedFeaturePool(mods...).One(ctx, exec)
|
related, err := o.FeaturePool(mods...).One(ctx, exec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -706,7 +706,7 @@ func (os ReviewTaskPoolSlice) LoadFeaturePool(ctx context.Context, exec bob.Exec
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
featurePools, err := os.RelatedFeaturePool(mods...).All(ctx, exec)
|
featurePools, err := os.FeaturePool(mods...).All(ctx, exec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -718,7 +718,7 @@ func (os ReviewTaskPoolSlice) LoadFeaturePool(ctx context.Context, exec bob.Exec
|
||||||
|
|
||||||
for _, rel := range featurePools {
|
for _, rel := range featurePools {
|
||||||
|
|
||||||
if !(o.FeaturePool == rel.FeatureID) {
|
if !(o.FeaturePoolID == rel.FeatureID) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,10 +149,10 @@ func JobCommit(ctx context.Context, file_id int32) error {
|
||||||
return fmt.Errorf("insert review task: %w", err)
|
return fmt.Errorf("insert review task: %w", err)
|
||||||
}
|
}
|
||||||
_, err = models.ReviewTaskPools.Insert(&models.ReviewTaskPoolSetter{
|
_, err = models.ReviewTaskPools.Insert(&models.ReviewTaskPoolSetter{
|
||||||
FeaturePool: omit.From(feature.ID),
|
FeaturePoolID: omit.From(feature.ID),
|
||||||
Location: omitnull.FromPtr[string](nil),
|
Location: omitnull.FromPtr[string](nil),
|
||||||
Geometry: omitnull.FromPtr[string](nil),
|
Geometry: omitnull.FromPtr[string](nil),
|
||||||
ReviewTaskID: omit.From(review_task.ID),
|
ReviewTaskID: omit.From(review_task.ID),
|
||||||
}).One(ctx, txn)
|
}).One(ctx, txn)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,10 @@ func EnsureAddress(ctx context.Context, txn bob.Tx, org *models.Organization, a
|
||||||
return &models.Address{
|
return &models.Address{
|
||||||
Country: geo.Address.Country,
|
Country: geo.Address.Country,
|
||||||
Created: created,
|
Created: created,
|
||||||
Geom: "",
|
|
||||||
H3cell: "",
|
H3cell: "",
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
Locality: geo.Address.Locality,
|
Locality: geo.Address.Locality,
|
||||||
|
Location: "",
|
||||||
PostalCode: geo.Address.PostalCode,
|
PostalCode: geo.Address.PostalCode,
|
||||||
Street: geo.Address.Street,
|
Street: geo.Address.Street,
|
||||||
Unit: geo.Address.Unit,
|
Unit: geo.Address.Unit,
|
||||||
|
|
@ -173,7 +173,7 @@ func Geocode(ctx context.Context, org *models.Organization, a Address) (GeocodeR
|
||||||
// Get the parcel for a given address, if one can be found
|
// Get the parcel for a given address, if one can be found
|
||||||
func GetParcel(ctx context.Context, txn bob.Tx, a *models.Address) (*models.Parcel, error) {
|
func GetParcel(ctx context.Context, txn bob.Tx, a *models.Address) (*models.Parcel, error) {
|
||||||
result, err := models.Parcels.Query(
|
result, err := models.Parcels.Query(
|
||||||
sm.InnerJoin("address").On(psql.F("ST_Contains", psql.Raw("parcel.geometry"), psql.Raw("address.geom"))),
|
sm.InnerJoin("address").On(psql.F("ST_Contains", psql.Raw("parcel.geometry"), psql.Raw("address.location"))),
|
||||||
models.SelectWhere.Addresses.ID.EQ(a.ID),
|
models.SelectWhere.Addresses.ID.EQ(a.ID),
|
||||||
).One(ctx, txn)
|
).One(ctx, txn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue