Fill in correct data about the district
This commit is contained in:
parent
a1cc2dbaff
commit
f859e372c6
9 changed files with 244 additions and 66 deletions
|
|
@ -240,6 +240,15 @@ var ImportDistricts = Table[
|
|||
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{
|
||||
|
|
@ -312,11 +321,12 @@ type importDistrictColumns struct {
|
|||
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.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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2624,6 +2624,7 @@ func (f *Factory) FromExistingImportDistrict(m *models.ImportDistrict) *ImportDi
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ type ImportDistrictTemplate struct {
|
|||
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
|
||||
|
|
@ -285,6 +286,9 @@ func (o ImportDistrictTemplate) Build() *models.ImportDistrict {
|
|||
if o.Extent4326 != nil {
|
||||
m.Extent4326 = o.Extent4326()
|
||||
}
|
||||
if o.Area4326SQM != nil {
|
||||
m.Area4326SQM = o.Area4326SQM()
|
||||
}
|
||||
|
||||
o.setModelRels(m)
|
||||
|
||||
|
|
@ -449,6 +453,7 @@ func (m importDistrictMods) RandomizeAllColumns(f *faker.Faker) ImportDistrictMo
|
|||
ImportDistrictMods.RandomGeom4326(f),
|
||||
ImportDistrictMods.RandomCentroid4326(f),
|
||||
ImportDistrictMods.RandomExtent4326(f),
|
||||
ImportDistrictMods.RandomArea4326SQM(f),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1755,6 +1760,59 @@ func (m importDistrictMods) RandomExtent4326NotNull(f *faker.Faker) ImportDistri
|
|||
})
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ type ImportDistrict struct {
|
|||
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:"-" `
|
||||
}
|
||||
|
|
@ -73,7 +74,7 @@ type importDistrictR struct {
|
|||
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",
|
||||
"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"),
|
||||
|
|
@ -101,6 +102,7 @@ func buildImportDistrictColumns(alias string) importDistrictColumns {
|
|||
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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,6 +134,7 @@ type importDistrictColumns struct {
|
|||
Geom4326 psql.Expression
|
||||
Centroid4326 psql.Expression
|
||||
Extent4326 psql.Expression
|
||||
Area4326SQM psql.Expression
|
||||
}
|
||||
|
||||
func (c importDistrictColumns) Alias() string {
|
||||
|
|
@ -944,6 +947,7 @@ type importDistrictWhere[Q psql.Filterable] struct {
|
|||
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] {
|
||||
|
|
@ -977,6 +981,7 @@ func buildImportDistrictWhere[Q psql.Filterable](cols importDistrictColumns) imp
|
|||
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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue