Make fieldseeker tables key on globalid, version
This is because the objectid is not unique between organizations.
This commit is contained in:
parent
d02d34cbaa
commit
e18ce6a09e
110 changed files with 10602 additions and 486 deletions
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
// FieldseekerPolygonlocation is an object representing the database table.
|
||||
type FieldseekerPolygonlocation struct {
|
||||
Objectid int64 `db:"objectid,pk" `
|
||||
Objectid int64 `db:"objectid" `
|
||||
// Original attribute from ArcGIS API is NAME
|
||||
Name null.Val[string] `db:"name" `
|
||||
// Original attribute from ArcGIS API is ZONE
|
||||
|
|
@ -63,7 +63,7 @@ type FieldseekerPolygonlocation struct {
|
|||
// Original attribute from ArcGIS API is LOCATIONNUMBER
|
||||
Locationnumber null.Val[int32] `db:"locationnumber" `
|
||||
// Original attribute from ArcGIS API is GlobalID
|
||||
Globalid uuid.UUID `db:"globalid" `
|
||||
Globalid uuid.UUID `db:"globalid,pk" `
|
||||
// Original attribute from ArcGIS API is LASTINSPECTDATE
|
||||
Lastinspectdate null.Val[time.Time] `db:"lastinspectdate" `
|
||||
// Original attribute from ArcGIS API is LASTINSPECTBREEDING
|
||||
|
|
@ -253,7 +253,7 @@ func (fieldseekerPolygonlocationColumns) AliasedAs(alias string) fieldseekerPoly
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type FieldseekerPolygonlocationSetter struct {
|
||||
Objectid omit.Val[int64] `db:"objectid,pk" `
|
||||
Objectid omit.Val[int64] `db:"objectid" `
|
||||
Name omitnull.Val[string] `db:"name" `
|
||||
Zone omitnull.Val[string] `db:"zone" `
|
||||
Habitat omitnull.Val[string] `db:"habitat" `
|
||||
|
|
@ -270,7 +270,7 @@ type FieldseekerPolygonlocationSetter struct {
|
|||
Larvinspectinterval omitnull.Val[int16] `db:"larvinspectinterval" `
|
||||
Zone2 omitnull.Val[string] `db:"zone2" `
|
||||
Locationnumber omitnull.Val[int32] `db:"locationnumber" `
|
||||
Globalid omit.Val[uuid.UUID] `db:"globalid" `
|
||||
Globalid omit.Val[uuid.UUID] `db:"globalid,pk" `
|
||||
Lastinspectdate omitnull.Val[time.Time] `db:"lastinspectdate" `
|
||||
Lastinspectbreeding omitnull.Val[string] `db:"lastinspectbreeding" `
|
||||
Lastinspectavglarvae omitnull.Val[float64] `db:"lastinspectavglarvae" `
|
||||
|
|
@ -1206,25 +1206,25 @@ func (s FieldseekerPolygonlocationSetter) Expressions(prefix ...string) []bob.Ex
|
|||
|
||||
// FindFieldseekerPolygonlocation retrieves a single record by primary key
|
||||
// If cols is empty Find will return all columns.
|
||||
func FindFieldseekerPolygonlocation(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerPolygonlocation, error) {
|
||||
func FindFieldseekerPolygonlocation(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32, cols ...string) (*FieldseekerPolygonlocation, error) {
|
||||
if len(cols) == 0 {
|
||||
return FieldseekerPolygonlocations.Query(
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(VersionPK))),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
return FieldseekerPolygonlocations.Query(
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(VersionPK))),
|
||||
sm.Columns(FieldseekerPolygonlocations.Columns.Only(cols...)),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
// FieldseekerPolygonlocationExists checks the presence of a single record by primary key
|
||||
func FieldseekerPolygonlocationExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) {
|
||||
func FieldseekerPolygonlocationExists(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32) (bool, error) {
|
||||
return FieldseekerPolygonlocations.Query(
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(VersionPK))),
|
||||
).Exists(ctx, exec)
|
||||
}
|
||||
|
|
@ -1250,13 +1250,13 @@ func (o *FieldseekerPolygonlocation) AfterQueryHook(ctx context.Context, exec bo
|
|||
// primaryKeyVals returns the primary key values of the FieldseekerPolygonlocation
|
||||
func (o *FieldseekerPolygonlocation) primaryKeyVals() bob.Expression {
|
||||
return psql.ArgGroup(
|
||||
o.Objectid,
|
||||
o.Globalid,
|
||||
o.Version,
|
||||
)
|
||||
}
|
||||
|
||||
func (o *FieldseekerPolygonlocation) pkEQ() dialect.Expression {
|
||||
return psql.Group(psql.Quote("fieldseeker.polygonlocation", "objectid"), psql.Quote("fieldseeker.polygonlocation", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
return psql.Group(psql.Quote("fieldseeker.polygonlocation", "globalid"), psql.Quote("fieldseeker.polygonlocation", "version")).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)
|
||||
}))
|
||||
}
|
||||
|
|
@ -1283,7 +1283,7 @@ func (o *FieldseekerPolygonlocation) Delete(ctx context.Context, exec bob.Execut
|
|||
// Reload refreshes the FieldseekerPolygonlocation using the executor
|
||||
func (o *FieldseekerPolygonlocation) Reload(ctx context.Context, exec bob.Executor) error {
|
||||
o2, err := FieldseekerPolygonlocations.Query(
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Objectid.EQ(psql.Arg(o.Objectid))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Globalid.EQ(psql.Arg(o.Globalid))),
|
||||
sm.Where(FieldseekerPolygonlocations.Columns.Version.EQ(psql.Arg(o.Version))),
|
||||
).One(ctx, exec)
|
||||
if err != nil {
|
||||
|
|
@ -1318,7 +1318,7 @@ func (o FieldseekerPolygonlocationSlice) pkIN() dialect.Expression {
|
|||
return psql.Raw("NULL")
|
||||
}
|
||||
|
||||
return psql.Group(psql.Quote("fieldseeker.polygonlocation", "objectid"), psql.Quote("fieldseeker.polygonlocation", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
return psql.Group(psql.Quote("fieldseeker.polygonlocation", "globalid"), psql.Quote("fieldseeker.polygonlocation", "version")).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()
|
||||
|
|
@ -1333,7 +1333,7 @@ func (o FieldseekerPolygonlocationSlice) pkIN() dialect.Expression {
|
|||
func (o FieldseekerPolygonlocationSlice) copyMatchingRows(from ...*FieldseekerPolygonlocation) {
|
||||
for i, old := range o {
|
||||
for _, new := range from {
|
||||
if new.Objectid != old.Objectid {
|
||||
if new.Globalid != old.Globalid {
|
||||
continue
|
||||
}
|
||||
if new.Version != old.Version {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue