Make fieldseeker tables key on globalid, version

This is because the objectid is not unique between organizations.
This commit is contained in:
Eli Ribble 2026-01-13 04:16:24 +00:00
parent d02d34cbaa
commit e18ce6a09e
No known key found for this signature in database
110 changed files with 10602 additions and 486 deletions

View file

@ -29,11 +29,11 @@ import (
// FieldseekerZones2 is an object representing the database table.
type FieldseekerZones2 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 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
@ -137,9 +137,9 @@ func (fieldseekerZones2Columns) AliasedAs(alias string) fieldseekerZones2Columns
// All values are optional, and do not have to be set
// Generated columns are not included
type FieldseekerZones2Setter struct {
Objectid omit.Val[int64] `db:"objectid,pk" `
Objectid omit.Val[int64] `db:"objectid" `
Name omitnull.Val[string] `db:"name" `
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" `
@ -510,25 +510,25 @@ func (s FieldseekerZones2Setter) Expressions(prefix ...string) []bob.Expression
// FindFieldseekerZones2 retrieves a single record by primary key
// If cols is empty Find will return all columns.
func FindFieldseekerZones2(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32, cols ...string) (*FieldseekerZones2, error) {
func FindFieldseekerZones2(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32, cols ...string) (*FieldseekerZones2, error) {
if len(cols) == 0 {
return FieldseekerZones2s.Query(
sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
sm.Where(FieldseekerZones2s.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(VersionPK))),
).One(ctx, exec)
}
return FieldseekerZones2s.Query(
sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
sm.Where(FieldseekerZones2s.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(VersionPK))),
sm.Columns(FieldseekerZones2s.Columns.Only(cols...)),
).One(ctx, exec)
}
// FieldseekerZones2Exists checks the presence of a single record by primary key
func FieldseekerZones2Exists(ctx context.Context, exec bob.Executor, ObjectidPK int64, VersionPK int32) (bool, error) {
func FieldseekerZones2Exists(ctx context.Context, exec bob.Executor, GlobalidPK uuid.UUID, VersionPK int32) (bool, error) {
return FieldseekerZones2s.Query(
sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(ObjectidPK))),
sm.Where(FieldseekerZones2s.Columns.Globalid.EQ(psql.Arg(GlobalidPK))),
sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(VersionPK))),
).Exists(ctx, exec)
}
@ -554,13 +554,13 @@ func (o *FieldseekerZones2) AfterQueryHook(ctx context.Context, exec bob.Executo
// primaryKeyVals returns the primary key values of the FieldseekerZones2
func (o *FieldseekerZones2) primaryKeyVals() bob.Expression {
return psql.ArgGroup(
o.Objectid,
o.Globalid,
o.Version,
)
}
func (o *FieldseekerZones2) pkEQ() dialect.Expression {
return psql.Group(psql.Quote("fieldseeker.zones2", "objectid"), psql.Quote("fieldseeker.zones2", "version")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
return psql.Group(psql.Quote("fieldseeker.zones2", "globalid"), psql.Quote("fieldseeker.zones2", "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)
}))
}
@ -587,7 +587,7 @@ func (o *FieldseekerZones2) Delete(ctx context.Context, exec bob.Executor) error
// Reload refreshes the FieldseekerZones2 using the executor
func (o *FieldseekerZones2) Reload(ctx context.Context, exec bob.Executor) error {
o2, err := FieldseekerZones2s.Query(
sm.Where(FieldseekerZones2s.Columns.Objectid.EQ(psql.Arg(o.Objectid))),
sm.Where(FieldseekerZones2s.Columns.Globalid.EQ(psql.Arg(o.Globalid))),
sm.Where(FieldseekerZones2s.Columns.Version.EQ(psql.Arg(o.Version))),
).One(ctx, exec)
if err != nil {
@ -622,7 +622,7 @@ func (o FieldseekerZones2Slice) pkIN() dialect.Expression {
return psql.Raw("NULL")
}
return psql.Group(psql.Quote("fieldseeker.zones2", "objectid"), psql.Quote("fieldseeker.zones2", "version")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
return psql.Group(psql.Quote("fieldseeker.zones2", "globalid"), psql.Quote("fieldseeker.zones2", "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()
@ -637,7 +637,7 @@ func (o FieldseekerZones2Slice) pkIN() dialect.Expression {
func (o FieldseekerZones2Slice) copyMatchingRows(from ...*FieldseekerZones2) {
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 {