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,11 +29,11 @@ import (
|
|||
|
||||
// FieldseekerHabitatrelate is an object representing the database table.
|
||||
type FieldseekerHabitatrelate struct {
|
||||
Objectid int64 `db:"objectid,pk" `
|
||||
Objectid int64 `db:"objectid" `
|
||||
// Original attribute from ArcGIS API is FOREIGN_ID
|
||||
ForeignID null.Val[uuid.UUID] `db:"foreign_id" `
|
||||
// Original attribute from ArcGIS API is GlobalID
|
||||
Globalid uuid.UUID `db:"globalid" `
|
||||
Globalid uuid.UUID `db:"globalid,pk" `
|
||||
// Original attribute from ArcGIS API is created_user
|
||||
CreatedUser null.Val[string] `db:"created_user" `
|
||||
// Original attribute from ArcGIS API is created_date
|
||||
|
|
@ -133,9 +133,9 @@ func (fieldseekerHabitatrelateColumns) AliasedAs(alias string) fieldseekerHabita
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type FieldseekerHabitatrelateSetter struct {
|
||||
Objectid omit.Val[int64] `db:"objectid,pk" `
|
||||
Objectid omit.Val[int64] `db:"objectid" `
|
||||
ForeignID omitnull.Val[uuid.UUID] `db:"foreign_id" `
|
||||
Globalid omit.Val[uuid.UUID] `db:"globalid" `
|
||||
Globalid omit.Val[uuid.UUID] `db:"globalid,pk" `
|
||||
CreatedUser omitnull.Val[string] `db:"created_user" `
|
||||
CreatedDate omitnull.Val[time.Time] `db:"created_date" `
|
||||
LastEditedUser omitnull.Val[string] `db:"last_edited_user" `
|
||||
|
|
@ -486,25 +486,25 @@ func (s FieldseekerHabitatrelateSetter) Expressions(prefix ...string) []bob.Expr
|
|||
|
||||
// FindFieldseekerHabitatrelate retrieves a single record by primary key
|
||||
// If cols is empty Find will return all columns.
|
||||
func FindFieldseekerHabitatrelate(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerHabitatrelate, error) {
|
||||
func FindFieldseekerHabitatrelate(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32, cols ...string) (*FieldseekerHabitatrelate, error) {
|
||||
if len(cols) == 0 {
|
||||
return FieldseekerHabitatrelates.Query(
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(VersionPK))),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
return FieldseekerHabitatrelates.Query(
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(VersionPK))),
|
||||
sm.Columns(FieldseekerHabitatrelates.Columns.Only(cols...)),
|
||||
).One(ctx, exec)
|
||||
}
|
||||
|
||||
// FieldseekerHabitatrelateExists checks the presence of a single record by primary key
|
||||
func FieldseekerHabitatrelateExists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) {
|
||||
func FieldseekerHabitatrelateExists(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32) (bool, error) {
|
||||
return FieldseekerHabitatrelates.Query(
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(VersionPK))),
|
||||
).Exists(ctx, exec)
|
||||
}
|
||||
|
|
@ -530,13 +530,13 @@ func (o *FieldseekerHabitatrelate) AfterQueryHook(ctx context.Context, exec bob.
|
|||
// primaryKeyVals returns the primary key values of the FieldseekerHabitatrelate
|
||||
func (o *FieldseekerHabitatrelate) primaryKeyVals() bob.Expression {
|
||||
return psql.ArgGroup(
|
||||
o.Objectid,
|
||||
o.Globalid,
|
||||
o.Version,
|
||||
)
|
||||
}
|
||||
|
||||
func (o *FieldseekerHabitatrelate) pkEQ() dialect.Expression {
|
||||
return psql.Group(psql.Quote("fieldseeker.habitatrelate", "objectid"), psql.Quote("fieldseeker.habitatrelate", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
return psql.Group(psql.Quote("fieldseeker.habitatrelate", "globalid"), psql.Quote("fieldseeker.habitatrelate", "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)
|
||||
}))
|
||||
}
|
||||
|
|
@ -563,7 +563,7 @@ func (o *FieldseekerHabitatrelate) Delete(ctx context.Context, exec bob.Executor
|
|||
// Reload refreshes the FieldseekerHabitatrelate using the executor
|
||||
func (o *FieldseekerHabitatrelate) Reload(ctx context.Context, exec bob.Executor) error {
|
||||
o2, err := FieldseekerHabitatrelates.Query(
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Objectid.EQ(psql.Arg(o.Objectid))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Globalid.EQ(psql.Arg(o.Globalid))),
|
||||
sm.Where(FieldseekerHabitatrelates.Columns.Version.EQ(psql.Arg(o.Version))),
|
||||
).One(ctx, exec)
|
||||
if err != nil {
|
||||
|
|
@ -598,7 +598,7 @@ func (o FieldseekerHabitatrelateSlice) pkIN() dialect.Expression {
|
|||
return psql.Raw("NULL")
|
||||
}
|
||||
|
||||
return psql.Group(psql.Quote("fieldseeker.habitatrelate", "objectid"), psql.Quote("fieldseeker.habitatrelate", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
return psql.Group(psql.Quote("fieldseeker.habitatrelate", "globalid"), psql.Quote("fieldseeker.habitatrelate", "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()
|
||||
|
|
@ -613,7 +613,7 @@ func (o FieldseekerHabitatrelateSlice) pkIN() dialect.Expression {
|
|||
func (o FieldseekerHabitatrelateSlice) copyMatchingRows(from ...*FieldseekerHabitatrelate) {
|
||||
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