diff --git a/.gitmodules b/.gitmodules index 555f12c9..dc0c25cc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "go-geojson2h3"] path = go-geojson2h3 url = git@github.com:Gleipnir-Technology/go-geojson2h3.git -[submodule "bob"] - path = db/bob - url = git@github.com:Gleipnir-Technology/bob.git diff --git a/background/arcgis.go b/background/arcgis.go index d1622068..901fda63 100644 --- a/background/arcgis.go +++ b/background/arcgis.go @@ -34,6 +34,7 @@ import ( "github.com/jackc/pgx/v5" "github.com/rs/zerolog/log" "github.com/stephenafamo/bob/dialect/psql" + "github.com/stephenafamo/bob/dialect/psql/dm" "github.com/stephenafamo/bob/dialect/psql/sm" "github.com/stephenafamo/bob/dialect/psql/um" ) @@ -101,11 +102,15 @@ func HandleOauthAccessCode(ctx context.Context, user *models.User, code string) } func HasFieldseekerConnection(ctx context.Context, user *models.User) (bool, error) { - result, err := sql.OauthTokenByUserId(user.ID).All(ctx, db.PGInstance.BobDB) + result, err := models.OauthTokens.Query( + sm.Where( + models.OauthTokens.Columns.UserID.EQ(psql.Arg(user.ID)), + ), + ).Exists(ctx, db.PGInstance.BobDB) if err != nil { return false, err } - return len(result) > 0, nil + return result, nil } func IsSyncOngoing(org_id int32) bool { @@ -234,12 +239,12 @@ func updateArcgisUserData(ctx context.Context, user *models.User, access_token s RefreshTokenExpires: refresh_token_expires, }, ) - portal, err := client.PortalsSelf() + + portal, err := updatePortalData(ctx, client, user.ID) if err != nil { - log.Error().Err(err).Msg("Failed to get ArcGIS user data") + log.Error().Err(err).Msg("Failed to get portal data") return } - log.Info().Str("Username", portal.User.Username).Str("user_id", portal.User.ID).Str("org_id", portal.User.OrgID).Str("org_name", portal.Name).Str("license_type_id", portal.User.UserLicenseTypeID).Msg("Got portals data") _, err = models.OauthTokens.Update( //um.SetCol(string(models.OauthTokens.Columns.ArcgisID)).ToArg(portal.User.ID), @@ -326,6 +331,72 @@ func updateArcgisUserData(ctx context.Context, user *models.User, access_token s NewOAuthTokenChannel <- struct{}{} } +func updatePortalData(ctx context.Context, client *arcgis.ArcGIS, user_id int32) (*arcgis.PortalsResponse, error) { + p, err := client.PortalsSelf() + if err != nil { + return nil, fmt.Errorf("Failed to get ArcGIS user data: %w", err) + } + + tx, err := db.PGInstance.BobDB.BeginTx(ctx, nil) + _, err = models.ArcgisUserPrivileges.Delete( + dm.Where( + models.ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(p.User.ID)), + ), + ).Exec(ctx, tx) + + if err != nil { + tx.Rollback(ctx) + return nil, fmt.Errorf("Failed to delete previous user privilege data: %w", err) + } + + _, err = models.ArcgisUsers.Delete( + dm.Where( + models.ArcgisUsers.Columns.ID.EQ(psql.Arg(p.User.ID)), + ), + ).Exec(ctx, tx) + + if err != nil { + tx.Rollback(ctx) + return nil, fmt.Errorf("Failed to delete previous user data: %w", err) + } + + setter := models.ArcgisUserSetter{ + Access: omit.From(p.Access), + Created: omit.From(time.Unix(p.User.Created, 0)), + Email: omit.From(p.User.Email), + FullName: omit.From(p.User.FullName), + ID: omit.From(p.User.ID), + Level: omit.From(p.User.Level), + OrgID: omit.From(p.User.OrgID), + PublicUserID: omit.From(user_id), + Region: omit.From(p.Region), + Role: omit.From(p.User.Role), + RoleID: omit.From(p.User.RoleId), + Username: omit.From(p.User.Username), + UserLicenseTypeID: omit.From(p.User.UserLicenseTypeID), + UserType: omit.From(p.User.UserType), + } + _, err = models.ArcgisUsers.Insert(&setter).One(ctx, tx) + if err != nil { + tx.Rollback(ctx) + return nil, fmt.Errorf("Failed to add arcgis user data: %w", err) + } + for _, priv := range p.User.Privileges { + s := models.ArcgisUserPrivilegeSetter{ + Privilege: omit.From(priv), + UserID: omit.From(p.User.ID), + } + _, err := models.ArcgisUserPrivileges.Insert(&s).One(ctx, tx) + if err != nil { + tx.Rollback(ctx) + return nil, fmt.Errorf("Failed to add arcgis user privilege data: %w", err) + } + } + err = tx.Commit(ctx) + log.Info().Str("username", p.User.Username).Str("user_id", p.User.ID).Str("org_id", p.User.OrgID).Str("org_name", p.Name).Str("license_type_id", p.User.UserLicenseTypeID).Msg("Updated portals data") + return p, nil +} + func maybeCreateWebhook(ctx context.Context, client *fieldseeker.FieldSeeker) { webhooks, err := client.WebhookList() if err != nil { diff --git a/db/bob b/db/bob deleted file mode 160000 index d277a066..00000000 --- a/db/bob +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d277a066d6bac5336e49615495ce2c74e736a7fd diff --git a/db/bobgen.sh b/db/bobgen.sh index ba30582d..9c2d653c 100755 --- a/db/bobgen.sh +++ b/db/bobgen.sh @@ -1,2 +1,3 @@ #!/run/current-system/sw/bin/bash -PSQL_DSN="postgresql://?host=/var/run/postgresql&sslmode=disable&dbname=nidus-sync" bob/bobgen-psql +PSQL_DSN="postgresql://?host=/var/run/postgresql&sslmode=disable&dbname=nidus-sync" /tmp/bobgen-psql +#PSQL_DSN="postgresql://?host=/var/run/postgresql&sslmode=disable&dbname=nidus-sync" bob/gen/bobgen-psql/bobgen-psql diff --git a/db/bobgen.yaml b/db/bobgen.yaml index e5a60949..b9f4c8d7 100644 --- a/db/bobgen.yaml +++ b/db/bobgen.yaml @@ -1,4 +1,9 @@ aliases: + arcgis.user_: + up_plural: "ArcgisUsers" + up_singular: "ArcgisUser" + down_plural: "arcgisusers" + down_singular: "arcgisuser" user_: up_plural: "Users" up_singular: "User" @@ -7,9 +12,11 @@ aliases: no_tests: true psql: schemas: + - "arcgis" - "public" - "publicreport" - "fieldseeker" + shared_schema: "public" queries: - ./sql uuid_pkg: google diff --git a/db/dberrors/arcgis.user_.bob.go b/db/dberrors/arcgis.user_.bob.go new file mode 100644 index 00000000..d17b1fef --- /dev/null +++ b/db/dberrors/arcgis.user_.bob.go @@ -0,0 +1,17 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package dberrors + +var ArcgisUserErrors = &arcgisuserErrors{ + ErrUniqueUser_Pkey: &UniqueConstraintError{ + schema: "arcgis", + table: "user_", + columns: []string{"id"}, + s: "user__pkey", + }, +} + +type arcgisuserErrors struct { + ErrUniqueUser_Pkey *UniqueConstraintError +} diff --git a/db/dberrors/arcgis.user_privilege.bob.go b/db/dberrors/arcgis.user_privilege.bob.go new file mode 100644 index 00000000..7ff6253f --- /dev/null +++ b/db/dberrors/arcgis.user_privilege.bob.go @@ -0,0 +1,17 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package dberrors + +var ArcgisUserPrivilegeErrors = &arcgisUserPrivilegeErrors{ + ErrUniqueUserPrivilegePkey: &UniqueConstraintError{ + schema: "arcgis", + table: "user_privilege", + columns: []string{"user_id", "privilege"}, + s: "user_privilege_pkey", + }, +} + +type arcgisUserPrivilegeErrors struct { + ErrUniqueUserPrivilegePkey *UniqueConstraintError +} diff --git a/db/dberrors/bob_errors.bob.go b/db/dberrors/bob_errors.bob.go index f98ecde7..ec4056c3 100644 --- a/db/dberrors/bob_errors.bob.go +++ b/db/dberrors/bob_errors.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/district.bob.go b/db/dberrors/district.bob.go index 06f8adee..b564e22b 100644 --- a/db/dberrors/district.bob.go +++ b/db/dberrors/district.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.containerrelate.bob.go b/db/dberrors/fieldseeker.containerrelate.bob.go index 2e5478b3..40d01312 100644 --- a/db/dberrors/fieldseeker.containerrelate.bob.go +++ b/db/dberrors/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.fieldscoutinglog.bob.go b/db/dberrors/fieldseeker.fieldscoutinglog.bob.go index 25c1147a..3237f5db 100644 --- a/db/dberrors/fieldseeker.fieldscoutinglog.bob.go +++ b/db/dberrors/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.habitatrelate.bob.go b/db/dberrors/fieldseeker.habitatrelate.bob.go index 752bf877..d00f431c 100644 --- a/db/dberrors/fieldseeker.habitatrelate.bob.go +++ b/db/dberrors/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.inspectionsample.bob.go b/db/dberrors/fieldseeker.inspectionsample.bob.go index b4e31312..ce6725a5 100644 --- a/db/dberrors/fieldseeker.inspectionsample.bob.go +++ b/db/dberrors/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.inspectionsampledetail.bob.go b/db/dberrors/fieldseeker.inspectionsampledetail.bob.go index 5538e4c9..69d7b6e6 100644 --- a/db/dberrors/fieldseeker.inspectionsampledetail.bob.go +++ b/db/dberrors/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.linelocation.bob.go b/db/dberrors/fieldseeker.linelocation.bob.go index 353de2a0..5a135a53 100644 --- a/db/dberrors/fieldseeker.linelocation.bob.go +++ b/db/dberrors/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.locationtracking.bob.go b/db/dberrors/fieldseeker.locationtracking.bob.go index 2f1f10ad..e68d1172 100644 --- a/db/dberrors/fieldseeker.locationtracking.bob.go +++ b/db/dberrors/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.mosquitoinspection.bob.go b/db/dberrors/fieldseeker.mosquitoinspection.bob.go index 127e85ca..f9b119a7 100644 --- a/db/dberrors/fieldseeker.mosquitoinspection.bob.go +++ b/db/dberrors/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.pointlocation.bob.go b/db/dberrors/fieldseeker.pointlocation.bob.go index 1b46e6c2..9078a437 100644 --- a/db/dberrors/fieldseeker.pointlocation.bob.go +++ b/db/dberrors/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.polygonlocation.bob.go b/db/dberrors/fieldseeker.polygonlocation.bob.go index 1502c145..250e5de2 100644 --- a/db/dberrors/fieldseeker.polygonlocation.bob.go +++ b/db/dberrors/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.pool.bob.go b/db/dberrors/fieldseeker.pool.bob.go index fc41b355..7bb30e90 100644 --- a/db/dberrors/fieldseeker.pool.bob.go +++ b/db/dberrors/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.pooldetail.bob.go b/db/dberrors/fieldseeker.pooldetail.bob.go index 613767bc..1423b462 100644 --- a/db/dberrors/fieldseeker.pooldetail.bob.go +++ b/db/dberrors/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go b/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go index fcad48db..991a4d46 100644 --- a/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.qamosquitoinspection.bob.go b/db/dberrors/fieldseeker.qamosquitoinspection.bob.go index 0d940baa..5ae42a56 100644 --- a/db/dberrors/fieldseeker.qamosquitoinspection.bob.go +++ b/db/dberrors/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.rodentlocation.bob.go b/db/dberrors/fieldseeker.rodentlocation.bob.go index 8b365032..d865425f 100644 --- a/db/dberrors/fieldseeker.rodentlocation.bob.go +++ b/db/dberrors/fieldseeker.rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.samplecollection.bob.go b/db/dberrors/fieldseeker.samplecollection.bob.go index 1bbb4dc8..6f0de912 100644 --- a/db/dberrors/fieldseeker.samplecollection.bob.go +++ b/db/dberrors/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.samplelocation.bob.go b/db/dberrors/fieldseeker.samplelocation.bob.go index 889bb8b5..35a96bc1 100644 --- a/db/dberrors/fieldseeker.samplelocation.bob.go +++ b/db/dberrors/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.servicerequest.bob.go b/db/dberrors/fieldseeker.servicerequest.bob.go index ec0baf46..5e8d1020 100644 --- a/db/dberrors/fieldseeker.servicerequest.bob.go +++ b/db/dberrors/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.speciesabundance.bob.go b/db/dberrors/fieldseeker.speciesabundance.bob.go index 5a6fde04..922bcc2a 100644 --- a/db/dberrors/fieldseeker.speciesabundance.bob.go +++ b/db/dberrors/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.stormdrain.bob.go b/db/dberrors/fieldseeker.stormdrain.bob.go index fa72d71e..689fe28d 100644 --- a/db/dberrors/fieldseeker.stormdrain.bob.go +++ b/db/dberrors/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.timecard.bob.go b/db/dberrors/fieldseeker.timecard.bob.go index a8c761ab..bf09f766 100644 --- a/db/dberrors/fieldseeker.timecard.bob.go +++ b/db/dberrors/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.trapdata.bob.go b/db/dberrors/fieldseeker.trapdata.bob.go index f31e1333..7ffe6603 100644 --- a/db/dberrors/fieldseeker.trapdata.bob.go +++ b/db/dberrors/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.traplocation.bob.go b/db/dberrors/fieldseeker.traplocation.bob.go index a5c182e4..de57fa80 100644 --- a/db/dberrors/fieldseeker.traplocation.bob.go +++ b/db/dberrors/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.treatment.bob.go b/db/dberrors/fieldseeker.treatment.bob.go index 6231fcb3..40e0bddf 100644 --- a/db/dberrors/fieldseeker.treatment.bob.go +++ b/db/dberrors/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.treatmentarea.bob.go b/db/dberrors/fieldseeker.treatmentarea.bob.go index 94ca5921..c7ff263b 100644 --- a/db/dberrors/fieldseeker.treatmentarea.bob.go +++ b/db/dberrors/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.zones.bob.go b/db/dberrors/fieldseeker.zones.bob.go index d18052a7..bd2fd6e6 100644 --- a/db/dberrors/fieldseeker.zones.bob.go +++ b/db/dberrors/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker.zones2.bob.go b/db/dberrors/fieldseeker.zones2.bob.go index 3d378f51..644248d7 100644 --- a/db/dberrors/fieldseeker.zones2.bob.go +++ b/db/dberrors/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/fieldseeker_sync.bob.go b/db/dberrors/fieldseeker_sync.bob.go index f02acf71..ac899d66 100644 --- a/db/dberrors/fieldseeker_sync.bob.go +++ b/db/dberrors/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/goose_db_version.bob.go b/db/dberrors/goose_db_version.bob.go index 1bd13dbd..af370d75 100644 --- a/db/dberrors/goose_db_version.bob.go +++ b/db/dberrors/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/h3_aggregation.bob.go b/db/dberrors/h3_aggregation.bob.go index 0876f0ad..80c555b1 100644 --- a/db/dberrors/h3_aggregation.bob.go +++ b/db/dberrors/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/note_audio.bob.go b/db/dberrors/note_audio.bob.go index 408f8d94..51621255 100644 --- a/db/dberrors/note_audio.bob.go +++ b/db/dberrors/note_audio.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/note_audio_breadcrumb.bob.go b/db/dberrors/note_audio_breadcrumb.bob.go index 36b73309..c0db7c25 100644 --- a/db/dberrors/note_audio_breadcrumb.bob.go +++ b/db/dberrors/note_audio_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/note_audio_data.bob.go b/db/dberrors/note_audio_data.bob.go index 6fe4fa73..bd4b07c1 100644 --- a/db/dberrors/note_audio_data.bob.go +++ b/db/dberrors/note_audio_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/note_image.bob.go b/db/dberrors/note_image.bob.go index 53ada199..8090f936 100644 --- a/db/dberrors/note_image.bob.go +++ b/db/dberrors/note_image.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/note_image_breadcrumb.bob.go b/db/dberrors/note_image_breadcrumb.bob.go index 256c0567..7e62d2ad 100644 --- a/db/dberrors/note_image_breadcrumb.bob.go +++ b/db/dberrors/note_image_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/note_image_data.bob.go b/db/dberrors/note_image_data.bob.go index eb67681f..91c1a89a 100644 --- a/db/dberrors/note_image_data.bob.go +++ b/db/dberrors/note_image_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/notification.bob.go b/db/dberrors/notification.bob.go index f9a429a1..d4f2841a 100644 --- a/db/dberrors/notification.bob.go +++ b/db/dberrors/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/oauth_token.bob.go b/db/dberrors/oauth_token.bob.go index 5340029a..050b1a47 100644 --- a/db/dberrors/oauth_token.bob.go +++ b/db/dberrors/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/organization.bob.go b/db/dberrors/organization.bob.go index 1368c885..d9bf3dbd 100644 --- a/db/dberrors/organization.bob.go +++ b/db/dberrors/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/publicreport.nuisance.bob.go b/db/dberrors/publicreport.nuisance.bob.go index fe815789..c1fcebb0 100644 --- a/db/dberrors/publicreport.nuisance.bob.go +++ b/db/dberrors/publicreport.nuisance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/publicreport.pool.bob.go b/db/dberrors/publicreport.pool.bob.go index d7ab3834..aefb420d 100644 --- a/db/dberrors/publicreport.pool.bob.go +++ b/db/dberrors/publicreport.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/publicreport.pool_photo.bob.go b/db/dberrors/publicreport.pool_photo.bob.go index 2bfed48d..0a5310e6 100644 --- a/db/dberrors/publicreport.pool_photo.bob.go +++ b/db/dberrors/publicreport.pool_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/publicreport.quick.bob.go b/db/dberrors/publicreport.quick.bob.go index f2d7db21..d51ed705 100644 --- a/db/dberrors/publicreport.quick.bob.go +++ b/db/dberrors/publicreport.quick.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/publicreport.quick_photo.bob.go b/db/dberrors/publicreport.quick_photo.bob.go index cce0eee3..4dd54714 100644 --- a/db/dberrors/publicreport.quick_photo.bob.go +++ b/db/dberrors/publicreport.quick_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/sessions.bob.go b/db/dberrors/sessions.bob.go index 8b54a349..e271ce05 100644 --- a/db/dberrors/sessions.bob.go +++ b/db/dberrors/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/spatial_ref_sys.bob.go b/db/dberrors/spatial_ref_sys.bob.go index 769f4bc2..195ac12d 100644 --- a/db/dberrors/spatial_ref_sys.bob.go +++ b/db/dberrors/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dberrors/user_.bob.go b/db/dberrors/user_.bob.go index 8b8b7295..d000ac1f 100644 --- a/db/dberrors/user_.bob.go +++ b/db/dberrors/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dberrors diff --git a/db/dbinfo/arcgis.user_.bob.go b/db/dbinfo/arcgis.user_.bob.go new file mode 100644 index 00000000..772f92db --- /dev/null +++ b/db/dbinfo/arcgis.user_.bob.go @@ -0,0 +1,237 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package dbinfo + +import "github.com/aarondl/opt/null" + +var ArcgisUsers = Table[ + arcgisuserColumns, + arcgisuserIndexes, + arcgisuserForeignKeys, + arcgisuserUniques, + arcgisuserChecks, +]{ + Schema: "arcgis", + Name: "user_", + Columns: arcgisuserColumns{ + Access: column{ + Name: "access", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Created: column{ + Name: "created", + DBType: "timestamp without time zone", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Email: column{ + Name: "email", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + FullName: column{ + Name: "full_name", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + ID: column{ + Name: "id", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Level: column{ + Name: "level", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + OrgID: column{ + Name: "org_id", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + PublicUserID: column{ + Name: "public_user_id", + DBType: "integer", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Region: column{ + Name: "region", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Role: column{ + Name: "role", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + RoleID: column{ + Name: "role_id", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Username: column{ + Name: "username", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + UserLicenseTypeID: column{ + Name: "user_license_type_id", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + UserType: column{ + Name: "user_type", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + }, + Indexes: arcgisuserIndexes{ + UserPkey: index{ + Type: "btree", + Name: "user__pkey", + Columns: []indexColumn{ + { + Name: "id", + Desc: null.FromCond(false, true), + IsExpression: false, + }, + }, + Unique: true, + Comment: "", + NullsFirst: []bool{false}, + NullsDistinct: false, + Where: "", + Include: []string{}, + }, + }, + PrimaryKey: &constraint{ + Name: "user__pkey", + Columns: []string{"id"}, + Comment: "", + }, + ForeignKeys: arcgisuserForeignKeys{ + ArcgisUserUserPublicUserIDFkey: foreignKey{ + constraint: constraint{ + Name: "arcgis.user_.user__public_user_id_fkey", + Columns: []string{"public_user_id"}, + Comment: "", + }, + ForeignTable: "user_", + ForeignColumns: []string{"id"}, + }, + }, + + Comment: "", +} + +type arcgisuserColumns struct { + Access column + Created column + Email column + FullName column + ID column + Level column + OrgID column + PublicUserID column + Region column + Role column + RoleID column + Username column + UserLicenseTypeID column + UserType column +} + +func (c arcgisuserColumns) AsSlice() []column { + return []column{ + c.Access, c.Created, c.Email, c.FullName, c.ID, c.Level, c.OrgID, c.PublicUserID, c.Region, c.Role, c.RoleID, c.Username, c.UserLicenseTypeID, c.UserType, + } +} + +type arcgisuserIndexes struct { + UserPkey index +} + +func (i arcgisuserIndexes) AsSlice() []index { + return []index{ + i.UserPkey, + } +} + +type arcgisuserForeignKeys struct { + ArcgisUserUserPublicUserIDFkey foreignKey +} + +func (f arcgisuserForeignKeys) AsSlice() []foreignKey { + return []foreignKey{ + f.ArcgisUserUserPublicUserIDFkey, + } +} + +type arcgisuserUniques struct{} + +func (u arcgisuserUniques) AsSlice() []constraint { + return []constraint{} +} + +type arcgisuserChecks struct{} + +func (c arcgisuserChecks) AsSlice() []check { + return []check{} +} diff --git a/db/dbinfo/arcgis.user_privilege.bob.go b/db/dbinfo/arcgis.user_privilege.bob.go new file mode 100644 index 00000000..88e2785f --- /dev/null +++ b/db/dbinfo/arcgis.user_privilege.bob.go @@ -0,0 +1,122 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package dbinfo + +import "github.com/aarondl/opt/null" + +var ArcgisUserPrivileges = Table[ + arcgisUserPrivilegeColumns, + arcgisUserPrivilegeIndexes, + arcgisUserPrivilegeForeignKeys, + arcgisUserPrivilegeUniques, + arcgisUserPrivilegeChecks, +]{ + Schema: "arcgis", + Name: "user_privilege", + Columns: arcgisUserPrivilegeColumns{ + UserID: column{ + Name: "user_id", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + Privilege: column{ + Name: "privilege", + DBType: "text", + Default: "", + Comment: "", + Nullable: false, + Generated: false, + AutoIncr: false, + }, + }, + Indexes: arcgisUserPrivilegeIndexes{ + UserPrivilegePkey: index{ + Type: "btree", + Name: "user_privilege_pkey", + Columns: []indexColumn{ + { + Name: "user_id", + Desc: null.FromCond(false, true), + IsExpression: false, + }, + { + Name: "privilege", + Desc: null.FromCond(false, true), + IsExpression: false, + }, + }, + Unique: true, + Comment: "", + NullsFirst: []bool{false, false}, + NullsDistinct: false, + Where: "", + Include: []string{}, + }, + }, + PrimaryKey: &constraint{ + Name: "user_privilege_pkey", + Columns: []string{"user_id", "privilege"}, + Comment: "", + }, + ForeignKeys: arcgisUserPrivilegeForeignKeys{ + ArcgisUserPrivilegeUserPrivilegeUserIDFkey: foreignKey{ + constraint: constraint{ + Name: "arcgis.user_privilege.user_privilege_user_id_fkey", + Columns: []string{"user_id"}, + Comment: "", + }, + ForeignTable: "arcgis.user_", + ForeignColumns: []string{"id"}, + }, + }, + + Comment: "", +} + +type arcgisUserPrivilegeColumns struct { + UserID column + Privilege column +} + +func (c arcgisUserPrivilegeColumns) AsSlice() []column { + return []column{ + c.UserID, c.Privilege, + } +} + +type arcgisUserPrivilegeIndexes struct { + UserPrivilegePkey index +} + +func (i arcgisUserPrivilegeIndexes) AsSlice() []index { + return []index{ + i.UserPrivilegePkey, + } +} + +type arcgisUserPrivilegeForeignKeys struct { + ArcgisUserPrivilegeUserPrivilegeUserIDFkey foreignKey +} + +func (f arcgisUserPrivilegeForeignKeys) AsSlice() []foreignKey { + return []foreignKey{ + f.ArcgisUserPrivilegeUserPrivilegeUserIDFkey, + } +} + +type arcgisUserPrivilegeUniques struct{} + +func (u arcgisUserPrivilegeUniques) AsSlice() []constraint { + return []constraint{} +} + +type arcgisUserPrivilegeChecks struct{} + +func (c arcgisUserPrivilegeChecks) AsSlice() []check { + return []check{} +} diff --git a/db/dbinfo/bob_types.bob.go b/db/dbinfo/bob_types.bob.go index 53d5f9be..2ece4dab 100644 --- a/db/dbinfo/bob_types.bob.go +++ b/db/dbinfo/bob_types.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/district.bob.go b/db/dbinfo/district.bob.go index 11976f13..1cbd0a70 100644 --- a/db/dbinfo/district.bob.go +++ b/db/dbinfo/district.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.containerrelate.bob.go b/db/dbinfo/fieldseeker.containerrelate.bob.go index e7f9fe89..9b293435 100644 --- a/db/dbinfo/fieldseeker.containerrelate.bob.go +++ b/db/dbinfo/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go b/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go index c506a744..7a8b2e88 100644 --- a/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go +++ b/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.habitatrelate.bob.go b/db/dbinfo/fieldseeker.habitatrelate.bob.go index b19ac6ac..5b7eef2f 100644 --- a/db/dbinfo/fieldseeker.habitatrelate.bob.go +++ b/db/dbinfo/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.inspectionsample.bob.go b/db/dbinfo/fieldseeker.inspectionsample.bob.go index d2e307a2..7222c516 100644 --- a/db/dbinfo/fieldseeker.inspectionsample.bob.go +++ b/db/dbinfo/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go b/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go index 6587df5f..9bfee61f 100644 --- a/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go +++ b/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.linelocation.bob.go b/db/dbinfo/fieldseeker.linelocation.bob.go index ef4c5c02..426609fa 100644 --- a/db/dbinfo/fieldseeker.linelocation.bob.go +++ b/db/dbinfo/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.locationtracking.bob.go b/db/dbinfo/fieldseeker.locationtracking.bob.go index 65aba4b0..fa3d2922 100644 --- a/db/dbinfo/fieldseeker.locationtracking.bob.go +++ b/db/dbinfo/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.mosquitoinspection.bob.go b/db/dbinfo/fieldseeker.mosquitoinspection.bob.go index 15436115..333ae452 100644 --- a/db/dbinfo/fieldseeker.mosquitoinspection.bob.go +++ b/db/dbinfo/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.pointlocation.bob.go b/db/dbinfo/fieldseeker.pointlocation.bob.go index 999e6ef6..5f65e44a 100644 --- a/db/dbinfo/fieldseeker.pointlocation.bob.go +++ b/db/dbinfo/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.polygonlocation.bob.go b/db/dbinfo/fieldseeker.polygonlocation.bob.go index 835412ab..e200e6c7 100644 --- a/db/dbinfo/fieldseeker.polygonlocation.bob.go +++ b/db/dbinfo/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.pool.bob.go b/db/dbinfo/fieldseeker.pool.bob.go index 51158097..9f359745 100644 --- a/db/dbinfo/fieldseeker.pool.bob.go +++ b/db/dbinfo/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.pooldetail.bob.go b/db/dbinfo/fieldseeker.pooldetail.bob.go index 65c5b988..b3a9e700 100644 --- a/db/dbinfo/fieldseeker.pooldetail.bob.go +++ b/db/dbinfo/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go b/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go index 8ae3d2f6..f85288c6 100644 --- a/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go b/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go index c841701d..76da7dd7 100644 --- a/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go +++ b/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.rodentlocation.bob.go b/db/dbinfo/fieldseeker.rodentlocation.bob.go index 5e57a239..8713d101 100644 --- a/db/dbinfo/fieldseeker.rodentlocation.bob.go +++ b/db/dbinfo/fieldseeker.rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.samplecollection.bob.go b/db/dbinfo/fieldseeker.samplecollection.bob.go index a22bc7ec..a205203b 100644 --- a/db/dbinfo/fieldseeker.samplecollection.bob.go +++ b/db/dbinfo/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.samplelocation.bob.go b/db/dbinfo/fieldseeker.samplelocation.bob.go index 89007afd..1f63b1c4 100644 --- a/db/dbinfo/fieldseeker.samplelocation.bob.go +++ b/db/dbinfo/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.servicerequest.bob.go b/db/dbinfo/fieldseeker.servicerequest.bob.go index 92a55390..30de6afe 100644 --- a/db/dbinfo/fieldseeker.servicerequest.bob.go +++ b/db/dbinfo/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.speciesabundance.bob.go b/db/dbinfo/fieldseeker.speciesabundance.bob.go index 3d67c19a..7431468f 100644 --- a/db/dbinfo/fieldseeker.speciesabundance.bob.go +++ b/db/dbinfo/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.stormdrain.bob.go b/db/dbinfo/fieldseeker.stormdrain.bob.go index 931622c0..412832a3 100644 --- a/db/dbinfo/fieldseeker.stormdrain.bob.go +++ b/db/dbinfo/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.timecard.bob.go b/db/dbinfo/fieldseeker.timecard.bob.go index d635a67a..65b6a792 100644 --- a/db/dbinfo/fieldseeker.timecard.bob.go +++ b/db/dbinfo/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.trapdata.bob.go b/db/dbinfo/fieldseeker.trapdata.bob.go index 14f83873..2c7c523f 100644 --- a/db/dbinfo/fieldseeker.trapdata.bob.go +++ b/db/dbinfo/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.traplocation.bob.go b/db/dbinfo/fieldseeker.traplocation.bob.go index b2563629..cc3cda90 100644 --- a/db/dbinfo/fieldseeker.traplocation.bob.go +++ b/db/dbinfo/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.treatment.bob.go b/db/dbinfo/fieldseeker.treatment.bob.go index 914c0532..b6a0075e 100644 --- a/db/dbinfo/fieldseeker.treatment.bob.go +++ b/db/dbinfo/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.treatmentarea.bob.go b/db/dbinfo/fieldseeker.treatmentarea.bob.go index f4dbf8b7..d9df5b58 100644 --- a/db/dbinfo/fieldseeker.treatmentarea.bob.go +++ b/db/dbinfo/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.zones.bob.go b/db/dbinfo/fieldseeker.zones.bob.go index eb1ecf75..1cd771cd 100644 --- a/db/dbinfo/fieldseeker.zones.bob.go +++ b/db/dbinfo/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker.zones2.bob.go b/db/dbinfo/fieldseeker.zones2.bob.go index 6d26143d..7a55e0e8 100644 --- a/db/dbinfo/fieldseeker.zones2.bob.go +++ b/db/dbinfo/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/fieldseeker_sync.bob.go b/db/dbinfo/fieldseeker_sync.bob.go index 6a53ec8e..f0d18f63 100644 --- a/db/dbinfo/fieldseeker_sync.bob.go +++ b/db/dbinfo/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/geography_columns.bob.go b/db/dbinfo/geography_columns.bob.go index 0cd86251..fede3218 100644 --- a/db/dbinfo/geography_columns.bob.go +++ b/db/dbinfo/geography_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/geometry_columns.bob.go b/db/dbinfo/geometry_columns.bob.go index c560a3d8..2292ee9a 100644 --- a/db/dbinfo/geometry_columns.bob.go +++ b/db/dbinfo/geometry_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/goose_db_version.bob.go b/db/dbinfo/goose_db_version.bob.go index 60d0e295..9bda0126 100644 --- a/db/dbinfo/goose_db_version.bob.go +++ b/db/dbinfo/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/h3_aggregation.bob.go b/db/dbinfo/h3_aggregation.bob.go index 3f640a73..65bd6414 100644 --- a/db/dbinfo/h3_aggregation.bob.go +++ b/db/dbinfo/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/note_audio.bob.go b/db/dbinfo/note_audio.bob.go index 413aa3e6..4725221d 100644 --- a/db/dbinfo/note_audio.bob.go +++ b/db/dbinfo/note_audio.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/note_audio_breadcrumb.bob.go b/db/dbinfo/note_audio_breadcrumb.bob.go index 9031f61a..0f6e5248 100644 --- a/db/dbinfo/note_audio_breadcrumb.bob.go +++ b/db/dbinfo/note_audio_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/note_audio_data.bob.go b/db/dbinfo/note_audio_data.bob.go index 20b42526..8e3dae3f 100644 --- a/db/dbinfo/note_audio_data.bob.go +++ b/db/dbinfo/note_audio_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/note_image.bob.go b/db/dbinfo/note_image.bob.go index 36545e55..89a0dccd 100644 --- a/db/dbinfo/note_image.bob.go +++ b/db/dbinfo/note_image.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/note_image_breadcrumb.bob.go b/db/dbinfo/note_image_breadcrumb.bob.go index a7dd7323..7824d997 100644 --- a/db/dbinfo/note_image_breadcrumb.bob.go +++ b/db/dbinfo/note_image_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/note_image_data.bob.go b/db/dbinfo/note_image_data.bob.go index be198b8f..dade46b3 100644 --- a/db/dbinfo/note_image_data.bob.go +++ b/db/dbinfo/note_image_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/notification.bob.go b/db/dbinfo/notification.bob.go index b4869c9a..b405ed17 100644 --- a/db/dbinfo/notification.bob.go +++ b/db/dbinfo/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/oauth_token.bob.go b/db/dbinfo/oauth_token.bob.go index e72e1cb2..e7ae9dcf 100644 --- a/db/dbinfo/oauth_token.bob.go +++ b/db/dbinfo/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/organization.bob.go b/db/dbinfo/organization.bob.go index c65f22a4..3539999d 100644 --- a/db/dbinfo/organization.bob.go +++ b/db/dbinfo/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/publicreport.nuisance.bob.go b/db/dbinfo/publicreport.nuisance.bob.go index 4eef190c..625162eb 100644 --- a/db/dbinfo/publicreport.nuisance.bob.go +++ b/db/dbinfo/publicreport.nuisance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/publicreport.pool.bob.go b/db/dbinfo/publicreport.pool.bob.go index 482e9357..045b24d7 100644 --- a/db/dbinfo/publicreport.pool.bob.go +++ b/db/dbinfo/publicreport.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/publicreport.pool_photo.bob.go b/db/dbinfo/publicreport.pool_photo.bob.go index 8d22839c..8b116463 100644 --- a/db/dbinfo/publicreport.pool_photo.bob.go +++ b/db/dbinfo/publicreport.pool_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/publicreport.quick.bob.go b/db/dbinfo/publicreport.quick.bob.go index eacf3433..77afb678 100644 --- a/db/dbinfo/publicreport.quick.bob.go +++ b/db/dbinfo/publicreport.quick.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/publicreport.quick_photo.bob.go b/db/dbinfo/publicreport.quick_photo.bob.go index 9a7d4eca..f827d142 100644 --- a/db/dbinfo/publicreport.quick_photo.bob.go +++ b/db/dbinfo/publicreport.quick_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/publicreport.report_location.bob.go b/db/dbinfo/publicreport.report_location.bob.go index f59c9427..92fa50fe 100644 --- a/db/dbinfo/publicreport.report_location.bob.go +++ b/db/dbinfo/publicreport.report_location.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/raster_columns.bob.go b/db/dbinfo/raster_columns.bob.go index 485a0e21..a7d56223 100644 --- a/db/dbinfo/raster_columns.bob.go +++ b/db/dbinfo/raster_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/raster_overviews.bob.go b/db/dbinfo/raster_overviews.bob.go index 40e7ff4b..7199817b 100644 --- a/db/dbinfo/raster_overviews.bob.go +++ b/db/dbinfo/raster_overviews.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/sessions.bob.go b/db/dbinfo/sessions.bob.go index 365152f9..4f66b5ce 100644 --- a/db/dbinfo/sessions.bob.go +++ b/db/dbinfo/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/spatial_ref_sys.bob.go b/db/dbinfo/spatial_ref_sys.bob.go index cd06d3f8..78b5a363 100644 --- a/db/dbinfo/spatial_ref_sys.bob.go +++ b/db/dbinfo/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/dbinfo/user_.bob.go b/db/dbinfo/user_.bob.go index 556adb13..b72cfaf4 100644 --- a/db/dbinfo/user_.bob.go +++ b/db/dbinfo/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package dbinfo diff --git a/db/enums/enums.bob.go b/db/enums/enums.bob.go index ff1c3c5b..34c6ec6f 100644 --- a/db/enums/enums.bob.go +++ b/db/enums/enums.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package enums diff --git a/db/factory/arcgis.user_.bob.go b/db/factory/arcgis.user_.bob.go new file mode 100644 index 00000000..43969366 --- /dev/null +++ b/db/factory/arcgis.user_.bob.go @@ -0,0 +1,984 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package factory + +import ( + "context" + "testing" + "time" + + models "github.com/Gleipnir-Technology/nidus-sync/db/models" + "github.com/aarondl/opt/omit" + "github.com/jaswdr/faker/v2" + "github.com/stephenafamo/bob" +) + +type ArcgisUserMod interface { + Apply(context.Context, *ArcgisUserTemplate) +} + +type ArcgisUserModFunc func(context.Context, *ArcgisUserTemplate) + +func (f ArcgisUserModFunc) Apply(ctx context.Context, n *ArcgisUserTemplate) { + f(ctx, n) +} + +type ArcgisUserModSlice []ArcgisUserMod + +func (mods ArcgisUserModSlice) Apply(ctx context.Context, n *ArcgisUserTemplate) { + for _, f := range mods { + f.Apply(ctx, n) + } +} + +// ArcgisUserTemplate is an object representing the database table. +// all columns are optional and should be set by mods +type ArcgisUserTemplate struct { + Access func() string + Created func() time.Time + Email func() string + FullName func() string + ID func() string + Level func() string + OrgID func() string + PublicUserID func() int32 + Region func() string + Role func() string + RoleID func() string + Username func() string + UserLicenseTypeID func() string + UserType func() string + + r arcgisuserR + f *Factory + + alreadyPersisted bool +} + +type arcgisuserR struct { + PublicUserUser *arcgisuserRPublicUserUserR + UserUserPrivileges []*arcgisuserRUserUserPrivilegesR +} + +type arcgisuserRPublicUserUserR struct { + o *UserTemplate +} +type arcgisuserRUserUserPrivilegesR struct { + number int + o *ArcgisUserPrivilegeTemplate +} + +// Apply mods to the ArcgisUserTemplate +func (o *ArcgisUserTemplate) Apply(ctx context.Context, mods ...ArcgisUserMod) { + for _, mod := range mods { + mod.Apply(ctx, o) + } +} + +// setModelRels creates and sets the relationships on *models.ArcgisUser +// according to the relationships in the template. Nothing is inserted into the db +func (t ArcgisUserTemplate) setModelRels(o *models.ArcgisUser) { + if t.r.PublicUserUser != nil { + rel := t.r.PublicUserUser.o.Build() + rel.R.PublicUserUser = append(rel.R.PublicUserUser, o) + o.PublicUserID = rel.ID // h2 + o.R.PublicUserUser = rel + } + + if t.r.UserUserPrivileges != nil { + rel := models.ArcgisUserPrivilegeSlice{} + for _, r := range t.r.UserUserPrivileges { + related := r.o.BuildMany(r.number) + for _, rel := range related { + rel.UserID = o.ID // h2 + rel.R.UserUser = o + } + rel = append(rel, related...) + } + o.R.UserUserPrivileges = rel + } +} + +// BuildSetter returns an *models.ArcgisUserSetter +// this does nothing with the relationship templates +func (o ArcgisUserTemplate) BuildSetter() *models.ArcgisUserSetter { + m := &models.ArcgisUserSetter{} + + if o.Access != nil { + val := o.Access() + m.Access = omit.From(val) + } + if o.Created != nil { + val := o.Created() + m.Created = omit.From(val) + } + if o.Email != nil { + val := o.Email() + m.Email = omit.From(val) + } + if o.FullName != nil { + val := o.FullName() + m.FullName = omit.From(val) + } + if o.ID != nil { + val := o.ID() + m.ID = omit.From(val) + } + if o.Level != nil { + val := o.Level() + m.Level = omit.From(val) + } + if o.OrgID != nil { + val := o.OrgID() + m.OrgID = omit.From(val) + } + if o.PublicUserID != nil { + val := o.PublicUserID() + m.PublicUserID = omit.From(val) + } + if o.Region != nil { + val := o.Region() + m.Region = omit.From(val) + } + if o.Role != nil { + val := o.Role() + m.Role = omit.From(val) + } + if o.RoleID != nil { + val := o.RoleID() + m.RoleID = omit.From(val) + } + if o.Username != nil { + val := o.Username() + m.Username = omit.From(val) + } + if o.UserLicenseTypeID != nil { + val := o.UserLicenseTypeID() + m.UserLicenseTypeID = omit.From(val) + } + if o.UserType != nil { + val := o.UserType() + m.UserType = omit.From(val) + } + + return m +} + +// BuildManySetter returns an []*models.ArcgisUserSetter +// this does nothing with the relationship templates +func (o ArcgisUserTemplate) BuildManySetter(number int) []*models.ArcgisUserSetter { + m := make([]*models.ArcgisUserSetter, number) + + for i := range m { + m[i] = o.BuildSetter() + } + + return m +} + +// Build returns an *models.ArcgisUser +// Related objects are also created and placed in the .R field +// NOTE: Objects are not inserted into the database. Use ArcgisUserTemplate.Create +func (o ArcgisUserTemplate) Build() *models.ArcgisUser { + m := &models.ArcgisUser{} + + if o.Access != nil { + m.Access = o.Access() + } + if o.Created != nil { + m.Created = o.Created() + } + if o.Email != nil { + m.Email = o.Email() + } + if o.FullName != nil { + m.FullName = o.FullName() + } + if o.ID != nil { + m.ID = o.ID() + } + if o.Level != nil { + m.Level = o.Level() + } + if o.OrgID != nil { + m.OrgID = o.OrgID() + } + if o.PublicUserID != nil { + m.PublicUserID = o.PublicUserID() + } + if o.Region != nil { + m.Region = o.Region() + } + if o.Role != nil { + m.Role = o.Role() + } + if o.RoleID != nil { + m.RoleID = o.RoleID() + } + if o.Username != nil { + m.Username = o.Username() + } + if o.UserLicenseTypeID != nil { + m.UserLicenseTypeID = o.UserLicenseTypeID() + } + if o.UserType != nil { + m.UserType = o.UserType() + } + + o.setModelRels(m) + + return m +} + +// BuildMany returns an models.ArcgisUserSlice +// Related objects are also created and placed in the .R field +// NOTE: Objects are not inserted into the database. Use ArcgisUserTemplate.CreateMany +func (o ArcgisUserTemplate) BuildMany(number int) models.ArcgisUserSlice { + m := make(models.ArcgisUserSlice, number) + + for i := range m { + m[i] = o.Build() + } + + return m +} + +func ensureCreatableArcgisUser(m *models.ArcgisUserSetter) { + if !(m.Access.IsValue()) { + val := random_string(nil) + m.Access = omit.From(val) + } + if !(m.Created.IsValue()) { + val := random_time_Time(nil) + m.Created = omit.From(val) + } + if !(m.Email.IsValue()) { + val := random_string(nil) + m.Email = omit.From(val) + } + if !(m.FullName.IsValue()) { + val := random_string(nil) + m.FullName = omit.From(val) + } + if !(m.ID.IsValue()) { + val := random_string(nil) + m.ID = omit.From(val) + } + if !(m.Level.IsValue()) { + val := random_string(nil) + m.Level = omit.From(val) + } + if !(m.OrgID.IsValue()) { + val := random_string(nil) + m.OrgID = omit.From(val) + } + if !(m.PublicUserID.IsValue()) { + val := random_int32(nil) + m.PublicUserID = omit.From(val) + } + if !(m.Region.IsValue()) { + val := random_string(nil) + m.Region = omit.From(val) + } + if !(m.Role.IsValue()) { + val := random_string(nil) + m.Role = omit.From(val) + } + if !(m.RoleID.IsValue()) { + val := random_string(nil) + m.RoleID = omit.From(val) + } + if !(m.Username.IsValue()) { + val := random_string(nil) + m.Username = omit.From(val) + } + if !(m.UserLicenseTypeID.IsValue()) { + val := random_string(nil) + m.UserLicenseTypeID = omit.From(val) + } + if !(m.UserType.IsValue()) { + val := random_string(nil) + m.UserType = omit.From(val) + } +} + +// insertOptRels creates and inserts any optional the relationships on *models.ArcgisUser +// according to the relationships in the template. +// any required relationship should have already exist on the model +func (o *ArcgisUserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ArcgisUser) error { + var err error + + isUserUserPrivilegesDone, _ := arcgisuserRelUserUserPrivilegesCtx.Value(ctx) + if !isUserUserPrivilegesDone && o.r.UserUserPrivileges != nil { + ctx = arcgisuserRelUserUserPrivilegesCtx.WithValue(ctx, true) + for _, r := range o.r.UserUserPrivileges { + if r.o.alreadyPersisted { + m.R.UserUserPrivileges = append(m.R.UserUserPrivileges, r.o.Build()) + } else { + rel1, err := r.o.CreateMany(ctx, exec, r.number) + if err != nil { + return err + } + + err = m.AttachUserUserPrivileges(ctx, exec, rel1...) + if err != nil { + return err + } + } + } + } + + return err +} + +// Create builds a arcgisuser and inserts it into the database +// Relations objects are also inserted and placed in the .R field +func (o *ArcgisUserTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ArcgisUser, error) { + var err error + opt := o.BuildSetter() + ensureCreatableArcgisUser(opt) + + if o.r.PublicUserUser == nil { + ArcgisUserMods.WithNewPublicUserUser().Apply(ctx, o) + } + + var rel0 *models.User + + if o.r.PublicUserUser.o.alreadyPersisted { + rel0 = o.r.PublicUserUser.o.Build() + } else { + rel0, err = o.r.PublicUserUser.o.Create(ctx, exec) + if err != nil { + return nil, err + } + } + + opt.PublicUserID = omit.From(rel0.ID) + + m, err := models.ArcgisUsers.Insert(opt).One(ctx, exec) + if err != nil { + return nil, err + } + + m.R.PublicUserUser = rel0 + + if err := o.insertOptRels(ctx, exec, m); err != nil { + return nil, err + } + return m, err +} + +// MustCreate builds a arcgisuser and inserts it into the database +// Relations objects are also inserted and placed in the .R field +// panics if an error occurs +func (o *ArcgisUserTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ArcgisUser { + m, err := o.Create(ctx, exec) + if err != nil { + panic(err) + } + return m +} + +// CreateOrFail builds a arcgisuser and inserts it into the database +// Relations objects are also inserted and placed in the .R field +// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs +func (o *ArcgisUserTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ArcgisUser { + tb.Helper() + m, err := o.Create(ctx, exec) + if err != nil { + tb.Fatal(err) + return nil + } + return m +} + +// CreateMany builds multiple arcgisusers and inserts them into the database +// Relations objects are also inserted and placed in the .R field +func (o ArcgisUserTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ArcgisUserSlice, error) { + var err error + m := make(models.ArcgisUserSlice, number) + + for i := range m { + m[i], err = o.Create(ctx, exec) + if err != nil { + return nil, err + } + } + + return m, nil +} + +// MustCreateMany builds multiple arcgisusers and inserts them into the database +// Relations objects are also inserted and placed in the .R field +// panics if an error occurs +func (o ArcgisUserTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ArcgisUserSlice { + m, err := o.CreateMany(ctx, exec, number) + if err != nil { + panic(err) + } + return m +} + +// CreateManyOrFail builds multiple arcgisusers and inserts them into the database +// Relations objects are also inserted and placed in the .R field +// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs +func (o ArcgisUserTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ArcgisUserSlice { + tb.Helper() + m, err := o.CreateMany(ctx, exec, number) + if err != nil { + tb.Fatal(err) + return nil + } + return m +} + +// ArcgisUser has methods that act as mods for the ArcgisUserTemplate +var ArcgisUserMods arcgisuserMods + +type arcgisuserMods struct{} + +func (m arcgisuserMods) RandomizeAllColumns(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModSlice{ + ArcgisUserMods.RandomAccess(f), + ArcgisUserMods.RandomCreated(f), + ArcgisUserMods.RandomEmail(f), + ArcgisUserMods.RandomFullName(f), + ArcgisUserMods.RandomID(f), + ArcgisUserMods.RandomLevel(f), + ArcgisUserMods.RandomOrgID(f), + ArcgisUserMods.RandomPublicUserID(f), + ArcgisUserMods.RandomRegion(f), + ArcgisUserMods.RandomRole(f), + ArcgisUserMods.RandomRoleID(f), + ArcgisUserMods.RandomUsername(f), + ArcgisUserMods.RandomUserLicenseTypeID(f), + ArcgisUserMods.RandomUserType(f), + } +} + +// Set the model columns to this value +func (m arcgisuserMods) Access(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Access = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) AccessFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Access = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetAccess() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Access = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomAccess(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Access = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) Created(val time.Time) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Created = func() time.Time { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) CreatedFunc(f func() time.Time) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Created = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetCreated() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Created = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomCreated(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Created = func() time.Time { + return random_time_Time(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) Email(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Email = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) EmailFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Email = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetEmail() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Email = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomEmail(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Email = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) FullName(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.FullName = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) FullNameFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.FullName = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetFullName() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.FullName = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomFullName(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.FullName = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) ID(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.ID = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) IDFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.ID = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetID() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.ID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomID(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.ID = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) Level(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Level = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) LevelFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Level = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetLevel() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Level = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomLevel(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Level = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) OrgID(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.OrgID = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) OrgIDFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.OrgID = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetOrgID() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.OrgID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomOrgID(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.OrgID = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) PublicUserID(val int32) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.PublicUserID = func() int32 { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) PublicUserIDFunc(f func() int32) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.PublicUserID = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetPublicUserID() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.PublicUserID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomPublicUserID(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.PublicUserID = func() int32 { + return random_int32(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) Region(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Region = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) RegionFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Region = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetRegion() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Region = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomRegion(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Region = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) Role(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Role = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) RoleFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Role = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetRole() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Role = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomRole(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Role = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) RoleID(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.RoleID = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) RoleIDFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.RoleID = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetRoleID() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.RoleID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomRoleID(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.RoleID = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) Username(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Username = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) UsernameFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Username = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetUsername() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Username = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomUsername(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.Username = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) UserLicenseTypeID(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserLicenseTypeID = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) UserLicenseTypeIDFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserLicenseTypeID = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetUserLicenseTypeID() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserLicenseTypeID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomUserLicenseTypeID(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserLicenseTypeID = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisuserMods) UserType(val string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserType = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisuserMods) UserTypeFunc(f func() string) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserType = f + }) +} + +// Clear any values for the column +func (m arcgisuserMods) UnsetUserType() ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserType = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisuserMods) RandomUserType(f *faker.Faker) ArcgisUserMod { + return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) { + o.UserType = func() string { + return random_string(f) + } + }) +} + +func (m arcgisuserMods) WithParentsCascading() ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + if isDone, _ := arcgisuserWithParentsCascadingCtx.Value(ctx); isDone { + return + } + ctx = arcgisuserWithParentsCascadingCtx.WithValue(ctx, true) + { + + related := o.f.NewUserWithContext(ctx, UserMods.WithParentsCascading()) + m.WithPublicUserUser(related).Apply(ctx, o) + } + }) +} + +func (m arcgisuserMods) WithPublicUserUser(rel *UserTemplate) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + o.r.PublicUserUser = &arcgisuserRPublicUserUserR{ + o: rel, + } + }) +} + +func (m arcgisuserMods) WithNewPublicUserUser(mods ...UserMod) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + related := o.f.NewUserWithContext(ctx, mods...) + + m.WithPublicUserUser(related).Apply(ctx, o) + }) +} + +func (m arcgisuserMods) WithExistingPublicUserUser(em *models.User) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + o.r.PublicUserUser = &arcgisuserRPublicUserUserR{ + o: o.f.FromExistingUser(em), + } + }) +} + +func (m arcgisuserMods) WithoutPublicUserUser() ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + o.r.PublicUserUser = nil + }) +} + +func (m arcgisuserMods) WithUserUserPrivileges(number int, related *ArcgisUserPrivilegeTemplate) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + o.r.UserUserPrivileges = []*arcgisuserRUserUserPrivilegesR{{ + number: number, + o: related, + }} + }) +} + +func (m arcgisuserMods) WithNewUserUserPrivileges(number int, mods ...ArcgisUserPrivilegeMod) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + related := o.f.NewArcgisUserPrivilegeWithContext(ctx, mods...) + m.WithUserUserPrivileges(number, related).Apply(ctx, o) + }) +} + +func (m arcgisuserMods) AddUserUserPrivileges(number int, related *ArcgisUserPrivilegeTemplate) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + o.r.UserUserPrivileges = append(o.r.UserUserPrivileges, &arcgisuserRUserUserPrivilegesR{ + number: number, + o: related, + }) + }) +} + +func (m arcgisuserMods) AddNewUserUserPrivileges(number int, mods ...ArcgisUserPrivilegeMod) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + related := o.f.NewArcgisUserPrivilegeWithContext(ctx, mods...) + m.AddUserUserPrivileges(number, related).Apply(ctx, o) + }) +} + +func (m arcgisuserMods) AddExistingUserUserPrivileges(existingModels ...*models.ArcgisUserPrivilege) ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + for _, em := range existingModels { + o.r.UserUserPrivileges = append(o.r.UserUserPrivileges, &arcgisuserRUserUserPrivilegesR{ + o: o.f.FromExistingArcgisUserPrivilege(em), + }) + } + }) +} + +func (m arcgisuserMods) WithoutUserUserPrivileges() ArcgisUserMod { + return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) { + o.r.UserUserPrivileges = nil + }) +} diff --git a/db/factory/arcgis.user_privilege.bob.go b/db/factory/arcgis.user_privilege.bob.go new file mode 100644 index 00000000..37ed5e39 --- /dev/null +++ b/db/factory/arcgis.user_privilege.bob.go @@ -0,0 +1,369 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package factory + +import ( + "context" + "testing" + + models "github.com/Gleipnir-Technology/nidus-sync/db/models" + "github.com/aarondl/opt/omit" + "github.com/jaswdr/faker/v2" + "github.com/stephenafamo/bob" +) + +type ArcgisUserPrivilegeMod interface { + Apply(context.Context, *ArcgisUserPrivilegeTemplate) +} + +type ArcgisUserPrivilegeModFunc func(context.Context, *ArcgisUserPrivilegeTemplate) + +func (f ArcgisUserPrivilegeModFunc) Apply(ctx context.Context, n *ArcgisUserPrivilegeTemplate) { + f(ctx, n) +} + +type ArcgisUserPrivilegeModSlice []ArcgisUserPrivilegeMod + +func (mods ArcgisUserPrivilegeModSlice) Apply(ctx context.Context, n *ArcgisUserPrivilegeTemplate) { + for _, f := range mods { + f.Apply(ctx, n) + } +} + +// ArcgisUserPrivilegeTemplate is an object representing the database table. +// all columns are optional and should be set by mods +type ArcgisUserPrivilegeTemplate struct { + UserID func() string + Privilege func() string + + r arcgisUserPrivilegeR + f *Factory + + alreadyPersisted bool +} + +type arcgisUserPrivilegeR struct { + UserUser *arcgisUserPrivilegeRUserUserR +} + +type arcgisUserPrivilegeRUserUserR struct { + o *ArcgisUserTemplate +} + +// Apply mods to the ArcgisUserPrivilegeTemplate +func (o *ArcgisUserPrivilegeTemplate) Apply(ctx context.Context, mods ...ArcgisUserPrivilegeMod) { + for _, mod := range mods { + mod.Apply(ctx, o) + } +} + +// setModelRels creates and sets the relationships on *models.ArcgisUserPrivilege +// according to the relationships in the template. Nothing is inserted into the db +func (t ArcgisUserPrivilegeTemplate) setModelRels(o *models.ArcgisUserPrivilege) { + if t.r.UserUser != nil { + rel := t.r.UserUser.o.Build() + rel.R.UserUserPrivileges = append(rel.R.UserUserPrivileges, o) + o.UserID = rel.ID // h2 + o.R.UserUser = rel + } +} + +// BuildSetter returns an *models.ArcgisUserPrivilegeSetter +// this does nothing with the relationship templates +func (o ArcgisUserPrivilegeTemplate) BuildSetter() *models.ArcgisUserPrivilegeSetter { + m := &models.ArcgisUserPrivilegeSetter{} + + if o.UserID != nil { + val := o.UserID() + m.UserID = omit.From(val) + } + if o.Privilege != nil { + val := o.Privilege() + m.Privilege = omit.From(val) + } + + return m +} + +// BuildManySetter returns an []*models.ArcgisUserPrivilegeSetter +// this does nothing with the relationship templates +func (o ArcgisUserPrivilegeTemplate) BuildManySetter(number int) []*models.ArcgisUserPrivilegeSetter { + m := make([]*models.ArcgisUserPrivilegeSetter, number) + + for i := range m { + m[i] = o.BuildSetter() + } + + return m +} + +// Build returns an *models.ArcgisUserPrivilege +// Related objects are also created and placed in the .R field +// NOTE: Objects are not inserted into the database. Use ArcgisUserPrivilegeTemplate.Create +func (o ArcgisUserPrivilegeTemplate) Build() *models.ArcgisUserPrivilege { + m := &models.ArcgisUserPrivilege{} + + if o.UserID != nil { + m.UserID = o.UserID() + } + if o.Privilege != nil { + m.Privilege = o.Privilege() + } + + o.setModelRels(m) + + return m +} + +// BuildMany returns an models.ArcgisUserPrivilegeSlice +// Related objects are also created and placed in the .R field +// NOTE: Objects are not inserted into the database. Use ArcgisUserPrivilegeTemplate.CreateMany +func (o ArcgisUserPrivilegeTemplate) BuildMany(number int) models.ArcgisUserPrivilegeSlice { + m := make(models.ArcgisUserPrivilegeSlice, number) + + for i := range m { + m[i] = o.Build() + } + + return m +} + +func ensureCreatableArcgisUserPrivilege(m *models.ArcgisUserPrivilegeSetter) { + if !(m.UserID.IsValue()) { + val := random_string(nil) + m.UserID = omit.From(val) + } + if !(m.Privilege.IsValue()) { + val := random_string(nil) + m.Privilege = omit.From(val) + } +} + +// insertOptRels creates and inserts any optional the relationships on *models.ArcgisUserPrivilege +// according to the relationships in the template. +// any required relationship should have already exist on the model +func (o *ArcgisUserPrivilegeTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ArcgisUserPrivilege) error { + var err error + + return err +} + +// Create builds a arcgisUserPrivilege and inserts it into the database +// Relations objects are also inserted and placed in the .R field +func (o *ArcgisUserPrivilegeTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ArcgisUserPrivilege, error) { + var err error + opt := o.BuildSetter() + ensureCreatableArcgisUserPrivilege(opt) + + if o.r.UserUser == nil { + ArcgisUserPrivilegeMods.WithNewUserUser().Apply(ctx, o) + } + + var rel0 *models.ArcgisUser + + if o.r.UserUser.o.alreadyPersisted { + rel0 = o.r.UserUser.o.Build() + } else { + rel0, err = o.r.UserUser.o.Create(ctx, exec) + if err != nil { + return nil, err + } + } + + opt.UserID = omit.From(rel0.ID) + + m, err := models.ArcgisUserPrivileges.Insert(opt).One(ctx, exec) + if err != nil { + return nil, err + } + + m.R.UserUser = rel0 + + if err := o.insertOptRels(ctx, exec, m); err != nil { + return nil, err + } + return m, err +} + +// MustCreate builds a arcgisUserPrivilege and inserts it into the database +// Relations objects are also inserted and placed in the .R field +// panics if an error occurs +func (o *ArcgisUserPrivilegeTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ArcgisUserPrivilege { + m, err := o.Create(ctx, exec) + if err != nil { + panic(err) + } + return m +} + +// CreateOrFail builds a arcgisUserPrivilege and inserts it into the database +// Relations objects are also inserted and placed in the .R field +// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs +func (o *ArcgisUserPrivilegeTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ArcgisUserPrivilege { + tb.Helper() + m, err := o.Create(ctx, exec) + if err != nil { + tb.Fatal(err) + return nil + } + return m +} + +// CreateMany builds multiple arcgisUserPrivileges and inserts them into the database +// Relations objects are also inserted and placed in the .R field +func (o ArcgisUserPrivilegeTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ArcgisUserPrivilegeSlice, error) { + var err error + m := make(models.ArcgisUserPrivilegeSlice, number) + + for i := range m { + m[i], err = o.Create(ctx, exec) + if err != nil { + return nil, err + } + } + + return m, nil +} + +// MustCreateMany builds multiple arcgisUserPrivileges and inserts them into the database +// Relations objects are also inserted and placed in the .R field +// panics if an error occurs +func (o ArcgisUserPrivilegeTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ArcgisUserPrivilegeSlice { + m, err := o.CreateMany(ctx, exec, number) + if err != nil { + panic(err) + } + return m +} + +// CreateManyOrFail builds multiple arcgisUserPrivileges and inserts them into the database +// Relations objects are also inserted and placed in the .R field +// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs +func (o ArcgisUserPrivilegeTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ArcgisUserPrivilegeSlice { + tb.Helper() + m, err := o.CreateMany(ctx, exec, number) + if err != nil { + tb.Fatal(err) + return nil + } + return m +} + +// ArcgisUserPrivilege has methods that act as mods for the ArcgisUserPrivilegeTemplate +var ArcgisUserPrivilegeMods arcgisUserPrivilegeMods + +type arcgisUserPrivilegeMods struct{} + +func (m arcgisUserPrivilegeMods) RandomizeAllColumns(f *faker.Faker) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModSlice{ + ArcgisUserPrivilegeMods.RandomUserID(f), + ArcgisUserPrivilegeMods.RandomPrivilege(f), + } +} + +// Set the model columns to this value +func (m arcgisUserPrivilegeMods) UserID(val string) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.UserID = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisUserPrivilegeMods) UserIDFunc(f func() string) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.UserID = f + }) +} + +// Clear any values for the column +func (m arcgisUserPrivilegeMods) UnsetUserID() ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.UserID = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisUserPrivilegeMods) RandomUserID(f *faker.Faker) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.UserID = func() string { + return random_string(f) + } + }) +} + +// Set the model columns to this value +func (m arcgisUserPrivilegeMods) Privilege(val string) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.Privilege = func() string { return val } + }) +} + +// Set the Column from the function +func (m arcgisUserPrivilegeMods) PrivilegeFunc(f func() string) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.Privilege = f + }) +} + +// Clear any values for the column +func (m arcgisUserPrivilegeMods) UnsetPrivilege() ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.Privilege = nil + }) +} + +// Generates a random value for the column using the given faker +// if faker is nil, a default faker is used +func (m arcgisUserPrivilegeMods) RandomPrivilege(f *faker.Faker) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) { + o.Privilege = func() string { + return random_string(f) + } + }) +} + +func (m arcgisUserPrivilegeMods) WithParentsCascading() ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) { + if isDone, _ := arcgisUserPrivilegeWithParentsCascadingCtx.Value(ctx); isDone { + return + } + ctx = arcgisUserPrivilegeWithParentsCascadingCtx.WithValue(ctx, true) + { + + related := o.f.NewArcgisUserWithContext(ctx, ArcgisUserMods.WithParentsCascading()) + m.WithUserUser(related).Apply(ctx, o) + } + }) +} + +func (m arcgisUserPrivilegeMods) WithUserUser(rel *ArcgisUserTemplate) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) { + o.r.UserUser = &arcgisUserPrivilegeRUserUserR{ + o: rel, + } + }) +} + +func (m arcgisUserPrivilegeMods) WithNewUserUser(mods ...ArcgisUserMod) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) { + related := o.f.NewArcgisUserWithContext(ctx, mods...) + + m.WithUserUser(related).Apply(ctx, o) + }) +} + +func (m arcgisUserPrivilegeMods) WithExistingUserUser(em *models.ArcgisUser) ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) { + o.r.UserUser = &arcgisUserPrivilegeRUserUserR{ + o: o.f.FromExistingArcgisUser(em), + } + }) +} + +func (m arcgisUserPrivilegeMods) WithoutUserUser() ArcgisUserPrivilegeMod { + return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) { + o.r.UserUser = nil + }) +} diff --git a/db/factory/bobfactory_context.bob.go b/db/factory/bobfactory_context.bob.go index 0f3fa16f..f584a12c 100644 --- a/db/factory/bobfactory_context.bob.go +++ b/db/factory/bobfactory_context.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -8,6 +8,15 @@ import "context" type contextKey string var ( + // Relationship Contexts for arcgis.user_ + arcgisuserWithParentsCascadingCtx = newContextual[bool]("arcgisuserWithParentsCascading") + arcgisuserRelPublicUserUserCtx = newContextual[bool]("arcgis.user_.user_.arcgis.user_.user__public_user_id_fkey") + arcgisuserRelUserUserPrivilegesCtx = newContextual[bool]("arcgis.user_.arcgis.user_privilege.arcgis.user_privilege.user_privilege_user_id_fkey") + + // Relationship Contexts for arcgis.user_privilege + arcgisUserPrivilegeWithParentsCascadingCtx = newContextual[bool]("arcgisUserPrivilegeWithParentsCascading") + arcgisUserPrivilegeRelUserUserCtx = newContextual[bool]("arcgis.user_.arcgis.user_privilege.arcgis.user_privilege.user_privilege_user_id_fkey") + // Relationship Contexts for district districtWithParentsCascadingCtx = newContextual[bool]("districtWithParentsCascading") @@ -247,6 +256,7 @@ var ( // Relationship Contexts for user_ userWithParentsCascadingCtx = newContextual[bool]("userWithParentsCascading") + userRelPublicUserUserCtx = newContextual[bool]("arcgis.user_.user_.arcgis.user_.user__public_user_id_fkey") userRelCreatorNoteAudiosCtx = newContextual[bool]("note_audio.user_.note_audio.note_audio_creator_id_fkey") userRelDeletorNoteAudiosCtx = newContextual[bool]("note_audio.user_.note_audio.note_audio_deletor_id_fkey") userRelCreatorNoteImagesCtx = newContextual[bool]("note_image.user_.note_image.note_image_creator_id_fkey") diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go index cae5658a..17d49c70 100644 --- a/db/factory/bobfactory_main.bob.go +++ b/db/factory/bobfactory_main.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -18,6 +18,8 @@ import ( ) type Factory struct { + baseArcgisUserMods ArcgisUserModSlice + baseArcgisUserPrivilegeMods ArcgisUserPrivilegeModSlice baseDistrictMods DistrictModSlice baseFieldseekerContainerrelateMods FieldseekerContainerrelateModSlice baseFieldseekerFieldscoutinglogMods FieldseekerFieldscoutinglogModSlice @@ -77,6 +79,81 @@ func New() *Factory { return &Factory{} } +func (f *Factory) NewArcgisUser(mods ...ArcgisUserMod) *ArcgisUserTemplate { + return f.NewArcgisUserWithContext(context.Background(), mods...) +} + +func (f *Factory) NewArcgisUserWithContext(ctx context.Context, mods ...ArcgisUserMod) *ArcgisUserTemplate { + o := &ArcgisUserTemplate{f: f} + + if f != nil { + f.baseArcgisUserMods.Apply(ctx, o) + } + + ArcgisUserModSlice(mods).Apply(ctx, o) + + return o +} + +func (f *Factory) FromExistingArcgisUser(m *models.ArcgisUser) *ArcgisUserTemplate { + o := &ArcgisUserTemplate{f: f, alreadyPersisted: true} + + o.Access = func() string { return m.Access } + o.Created = func() time.Time { return m.Created } + o.Email = func() string { return m.Email } + o.FullName = func() string { return m.FullName } + o.ID = func() string { return m.ID } + o.Level = func() string { return m.Level } + o.OrgID = func() string { return m.OrgID } + o.PublicUserID = func() int32 { return m.PublicUserID } + o.Region = func() string { return m.Region } + o.Role = func() string { return m.Role } + o.RoleID = func() string { return m.RoleID } + o.Username = func() string { return m.Username } + o.UserLicenseTypeID = func() string { return m.UserLicenseTypeID } + o.UserType = func() string { return m.UserType } + + ctx := context.Background() + if m.R.PublicUserUser != nil { + ArcgisUserMods.WithExistingPublicUserUser(m.R.PublicUserUser).Apply(ctx, o) + } + if len(m.R.UserUserPrivileges) > 0 { + ArcgisUserMods.AddExistingUserUserPrivileges(m.R.UserUserPrivileges...).Apply(ctx, o) + } + + return o +} + +func (f *Factory) NewArcgisUserPrivilege(mods ...ArcgisUserPrivilegeMod) *ArcgisUserPrivilegeTemplate { + return f.NewArcgisUserPrivilegeWithContext(context.Background(), mods...) +} + +func (f *Factory) NewArcgisUserPrivilegeWithContext(ctx context.Context, mods ...ArcgisUserPrivilegeMod) *ArcgisUserPrivilegeTemplate { + o := &ArcgisUserPrivilegeTemplate{f: f} + + if f != nil { + f.baseArcgisUserPrivilegeMods.Apply(ctx, o) + } + + ArcgisUserPrivilegeModSlice(mods).Apply(ctx, o) + + return o +} + +func (f *Factory) FromExistingArcgisUserPrivilege(m *models.ArcgisUserPrivilege) *ArcgisUserPrivilegeTemplate { + o := &ArcgisUserPrivilegeTemplate{f: f, alreadyPersisted: true} + + o.UserID = func() string { return m.UserID } + o.Privilege = func() string { return m.Privilege } + + ctx := context.Background() + if m.R.UserUser != nil { + ArcgisUserPrivilegeMods.WithExistingUserUser(m.R.UserUser).Apply(ctx, o) + } + + return o +} + func (f *Factory) NewDistrict(mods ...DistrictMod) *DistrictTemplate { return f.NewDistrictWithContext(context.Background(), mods...) } @@ -2825,6 +2902,9 @@ func (f *Factory) FromExistingUser(m *models.User) *UserTemplate { o.PasswordHash = func() string { return m.PasswordHash } ctx := context.Background() + if len(m.R.PublicUserUser) > 0 { + UserMods.AddExistingPublicUserUser(m.R.PublicUserUser...).Apply(ctx, o) + } if len(m.R.CreatorNoteAudios) > 0 { UserMods.AddExistingCreatorNoteAudios(m.R.CreatorNoteAudios...).Apply(ctx, o) } @@ -2850,6 +2930,22 @@ func (f *Factory) FromExistingUser(m *models.User) *UserTemplate { return o } +func (f *Factory) ClearBaseArcgisUserMods() { + f.baseArcgisUserMods = nil +} + +func (f *Factory) AddBaseArcgisUserMod(mods ...ArcgisUserMod) { + f.baseArcgisUserMods = append(f.baseArcgisUserMods, mods...) +} + +func (f *Factory) ClearBaseArcgisUserPrivilegeMods() { + f.baseArcgisUserPrivilegeMods = nil +} + +func (f *Factory) AddBaseArcgisUserPrivilegeMod(mods ...ArcgisUserPrivilegeMod) { + f.baseArcgisUserPrivilegeMods = append(f.baseArcgisUserPrivilegeMods, mods...) +} + func (f *Factory) ClearBaseDistrictMods() { f.baseDistrictMods = nil } diff --git a/db/factory/bobfactory_random.bob.go b/db/factory/bobfactory_random.bob.go index abb5ef00..0f93c1ad 100644 --- a/db/factory/bobfactory_random.bob.go +++ b/db/factory/bobfactory_random.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/district.bob.go b/db/factory/district.bob.go index 4a25435f..fd5944c4 100644 --- a/db/factory/district.bob.go +++ b/db/factory/district.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.containerrelate.bob.go b/db/factory/fieldseeker.containerrelate.bob.go index 8a1a3613..31dbc2be 100644 --- a/db/factory/fieldseeker.containerrelate.bob.go +++ b/db/factory/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.fieldscoutinglog.bob.go b/db/factory/fieldseeker.fieldscoutinglog.bob.go index e688ab28..ac7f0351 100644 --- a/db/factory/fieldseeker.fieldscoutinglog.bob.go +++ b/db/factory/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.habitatrelate.bob.go b/db/factory/fieldseeker.habitatrelate.bob.go index bbf2eaef..863ee087 100644 --- a/db/factory/fieldseeker.habitatrelate.bob.go +++ b/db/factory/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.inspectionsample.bob.go b/db/factory/fieldseeker.inspectionsample.bob.go index 3306127e..75993f79 100644 --- a/db/factory/fieldseeker.inspectionsample.bob.go +++ b/db/factory/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.inspectionsampledetail.bob.go b/db/factory/fieldseeker.inspectionsampledetail.bob.go index 006b3dd3..53e60c10 100644 --- a/db/factory/fieldseeker.inspectionsampledetail.bob.go +++ b/db/factory/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.linelocation.bob.go b/db/factory/fieldseeker.linelocation.bob.go index 06e2dd00..4cd24b90 100644 --- a/db/factory/fieldseeker.linelocation.bob.go +++ b/db/factory/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.locationtracking.bob.go b/db/factory/fieldseeker.locationtracking.bob.go index 02742246..a258b8a1 100644 --- a/db/factory/fieldseeker.locationtracking.bob.go +++ b/db/factory/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.mosquitoinspection.bob.go b/db/factory/fieldseeker.mosquitoinspection.bob.go index 3f5e6093..fa9c480a 100644 --- a/db/factory/fieldseeker.mosquitoinspection.bob.go +++ b/db/factory/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.pointlocation.bob.go b/db/factory/fieldseeker.pointlocation.bob.go index 55faf410..01cf29b0 100644 --- a/db/factory/fieldseeker.pointlocation.bob.go +++ b/db/factory/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.polygonlocation.bob.go b/db/factory/fieldseeker.polygonlocation.bob.go index 7f6485f8..7def30d7 100644 --- a/db/factory/fieldseeker.polygonlocation.bob.go +++ b/db/factory/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.pool.bob.go b/db/factory/fieldseeker.pool.bob.go index 1ffac53a..322b8bcd 100644 --- a/db/factory/fieldseeker.pool.bob.go +++ b/db/factory/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.pooldetail.bob.go b/db/factory/fieldseeker.pooldetail.bob.go index 22cb2ca4..c4978b51 100644 --- a/db/factory/fieldseeker.pooldetail.bob.go +++ b/db/factory/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.proposedtreatmentarea.bob.go b/db/factory/fieldseeker.proposedtreatmentarea.bob.go index 1bf811dd..a9dd58c6 100644 --- a/db/factory/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/factory/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.qamosquitoinspection.bob.go b/db/factory/fieldseeker.qamosquitoinspection.bob.go index bf8ea348..cabb9b45 100644 --- a/db/factory/fieldseeker.qamosquitoinspection.bob.go +++ b/db/factory/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.rodentlocation.bob.go b/db/factory/fieldseeker.rodentlocation.bob.go index 63871fcd..4911723e 100644 --- a/db/factory/fieldseeker.rodentlocation.bob.go +++ b/db/factory/fieldseeker.rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.samplecollection.bob.go b/db/factory/fieldseeker.samplecollection.bob.go index 9ce1f745..29e18a7d 100644 --- a/db/factory/fieldseeker.samplecollection.bob.go +++ b/db/factory/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.samplelocation.bob.go b/db/factory/fieldseeker.samplelocation.bob.go index 85d1ece6..bc41d319 100644 --- a/db/factory/fieldseeker.samplelocation.bob.go +++ b/db/factory/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.servicerequest.bob.go b/db/factory/fieldseeker.servicerequest.bob.go index 0ce06a72..4a69b438 100644 --- a/db/factory/fieldseeker.servicerequest.bob.go +++ b/db/factory/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.speciesabundance.bob.go b/db/factory/fieldseeker.speciesabundance.bob.go index 18fea4e5..efafd1fe 100644 --- a/db/factory/fieldseeker.speciesabundance.bob.go +++ b/db/factory/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.stormdrain.bob.go b/db/factory/fieldseeker.stormdrain.bob.go index 3b1caa24..bb3fdca3 100644 --- a/db/factory/fieldseeker.stormdrain.bob.go +++ b/db/factory/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.timecard.bob.go b/db/factory/fieldseeker.timecard.bob.go index 5001368d..fa18147b 100644 --- a/db/factory/fieldseeker.timecard.bob.go +++ b/db/factory/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.trapdata.bob.go b/db/factory/fieldseeker.trapdata.bob.go index aa03e598..649b359f 100644 --- a/db/factory/fieldseeker.trapdata.bob.go +++ b/db/factory/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.traplocation.bob.go b/db/factory/fieldseeker.traplocation.bob.go index b2699c74..621c0929 100644 --- a/db/factory/fieldseeker.traplocation.bob.go +++ b/db/factory/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.treatment.bob.go b/db/factory/fieldseeker.treatment.bob.go index 99e0a3bf..dadf53bd 100644 --- a/db/factory/fieldseeker.treatment.bob.go +++ b/db/factory/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.treatmentarea.bob.go b/db/factory/fieldseeker.treatmentarea.bob.go index 9f48e08a..2290a138 100644 --- a/db/factory/fieldseeker.treatmentarea.bob.go +++ b/db/factory/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.zones.bob.go b/db/factory/fieldseeker.zones.bob.go index e733cca5..1e6fab87 100644 --- a/db/factory/fieldseeker.zones.bob.go +++ b/db/factory/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker.zones2.bob.go b/db/factory/fieldseeker.zones2.bob.go index 2d383f58..9cf78520 100644 --- a/db/factory/fieldseeker.zones2.bob.go +++ b/db/factory/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/fieldseeker_sync.bob.go b/db/factory/fieldseeker_sync.bob.go index 1e4eb34c..2358f34a 100644 --- a/db/factory/fieldseeker_sync.bob.go +++ b/db/factory/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/geography_columns.bob.go b/db/factory/geography_columns.bob.go index ae74519b..16709713 100644 --- a/db/factory/geography_columns.bob.go +++ b/db/factory/geography_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/geometry_columns.bob.go b/db/factory/geometry_columns.bob.go index f493872e..63c97d2a 100644 --- a/db/factory/geometry_columns.bob.go +++ b/db/factory/geometry_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/goose_db_version.bob.go b/db/factory/goose_db_version.bob.go index 68bc4aea..581502cb 100644 --- a/db/factory/goose_db_version.bob.go +++ b/db/factory/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/h3_aggregation.bob.go b/db/factory/h3_aggregation.bob.go index ea3b03db..5977ac04 100644 --- a/db/factory/h3_aggregation.bob.go +++ b/db/factory/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/note_audio.bob.go b/db/factory/note_audio.bob.go index e3a9620a..557894ba 100644 --- a/db/factory/note_audio.bob.go +++ b/db/factory/note_audio.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/note_audio_breadcrumb.bob.go b/db/factory/note_audio_breadcrumb.bob.go index 3abf3eef..b4a8c8a2 100644 --- a/db/factory/note_audio_breadcrumb.bob.go +++ b/db/factory/note_audio_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/note_audio_data.bob.go b/db/factory/note_audio_data.bob.go index cd6578e6..3030278b 100644 --- a/db/factory/note_audio_data.bob.go +++ b/db/factory/note_audio_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/note_image.bob.go b/db/factory/note_image.bob.go index a79ca241..53cc85cf 100644 --- a/db/factory/note_image.bob.go +++ b/db/factory/note_image.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/note_image_breadcrumb.bob.go b/db/factory/note_image_breadcrumb.bob.go index ed0ae5e7..31cb44f6 100644 --- a/db/factory/note_image_breadcrumb.bob.go +++ b/db/factory/note_image_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/note_image_data.bob.go b/db/factory/note_image_data.bob.go index 3b79cc04..dc8350ce 100644 --- a/db/factory/note_image_data.bob.go +++ b/db/factory/note_image_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/notification.bob.go b/db/factory/notification.bob.go index 42b1912e..9b34b0c7 100644 --- a/db/factory/notification.bob.go +++ b/db/factory/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/oauth_token.bob.go b/db/factory/oauth_token.bob.go index fbe69c7a..12ef5b67 100644 --- a/db/factory/oauth_token.bob.go +++ b/db/factory/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/organization.bob.go b/db/factory/organization.bob.go index f7567bd7..73aa2bed 100644 --- a/db/factory/organization.bob.go +++ b/db/factory/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/publicreport.nuisance.bob.go b/db/factory/publicreport.nuisance.bob.go index 022ef0ea..3590e4e1 100644 --- a/db/factory/publicreport.nuisance.bob.go +++ b/db/factory/publicreport.nuisance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/publicreport.pool.bob.go b/db/factory/publicreport.pool.bob.go index f5184a82..d35ac5c2 100644 --- a/db/factory/publicreport.pool.bob.go +++ b/db/factory/publicreport.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/publicreport.pool_photo.bob.go b/db/factory/publicreport.pool_photo.bob.go index a0a289d0..d41bd538 100644 --- a/db/factory/publicreport.pool_photo.bob.go +++ b/db/factory/publicreport.pool_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/publicreport.quick.bob.go b/db/factory/publicreport.quick.bob.go index 85b456d4..95a66d3a 100644 --- a/db/factory/publicreport.quick.bob.go +++ b/db/factory/publicreport.quick.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/publicreport.quick_photo.bob.go b/db/factory/publicreport.quick_photo.bob.go index 39b70215..4bd2bfb9 100644 --- a/db/factory/publicreport.quick_photo.bob.go +++ b/db/factory/publicreport.quick_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/publicreport.report_location.bob.go b/db/factory/publicreport.report_location.bob.go index a7ff64c2..2b1dac21 100644 --- a/db/factory/publicreport.report_location.bob.go +++ b/db/factory/publicreport.report_location.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/raster_columns.bob.go b/db/factory/raster_columns.bob.go index ca6ca8d8..bd01e09e 100644 --- a/db/factory/raster_columns.bob.go +++ b/db/factory/raster_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/raster_overviews.bob.go b/db/factory/raster_overviews.bob.go index ba9c8a89..3d7f41da 100644 --- a/db/factory/raster_overviews.bob.go +++ b/db/factory/raster_overviews.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/sessions.bob.go b/db/factory/sessions.bob.go index d5293505..d0148f28 100644 --- a/db/factory/sessions.bob.go +++ b/db/factory/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/spatial_ref_sys.bob.go b/db/factory/spatial_ref_sys.bob.go index 448a30ff..8eeff8fa 100644 --- a/db/factory/spatial_ref_sys.bob.go +++ b/db/factory/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory diff --git a/db/factory/user_.bob.go b/db/factory/user_.bob.go index 6425b915..0bfd18f8 100644 --- a/db/factory/user_.bob.go +++ b/db/factory/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package factory @@ -58,6 +58,7 @@ type UserTemplate struct { } type userR struct { + PublicUserUser []*userRPublicUserUserR CreatorNoteAudios []*userRCreatorNoteAudiosR DeletorNoteAudios []*userRDeletorNoteAudiosR CreatorNoteImages []*userRCreatorNoteImagesR @@ -67,6 +68,10 @@ type userR struct { Organization *userROrganizationR } +type userRPublicUserUserR struct { + number int + o *ArcgisUserTemplate +} type userRCreatorNoteAudiosR struct { number int o *NoteAudioTemplate @@ -105,6 +110,19 @@ func (o *UserTemplate) Apply(ctx context.Context, mods ...UserMod) { // setModelRels creates and sets the relationships on *models.User // according to the relationships in the template. Nothing is inserted into the db func (t UserTemplate) setModelRels(o *models.User) { + if t.r.PublicUserUser != nil { + rel := models.ArcgisUserSlice{} + for _, r := range t.r.PublicUserUser { + related := r.o.BuildMany(r.number) + for _, rel := range related { + rel.PublicUserID = o.ID // h2 + rel.R.PublicUserUser = o + } + rel = append(rel, related...) + } + o.R.PublicUserUser = rel + } + if t.r.CreatorNoteAudios != nil { rel := models.NoteAudioSlice{} for _, r := range t.r.CreatorNoteAudios { @@ -350,6 +368,26 @@ func ensureCreatableUser(m *models.UserSetter) { func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.User) error { var err error + isPublicUserUserDone, _ := userRelPublicUserUserCtx.Value(ctx) + if !isPublicUserUserDone && o.r.PublicUserUser != nil { + ctx = userRelPublicUserUserCtx.WithValue(ctx, true) + for _, r := range o.r.PublicUserUser { + if r.o.alreadyPersisted { + m.R.PublicUserUser = append(m.R.PublicUserUser, r.o.Build()) + } else { + rel0, err := r.o.CreateMany(ctx, exec, r.number) + if err != nil { + return err + } + + err = m.AttachPublicUserUser(ctx, exec, rel0...) + if err != nil { + return err + } + } + } + } + isCreatorNoteAudiosDone, _ := userRelCreatorNoteAudiosCtx.Value(ctx) if !isCreatorNoteAudiosDone && o.r.CreatorNoteAudios != nil { ctx = userRelCreatorNoteAudiosCtx.WithValue(ctx, true) @@ -357,12 +395,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m * if r.o.alreadyPersisted { m.R.CreatorNoteAudios = append(m.R.CreatorNoteAudios, r.o.Build()) } else { - rel0, err := r.o.CreateMany(ctx, exec, r.number) + rel1, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachCreatorNoteAudios(ctx, exec, rel0...) + err = m.AttachCreatorNoteAudios(ctx, exec, rel1...) if err != nil { return err } @@ -377,12 +415,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m * if r.o.alreadyPersisted { m.R.DeletorNoteAudios = append(m.R.DeletorNoteAudios, r.o.Build()) } else { - rel1, err := r.o.CreateMany(ctx, exec, r.number) + rel2, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachDeletorNoteAudios(ctx, exec, rel1...) + err = m.AttachDeletorNoteAudios(ctx, exec, rel2...) if err != nil { return err } @@ -397,12 +435,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m * if r.o.alreadyPersisted { m.R.CreatorNoteImages = append(m.R.CreatorNoteImages, r.o.Build()) } else { - rel2, err := r.o.CreateMany(ctx, exec, r.number) + rel3, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachCreatorNoteImages(ctx, exec, rel2...) + err = m.AttachCreatorNoteImages(ctx, exec, rel3...) if err != nil { return err } @@ -417,12 +455,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m * if r.o.alreadyPersisted { m.R.DeletorNoteImages = append(m.R.DeletorNoteImages, r.o.Build()) } else { - rel3, err := r.o.CreateMany(ctx, exec, r.number) + rel4, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachDeletorNoteImages(ctx, exec, rel3...) + err = m.AttachDeletorNoteImages(ctx, exec, rel4...) if err != nil { return err } @@ -437,12 +475,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m * if r.o.alreadyPersisted { m.R.UserNotifications = append(m.R.UserNotifications, r.o.Build()) } else { - rel4, err := r.o.CreateMany(ctx, exec, r.number) + rel5, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachUserNotifications(ctx, exec, rel4...) + err = m.AttachUserNotifications(ctx, exec, rel5...) if err != nil { return err } @@ -457,12 +495,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m * if r.o.alreadyPersisted { m.R.UserOauthTokens = append(m.R.UserOauthTokens, r.o.Build()) } else { - rel5, err := r.o.CreateMany(ctx, exec, r.number) + rel6, err := r.o.CreateMany(ctx, exec, r.number) if err != nil { return err } - err = m.AttachUserOauthTokens(ctx, exec, rel5...) + err = m.AttachUserOauthTokens(ctx, exec, rel6...) if err != nil { return err } @@ -484,25 +522,25 @@ func (o *UserTemplate) Create(ctx context.Context, exec bob.Executor) (*models.U UserMods.WithNewOrganization().Apply(ctx, o) } - var rel6 *models.Organization + var rel7 *models.Organization if o.r.Organization.o.alreadyPersisted { - rel6 = o.r.Organization.o.Build() + rel7 = o.r.Organization.o.Build() } else { - rel6, err = o.r.Organization.o.Create(ctx, exec) + rel7, err = o.r.Organization.o.Create(ctx, exec) if err != nil { return nil, err } } - opt.OrganizationID = omit.From(rel6.ID) + opt.OrganizationID = omit.From(rel7.ID) m, err := models.Users.Insert(opt).One(ctx, exec) if err != nil { return nil, err } - m.R.Organization = rel6 + m.R.Organization = rel7 if err := o.insertOptRels(ctx, exec, m); err != nil { return nil, err @@ -1144,6 +1182,54 @@ func (m userMods) WithoutOrganization() UserMod { }) } +func (m userMods) WithPublicUserUser(number int, related *ArcgisUserTemplate) UserMod { + return UserModFunc(func(ctx context.Context, o *UserTemplate) { + o.r.PublicUserUser = []*userRPublicUserUserR{{ + number: number, + o: related, + }} + }) +} + +func (m userMods) WithNewPublicUserUser(number int, mods ...ArcgisUserMod) UserMod { + return UserModFunc(func(ctx context.Context, o *UserTemplate) { + related := o.f.NewArcgisUserWithContext(ctx, mods...) + m.WithPublicUserUser(number, related).Apply(ctx, o) + }) +} + +func (m userMods) AddPublicUserUser(number int, related *ArcgisUserTemplate) UserMod { + return UserModFunc(func(ctx context.Context, o *UserTemplate) { + o.r.PublicUserUser = append(o.r.PublicUserUser, &userRPublicUserUserR{ + number: number, + o: related, + }) + }) +} + +func (m userMods) AddNewPublicUserUser(number int, mods ...ArcgisUserMod) UserMod { + return UserModFunc(func(ctx context.Context, o *UserTemplate) { + related := o.f.NewArcgisUserWithContext(ctx, mods...) + m.AddPublicUserUser(number, related).Apply(ctx, o) + }) +} + +func (m userMods) AddExistingPublicUserUser(existingModels ...*models.ArcgisUser) UserMod { + return UserModFunc(func(ctx context.Context, o *UserTemplate) { + for _, em := range existingModels { + o.r.PublicUserUser = append(o.r.PublicUserUser, &userRPublicUserUserR{ + o: o.f.FromExistingArcgisUser(em), + }) + } + }) +} + +func (m userMods) WithoutPublicUserUser() UserMod { + return UserModFunc(func(ctx context.Context, o *UserTemplate) { + o.r.PublicUserUser = nil + }) +} + func (m userMods) WithCreatorNoteAudios(number int, related *NoteAudioTemplate) UserMod { return UserModFunc(func(ctx context.Context, o *UserTemplate) { o.r.CreatorNoteAudios = []*userRCreatorNoteAudiosR{{ diff --git a/db/migrations/00031_arcgis_user.sql b/db/migrations/00031_arcgis_user.sql new file mode 100644 index 00000000..0e58193c --- /dev/null +++ b/db/migrations/00031_arcgis_user.sql @@ -0,0 +1,28 @@ +-- +goose Up +CREATE SCHEMA arcgis; +CREATE TABLE arcgis.user_ ( + access TEXT NOT NULL, + created TIMESTAMP WITHOUT TIME ZONE NOT NULL, + email TEXT NOT NULL, + full_name TEXT NOT NULL, + id TEXT NOT NULL, + level TEXT NOT NULL, + org_id TEXT NOT NULL, + public_user_id INTEGER NOT NULL REFERENCES public.user_(id), + region TEXT NOT NULL, + role TEXT NOT NULL, + role_id TEXT NOT NULL, + username TEXT NOT NULL, + user_license_type_id TEXT NOT NULL, + user_type TEXT NOT NULL, + PRIMARY KEY (id) +); +CREATE TABLE arcgis.user_privilege ( + user_id TEXT NOT NULL REFERENCES arcgis.user_(id), + privilege TEXT NOT NULL, + PRIMARY KEY(user_id, privilege) +); +-- +goose Down +DROP TABLE arcgis.user_privilege; +DROP TABLE arcgis.user_; +DROP SCHEMA arcgis; diff --git a/db/models/arcgis.user_.bob.go b/db/models/arcgis.user_.bob.go new file mode 100644 index 00000000..6613b87f --- /dev/null +++ b/db/models/arcgis.user_.bob.go @@ -0,0 +1,1191 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package models + +import ( + "context" + "fmt" + "io" + "time" + + "github.com/aarondl/opt/omit" + "github.com/stephenafamo/bob" + "github.com/stephenafamo/bob/dialect/psql" + "github.com/stephenafamo/bob/dialect/psql/dialect" + "github.com/stephenafamo/bob/dialect/psql/dm" + "github.com/stephenafamo/bob/dialect/psql/sm" + "github.com/stephenafamo/bob/dialect/psql/um" + "github.com/stephenafamo/bob/expr" + "github.com/stephenafamo/bob/mods" + "github.com/stephenafamo/bob/orm" + "github.com/stephenafamo/bob/types/pgtypes" +) + +// ArcgisUser is an object representing the database table. +type ArcgisUser struct { + Access string `db:"access" ` + Created time.Time `db:"created" ` + Email string `db:"email" ` + FullName string `db:"full_name" ` + ID string `db:"id,pk" ` + Level string `db:"level" ` + OrgID string `db:"org_id" ` + PublicUserID int32 `db:"public_user_id" ` + Region string `db:"region" ` + Role string `db:"role" ` + RoleID string `db:"role_id" ` + Username string `db:"username" ` + UserLicenseTypeID string `db:"user_license_type_id" ` + UserType string `db:"user_type" ` + + R arcgisuserR `db:"-" ` + + C arcgisuserC `db:"-" ` +} + +// ArcgisUserSlice is an alias for a slice of pointers to ArcgisUser. +// This should almost always be used instead of []*ArcgisUser. +type ArcgisUserSlice []*ArcgisUser + +// ArcgisUsers contains methods to work with the user_ table +var ArcgisUsers = psql.NewTablex[*ArcgisUser, ArcgisUserSlice, *ArcgisUserSetter]("arcgis", "user_", buildArcgisUserColumns("arcgis.user_")) + +// ArcgisUsersQuery is a query on the user_ table +type ArcgisUsersQuery = *psql.ViewQuery[*ArcgisUser, ArcgisUserSlice] + +// arcgisuserR is where relationships are stored. +type arcgisuserR struct { + PublicUserUser *User // arcgis.user_.user__public_user_id_fkey + UserUserPrivileges ArcgisUserPrivilegeSlice // arcgis.user_privilege.user_privilege_user_id_fkey +} + +func buildArcgisUserColumns(alias string) arcgisuserColumns { + return arcgisuserColumns{ + ColumnsExpr: expr.NewColumnsExpr( + "access", "created", "email", "full_name", "id", "level", "org_id", "public_user_id", "region", "role", "role_id", "username", "user_license_type_id", "user_type", + ).WithParent("arcgis.user_"), + tableAlias: alias, + Access: psql.Quote(alias, "access"), + Created: psql.Quote(alias, "created"), + Email: psql.Quote(alias, "email"), + FullName: psql.Quote(alias, "full_name"), + ID: psql.Quote(alias, "id"), + Level: psql.Quote(alias, "level"), + OrgID: psql.Quote(alias, "org_id"), + PublicUserID: psql.Quote(alias, "public_user_id"), + Region: psql.Quote(alias, "region"), + Role: psql.Quote(alias, "role"), + RoleID: psql.Quote(alias, "role_id"), + Username: psql.Quote(alias, "username"), + UserLicenseTypeID: psql.Quote(alias, "user_license_type_id"), + UserType: psql.Quote(alias, "user_type"), + } +} + +type arcgisuserColumns struct { + expr.ColumnsExpr + tableAlias string + Access psql.Expression + Created psql.Expression + Email psql.Expression + FullName psql.Expression + ID psql.Expression + Level psql.Expression + OrgID psql.Expression + PublicUserID psql.Expression + Region psql.Expression + Role psql.Expression + RoleID psql.Expression + Username psql.Expression + UserLicenseTypeID psql.Expression + UserType psql.Expression +} + +func (c arcgisuserColumns) Alias() string { + return c.tableAlias +} + +func (arcgisuserColumns) AliasedAs(alias string) arcgisuserColumns { + return buildArcgisUserColumns(alias) +} + +// ArcgisUserSetter is used for insert/upsert/update operations +// All values are optional, and do not have to be set +// Generated columns are not included +type ArcgisUserSetter struct { + Access omit.Val[string] `db:"access" ` + Created omit.Val[time.Time] `db:"created" ` + Email omit.Val[string] `db:"email" ` + FullName omit.Val[string] `db:"full_name" ` + ID omit.Val[string] `db:"id,pk" ` + Level omit.Val[string] `db:"level" ` + OrgID omit.Val[string] `db:"org_id" ` + PublicUserID omit.Val[int32] `db:"public_user_id" ` + Region omit.Val[string] `db:"region" ` + Role omit.Val[string] `db:"role" ` + RoleID omit.Val[string] `db:"role_id" ` + Username omit.Val[string] `db:"username" ` + UserLicenseTypeID omit.Val[string] `db:"user_license_type_id" ` + UserType omit.Val[string] `db:"user_type" ` +} + +func (s ArcgisUserSetter) SetColumns() []string { + vals := make([]string, 0, 14) + if s.Access.IsValue() { + vals = append(vals, "access") + } + if s.Created.IsValue() { + vals = append(vals, "created") + } + if s.Email.IsValue() { + vals = append(vals, "email") + } + if s.FullName.IsValue() { + vals = append(vals, "full_name") + } + if s.ID.IsValue() { + vals = append(vals, "id") + } + if s.Level.IsValue() { + vals = append(vals, "level") + } + if s.OrgID.IsValue() { + vals = append(vals, "org_id") + } + if s.PublicUserID.IsValue() { + vals = append(vals, "public_user_id") + } + if s.Region.IsValue() { + vals = append(vals, "region") + } + if s.Role.IsValue() { + vals = append(vals, "role") + } + if s.RoleID.IsValue() { + vals = append(vals, "role_id") + } + if s.Username.IsValue() { + vals = append(vals, "username") + } + if s.UserLicenseTypeID.IsValue() { + vals = append(vals, "user_license_type_id") + } + if s.UserType.IsValue() { + vals = append(vals, "user_type") + } + return vals +} + +func (s ArcgisUserSetter) Overwrite(t *ArcgisUser) { + if s.Access.IsValue() { + t.Access = s.Access.MustGet() + } + if s.Created.IsValue() { + t.Created = s.Created.MustGet() + } + if s.Email.IsValue() { + t.Email = s.Email.MustGet() + } + if s.FullName.IsValue() { + t.FullName = s.FullName.MustGet() + } + if s.ID.IsValue() { + t.ID = s.ID.MustGet() + } + if s.Level.IsValue() { + t.Level = s.Level.MustGet() + } + if s.OrgID.IsValue() { + t.OrgID = s.OrgID.MustGet() + } + if s.PublicUserID.IsValue() { + t.PublicUserID = s.PublicUserID.MustGet() + } + if s.Region.IsValue() { + t.Region = s.Region.MustGet() + } + if s.Role.IsValue() { + t.Role = s.Role.MustGet() + } + if s.RoleID.IsValue() { + t.RoleID = s.RoleID.MustGet() + } + if s.Username.IsValue() { + t.Username = s.Username.MustGet() + } + if s.UserLicenseTypeID.IsValue() { + t.UserLicenseTypeID = s.UserLicenseTypeID.MustGet() + } + if s.UserType.IsValue() { + t.UserType = s.UserType.MustGet() + } +} + +func (s *ArcgisUserSetter) Apply(q *dialect.InsertQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return ArcgisUsers.BeforeInsertHooks.RunHooks(ctx, exec, s) + }) + + q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + vals := make([]bob.Expression, 14) + if s.Access.IsValue() { + vals[0] = psql.Arg(s.Access.MustGet()) + } else { + vals[0] = psql.Raw("DEFAULT") + } + + if s.Created.IsValue() { + vals[1] = psql.Arg(s.Created.MustGet()) + } else { + vals[1] = psql.Raw("DEFAULT") + } + + if s.Email.IsValue() { + vals[2] = psql.Arg(s.Email.MustGet()) + } else { + vals[2] = psql.Raw("DEFAULT") + } + + if s.FullName.IsValue() { + vals[3] = psql.Arg(s.FullName.MustGet()) + } else { + vals[3] = psql.Raw("DEFAULT") + } + + if s.ID.IsValue() { + vals[4] = psql.Arg(s.ID.MustGet()) + } else { + vals[4] = psql.Raw("DEFAULT") + } + + if s.Level.IsValue() { + vals[5] = psql.Arg(s.Level.MustGet()) + } else { + vals[5] = psql.Raw("DEFAULT") + } + + if s.OrgID.IsValue() { + vals[6] = psql.Arg(s.OrgID.MustGet()) + } else { + vals[6] = psql.Raw("DEFAULT") + } + + if s.PublicUserID.IsValue() { + vals[7] = psql.Arg(s.PublicUserID.MustGet()) + } else { + vals[7] = psql.Raw("DEFAULT") + } + + if s.Region.IsValue() { + vals[8] = psql.Arg(s.Region.MustGet()) + } else { + vals[8] = psql.Raw("DEFAULT") + } + + if s.Role.IsValue() { + vals[9] = psql.Arg(s.Role.MustGet()) + } else { + vals[9] = psql.Raw("DEFAULT") + } + + if s.RoleID.IsValue() { + vals[10] = psql.Arg(s.RoleID.MustGet()) + } else { + vals[10] = psql.Raw("DEFAULT") + } + + if s.Username.IsValue() { + vals[11] = psql.Arg(s.Username.MustGet()) + } else { + vals[11] = psql.Raw("DEFAULT") + } + + if s.UserLicenseTypeID.IsValue() { + vals[12] = psql.Arg(s.UserLicenseTypeID.MustGet()) + } else { + vals[12] = psql.Raw("DEFAULT") + } + + if s.UserType.IsValue() { + vals[13] = psql.Arg(s.UserType.MustGet()) + } else { + vals[13] = psql.Raw("DEFAULT") + } + + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") + })) +} + +func (s ArcgisUserSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { + return um.Set(s.Expressions()...) +} + +func (s ArcgisUserSetter) Expressions(prefix ...string) []bob.Expression { + exprs := make([]bob.Expression, 0, 14) + + if s.Access.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "access")...), + psql.Arg(s.Access), + }}) + } + + if s.Created.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "created")...), + psql.Arg(s.Created), + }}) + } + + if s.Email.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "email")...), + psql.Arg(s.Email), + }}) + } + + if s.FullName.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "full_name")...), + psql.Arg(s.FullName), + }}) + } + + if s.ID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "id")...), + psql.Arg(s.ID), + }}) + } + + if s.Level.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "level")...), + psql.Arg(s.Level), + }}) + } + + if s.OrgID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "org_id")...), + psql.Arg(s.OrgID), + }}) + } + + if s.PublicUserID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "public_user_id")...), + psql.Arg(s.PublicUserID), + }}) + } + + if s.Region.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "region")...), + psql.Arg(s.Region), + }}) + } + + if s.Role.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "role")...), + psql.Arg(s.Role), + }}) + } + + if s.RoleID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "role_id")...), + psql.Arg(s.RoleID), + }}) + } + + if s.Username.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "username")...), + psql.Arg(s.Username), + }}) + } + + if s.UserLicenseTypeID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "user_license_type_id")...), + psql.Arg(s.UserLicenseTypeID), + }}) + } + + if s.UserType.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "user_type")...), + psql.Arg(s.UserType), + }}) + } + + return exprs +} + +// FindArcgisUser retrieves a single record by primary key +// If cols is empty Find will return all columns. +func FindArcgisUser(ctx context.Context, exec bob.Executor, IDPK string, cols ...string) (*ArcgisUser, error) { + if len(cols) == 0 { + return ArcgisUsers.Query( + sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(IDPK))), + ).One(ctx, exec) + } + + return ArcgisUsers.Query( + sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(IDPK))), + sm.Columns(ArcgisUsers.Columns.Only(cols...)), + ).One(ctx, exec) +} + +// ArcgisUserExists checks the presence of a single record by primary key +func ArcgisUserExists(ctx context.Context, exec bob.Executor, IDPK string) (bool, error) { + return ArcgisUsers.Query( + sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(IDPK))), + ).Exists(ctx, exec) +} + +// AfterQueryHook is called after ArcgisUser is retrieved from the database +func (o *ArcgisUser) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { + var err error + + switch queryType { + case bob.QueryTypeSelect: + ctx, err = ArcgisUsers.AfterSelectHooks.RunHooks(ctx, exec, ArcgisUserSlice{o}) + case bob.QueryTypeInsert: + ctx, err = ArcgisUsers.AfterInsertHooks.RunHooks(ctx, exec, ArcgisUserSlice{o}) + case bob.QueryTypeUpdate: + ctx, err = ArcgisUsers.AfterUpdateHooks.RunHooks(ctx, exec, ArcgisUserSlice{o}) + case bob.QueryTypeDelete: + ctx, err = ArcgisUsers.AfterDeleteHooks.RunHooks(ctx, exec, ArcgisUserSlice{o}) + } + + return err +} + +// primaryKeyVals returns the primary key values of the ArcgisUser +func (o *ArcgisUser) primaryKeyVals() bob.Expression { + return psql.Arg(o.ID) +} + +func (o *ArcgisUser) pkEQ() dialect.Expression { + return psql.Quote("arcgis.user_", "id").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) + })) +} + +// Update uses an executor to update the ArcgisUser +func (o *ArcgisUser) Update(ctx context.Context, exec bob.Executor, s *ArcgisUserSetter) error { + v, err := ArcgisUsers.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec) + if err != nil { + return err + } + + o.R = v.R + *o = *v + + return nil +} + +// Delete deletes a single ArcgisUser record with an executor +func (o *ArcgisUser) Delete(ctx context.Context, exec bob.Executor) error { + _, err := ArcgisUsers.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec) + return err +} + +// Reload refreshes the ArcgisUser using the executor +func (o *ArcgisUser) Reload(ctx context.Context, exec bob.Executor) error { + o2, err := ArcgisUsers.Query( + sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(o.ID))), + ).One(ctx, exec) + if err != nil { + return err + } + o2.R = o.R + *o = *o2 + + return nil +} + +// AfterQueryHook is called after ArcgisUserSlice is retrieved from the database +func (o ArcgisUserSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { + var err error + + switch queryType { + case bob.QueryTypeSelect: + ctx, err = ArcgisUsers.AfterSelectHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeInsert: + ctx, err = ArcgisUsers.AfterInsertHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeUpdate: + ctx, err = ArcgisUsers.AfterUpdateHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeDelete: + ctx, err = ArcgisUsers.AfterDeleteHooks.RunHooks(ctx, exec, o) + } + + return err +} + +func (o ArcgisUserSlice) pkIN() dialect.Expression { + if len(o) == 0 { + return psql.Raw("NULL") + } + + return psql.Quote("arcgis.user_", "id").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() + } + return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "") + })) +} + +// copyMatchingRows finds models in the given slice that have the same primary key +// then it first copies the existing relationships from the old model to the new model +// and then replaces the old model in the slice with the new model +func (o ArcgisUserSlice) copyMatchingRows(from ...*ArcgisUser) { + for i, old := range o { + for _, new := range from { + if new.ID != old.ID { + continue + } + new.R = old.R + o[i] = new + break + } + } +} + +// UpdateMod modifies an update query with "WHERE primary_key IN (o...)" +func (o ArcgisUserSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] { + return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return ArcgisUsers.BeforeUpdateHooks.RunHooks(ctx, exec, o) + }) + + q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { + var err error + switch retrieved := retrieved.(type) { + case *ArcgisUser: + o.copyMatchingRows(retrieved) + case []*ArcgisUser: + o.copyMatchingRows(retrieved...) + case ArcgisUserSlice: + o.copyMatchingRows(retrieved...) + default: + // If the retrieved value is not a ArcgisUser or a slice of ArcgisUser + // then run the AfterUpdateHooks on the slice + _, err = ArcgisUsers.AfterUpdateHooks.RunHooks(ctx, exec, o) + } + + return err + })) + + q.AppendWhere(o.pkIN()) + }) +} + +// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)" +func (o ArcgisUserSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] { + return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return ArcgisUsers.BeforeDeleteHooks.RunHooks(ctx, exec, o) + }) + + q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { + var err error + switch retrieved := retrieved.(type) { + case *ArcgisUser: + o.copyMatchingRows(retrieved) + case []*ArcgisUser: + o.copyMatchingRows(retrieved...) + case ArcgisUserSlice: + o.copyMatchingRows(retrieved...) + default: + // If the retrieved value is not a ArcgisUser or a slice of ArcgisUser + // then run the AfterDeleteHooks on the slice + _, err = ArcgisUsers.AfterDeleteHooks.RunHooks(ctx, exec, o) + } + + return err + })) + + q.AppendWhere(o.pkIN()) + }) +} + +func (o ArcgisUserSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals ArcgisUserSetter) error { + if len(o) == 0 { + return nil + } + + _, err := ArcgisUsers.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec) + return err +} + +func (o ArcgisUserSlice) DeleteAll(ctx context.Context, exec bob.Executor) error { + if len(o) == 0 { + return nil + } + + _, err := ArcgisUsers.Delete(o.DeleteMod()).Exec(ctx, exec) + return err +} + +func (o ArcgisUserSlice) ReloadAll(ctx context.Context, exec bob.Executor) error { + if len(o) == 0 { + return nil + } + + o2, err := ArcgisUsers.Query(sm.Where(o.pkIN())).All(ctx, exec) + if err != nil { + return err + } + + o.copyMatchingRows(o2...) + + return nil +} + +// PublicUserUser starts a query for related objects on user_ +func (o *ArcgisUser) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery { + return Users.Query(append(mods, + sm.Where(Users.Columns.ID.EQ(psql.Arg(o.PublicUserID))), + )...) +} + +func (os ArcgisUserSlice) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery { + pkPublicUserID := make(pgtypes.Array[int32], 0, len(os)) + for _, o := range os { + if o == nil { + continue + } + pkPublicUserID = append(pkPublicUserID, o.PublicUserID) + } + PKArgExpr := psql.Select(sm.Columns( + psql.F("unnest", psql.Cast(psql.Arg(pkPublicUserID), "integer[]")), + )) + + return Users.Query(append(mods, + sm.Where(psql.Group(Users.Columns.ID).OP("IN", PKArgExpr)), + )...) +} + +// UserUserPrivileges starts a query for related objects on arcgis.user_privilege +func (o *ArcgisUser) UserUserPrivileges(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUserPrivilegesQuery { + return ArcgisUserPrivileges.Query(append(mods, + sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(o.ID))), + )...) +} + +func (os ArcgisUserSlice) UserUserPrivileges(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUserPrivilegesQuery { + pkID := make(pgtypes.Array[string], 0, len(os)) + for _, o := range os { + if o == nil { + continue + } + pkID = append(pkID, o.ID) + } + PKArgExpr := psql.Select(sm.Columns( + psql.F("unnest", psql.Cast(psql.Arg(pkID), "text[]")), + )) + + return ArcgisUserPrivileges.Query(append(mods, + sm.Where(psql.Group(ArcgisUserPrivileges.Columns.UserID).OP("IN", PKArgExpr)), + )...) +} + +func attachArcgisUserPublicUserUser0(ctx context.Context, exec bob.Executor, count int, arcgisuser0 *ArcgisUser, user1 *User) (*ArcgisUser, error) { + setter := &ArcgisUserSetter{ + PublicUserID: omit.From(user1.ID), + } + + err := arcgisuser0.Update(ctx, exec, setter) + if err != nil { + return nil, fmt.Errorf("attachArcgisUserPublicUserUser0: %w", err) + } + + return arcgisuser0, nil +} + +func (arcgisuser0 *ArcgisUser) InsertPublicUserUser(ctx context.Context, exec bob.Executor, related *UserSetter) error { + var err error + + user1, err := Users.Insert(related).One(ctx, exec) + if err != nil { + return fmt.Errorf("inserting related objects: %w", err) + } + + _, err = attachArcgisUserPublicUserUser0(ctx, exec, 1, arcgisuser0, user1) + if err != nil { + return err + } + + arcgisuser0.R.PublicUserUser = user1 + + user1.R.PublicUserUser = append(user1.R.PublicUserUser, arcgisuser0) + + return nil +} + +func (arcgisuser0 *ArcgisUser) AttachPublicUserUser(ctx context.Context, exec bob.Executor, user1 *User) error { + var err error + + _, err = attachArcgisUserPublicUserUser0(ctx, exec, 1, arcgisuser0, user1) + if err != nil { + return err + } + + arcgisuser0.R.PublicUserUser = user1 + + user1.R.PublicUserUser = append(user1.R.PublicUserUser, arcgisuser0) + + return nil +} + +func insertArcgisUserUserUserPrivileges0(ctx context.Context, exec bob.Executor, arcgisUserPrivileges1 []*ArcgisUserPrivilegeSetter, arcgisuser0 *ArcgisUser) (ArcgisUserPrivilegeSlice, error) { + for i := range arcgisUserPrivileges1 { + arcgisUserPrivileges1[i].UserID = omit.From(arcgisuser0.ID) + } + + ret, err := ArcgisUserPrivileges.Insert(bob.ToMods(arcgisUserPrivileges1...)).All(ctx, exec) + if err != nil { + return ret, fmt.Errorf("insertArcgisUserUserUserPrivileges0: %w", err) + } + + return ret, nil +} + +func attachArcgisUserUserUserPrivileges0(ctx context.Context, exec bob.Executor, count int, arcgisUserPrivileges1 ArcgisUserPrivilegeSlice, arcgisuser0 *ArcgisUser) (ArcgisUserPrivilegeSlice, error) { + setter := &ArcgisUserPrivilegeSetter{ + UserID: omit.From(arcgisuser0.ID), + } + + err := arcgisUserPrivileges1.UpdateAll(ctx, exec, *setter) + if err != nil { + return nil, fmt.Errorf("attachArcgisUserUserUserPrivileges0: %w", err) + } + + return arcgisUserPrivileges1, nil +} + +func (arcgisuser0 *ArcgisUser) InsertUserUserPrivileges(ctx context.Context, exec bob.Executor, related ...*ArcgisUserPrivilegeSetter) error { + if len(related) == 0 { + return nil + } + + var err error + + arcgisUserPrivileges1, err := insertArcgisUserUserUserPrivileges0(ctx, exec, related, arcgisuser0) + if err != nil { + return err + } + + arcgisuser0.R.UserUserPrivileges = append(arcgisuser0.R.UserUserPrivileges, arcgisUserPrivileges1...) + + for _, rel := range arcgisUserPrivileges1 { + rel.R.UserUser = arcgisuser0 + } + return nil +} + +func (arcgisuser0 *ArcgisUser) AttachUserUserPrivileges(ctx context.Context, exec bob.Executor, related ...*ArcgisUserPrivilege) error { + if len(related) == 0 { + return nil + } + + var err error + arcgisUserPrivileges1 := ArcgisUserPrivilegeSlice(related) + + _, err = attachArcgisUserUserUserPrivileges0(ctx, exec, len(related), arcgisUserPrivileges1, arcgisuser0) + if err != nil { + return err + } + + arcgisuser0.R.UserUserPrivileges = append(arcgisuser0.R.UserUserPrivileges, arcgisUserPrivileges1...) + + for _, rel := range related { + rel.R.UserUser = arcgisuser0 + } + + return nil +} + +type arcgisuserWhere[Q psql.Filterable] struct { + Access psql.WhereMod[Q, string] + Created psql.WhereMod[Q, time.Time] + Email psql.WhereMod[Q, string] + FullName psql.WhereMod[Q, string] + ID psql.WhereMod[Q, string] + Level psql.WhereMod[Q, string] + OrgID psql.WhereMod[Q, string] + PublicUserID psql.WhereMod[Q, int32] + Region psql.WhereMod[Q, string] + Role psql.WhereMod[Q, string] + RoleID psql.WhereMod[Q, string] + Username psql.WhereMod[Q, string] + UserLicenseTypeID psql.WhereMod[Q, string] + UserType psql.WhereMod[Q, string] +} + +func (arcgisuserWhere[Q]) AliasedAs(alias string) arcgisuserWhere[Q] { + return buildArcgisUserWhere[Q](buildArcgisUserColumns(alias)) +} + +func buildArcgisUserWhere[Q psql.Filterable](cols arcgisuserColumns) arcgisuserWhere[Q] { + return arcgisuserWhere[Q]{ + Access: psql.Where[Q, string](cols.Access), + Created: psql.Where[Q, time.Time](cols.Created), + Email: psql.Where[Q, string](cols.Email), + FullName: psql.Where[Q, string](cols.FullName), + ID: psql.Where[Q, string](cols.ID), + Level: psql.Where[Q, string](cols.Level), + OrgID: psql.Where[Q, string](cols.OrgID), + PublicUserID: psql.Where[Q, int32](cols.PublicUserID), + Region: psql.Where[Q, string](cols.Region), + Role: psql.Where[Q, string](cols.Role), + RoleID: psql.Where[Q, string](cols.RoleID), + Username: psql.Where[Q, string](cols.Username), + UserLicenseTypeID: psql.Where[Q, string](cols.UserLicenseTypeID), + UserType: psql.Where[Q, string](cols.UserType), + } +} + +func (o *ArcgisUser) Preload(name string, retrieved any) error { + if o == nil { + return nil + } + + switch name { + case "PublicUserUser": + rel, ok := retrieved.(*User) + if !ok { + return fmt.Errorf("arcgisuser cannot load %T as %q", retrieved, name) + } + + o.R.PublicUserUser = rel + + if rel != nil { + rel.R.PublicUserUser = ArcgisUserSlice{o} + } + return nil + case "UserUserPrivileges": + rels, ok := retrieved.(ArcgisUserPrivilegeSlice) + if !ok { + return fmt.Errorf("arcgisuser cannot load %T as %q", retrieved, name) + } + + o.R.UserUserPrivileges = rels + + for _, rel := range rels { + if rel != nil { + rel.R.UserUser = o + } + } + return nil + default: + return fmt.Errorf("arcgisuser has no relationship %q", name) + } +} + +type arcgisuserPreloader struct { + PublicUserUser func(...psql.PreloadOption) psql.Preloader +} + +func buildArcgisUserPreloader() arcgisuserPreloader { + return arcgisuserPreloader{ + PublicUserUser: func(opts ...psql.PreloadOption) psql.Preloader { + return psql.Preload[*User, UserSlice](psql.PreloadRel{ + Name: "PublicUserUser", + Sides: []psql.PreloadSide{ + { + From: ArcgisUsers, + To: Users, + FromColumns: []string{"public_user_id"}, + ToColumns: []string{"id"}, + }, + }, + }, Users.Columns.Names(), opts...) + }, + } +} + +type arcgisuserThenLoader[Q orm.Loadable] struct { + PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + UserUserPrivileges func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildArcgisUserThenLoader[Q orm.Loadable]() arcgisuserThenLoader[Q] { + type PublicUserUserLoadInterface interface { + LoadPublicUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type UserUserPrivilegesLoadInterface interface { + LoadUserUserPrivileges(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return arcgisuserThenLoader[Q]{ + PublicUserUser: thenLoadBuilder[Q]( + "PublicUserUser", + func(ctx context.Context, exec bob.Executor, retrieved PublicUserUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadPublicUserUser(ctx, exec, mods...) + }, + ), + UserUserPrivileges: thenLoadBuilder[Q]( + "UserUserPrivileges", + func(ctx context.Context, exec bob.Executor, retrieved UserUserPrivilegesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadUserUserPrivileges(ctx, exec, mods...) + }, + ), + } +} + +// LoadPublicUserUser loads the arcgisuser's PublicUserUser into the .R struct +func (o *ArcgisUser) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + // Reset the relationship + o.R.PublicUserUser = nil + + related, err := o.PublicUserUser(mods...).One(ctx, exec) + if err != nil { + return err + } + + related.R.PublicUserUser = ArcgisUserSlice{o} + + o.R.PublicUserUser = related + return nil +} + +// LoadPublicUserUser loads the arcgisuser's PublicUserUser into the .R struct +func (os ArcgisUserSlice) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + users, err := os.PublicUserUser(mods...).All(ctx, exec) + if err != nil { + return err + } + + for _, o := range os { + if o == nil { + continue + } + + for _, rel := range users { + + if !(o.PublicUserID == rel.ID) { + continue + } + + rel.R.PublicUserUser = append(rel.R.PublicUserUser, o) + + o.R.PublicUserUser = rel + break + } + } + + return nil +} + +// LoadUserUserPrivileges loads the arcgisuser's UserUserPrivileges into the .R struct +func (o *ArcgisUser) LoadUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + // Reset the relationship + o.R.UserUserPrivileges = nil + + related, err := o.UserUserPrivileges(mods...).All(ctx, exec) + if err != nil { + return err + } + + for _, rel := range related { + rel.R.UserUser = o + } + + o.R.UserUserPrivileges = related + return nil +} + +// LoadUserUserPrivileges loads the arcgisuser's UserUserPrivileges into the .R struct +func (os ArcgisUserSlice) LoadUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + arcgisUserPrivileges, err := os.UserUserPrivileges(mods...).All(ctx, exec) + if err != nil { + return err + } + + for _, o := range os { + if o == nil { + continue + } + + o.R.UserUserPrivileges = nil + } + + for _, o := range os { + if o == nil { + continue + } + + for _, rel := range arcgisUserPrivileges { + + if !(o.ID == rel.UserID) { + continue + } + + rel.R.UserUser = o + + o.R.UserUserPrivileges = append(o.R.UserUserPrivileges, rel) + } + } + + return nil +} + +// arcgisuserC is where relationship counts are stored. +type arcgisuserC struct { + UserUserPrivileges *int64 +} + +// PreloadCount sets a count in the C struct by name +func (o *ArcgisUser) PreloadCount(name string, count int64) error { + if o == nil { + return nil + } + + switch name { + case "UserUserPrivileges": + o.C.UserUserPrivileges = &count + } + return nil +} + +type arcgisuserCountPreloader struct { + UserUserPrivileges func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader +} + +func buildArcgisUserCountPreloader() arcgisuserCountPreloader { + return arcgisuserCountPreloader{ + UserUserPrivileges: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*ArcgisUser]("UserUserPrivileges", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = ArcgisUsers.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(ArcgisUserPrivileges.Name()), + sm.Where(psql.Quote(ArcgisUserPrivileges.Alias(), "user_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + } +} + +type arcgisuserCountThenLoader[Q orm.Loadable] struct { + UserUserPrivileges func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildArcgisUserCountThenLoader[Q orm.Loadable]() arcgisuserCountThenLoader[Q] { + type UserUserPrivilegesCountInterface interface { + LoadCountUserUserPrivileges(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return arcgisuserCountThenLoader[Q]{ + UserUserPrivileges: countThenLoadBuilder[Q]( + "UserUserPrivileges", + func(ctx context.Context, exec bob.Executor, retrieved UserUserPrivilegesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountUserUserPrivileges(ctx, exec, mods...) + }, + ), + } +} + +// LoadCountUserUserPrivileges loads the count of UserUserPrivileges into the C struct +func (o *ArcgisUser) LoadCountUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.UserUserPrivileges(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.UserUserPrivileges = &count + return nil +} + +// LoadCountUserUserPrivileges loads the count of UserUserPrivileges for a slice +func (os ArcgisUserSlice) LoadCountUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountUserUserPrivileges(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +type arcgisuserJoins[Q dialect.Joinable] struct { + typ string + PublicUserUser modAs[Q, userColumns] + UserUserPrivileges modAs[Q, arcgisUserPrivilegeColumns] +} + +func (j arcgisuserJoins[Q]) aliasedAs(alias string) arcgisuserJoins[Q] { + return buildArcgisUserJoins[Q](buildArcgisUserColumns(alias), j.typ) +} + +func buildArcgisUserJoins[Q dialect.Joinable](cols arcgisuserColumns, typ string) arcgisuserJoins[Q] { + return arcgisuserJoins[Q]{ + typ: typ, + PublicUserUser: modAs[Q, userColumns]{ + c: Users.Columns, + f: func(to userColumns) bob.Mod[Q] { + mods := make(mods.QueryMods[Q], 0, 1) + + { + mods = append(mods, dialect.Join[Q](typ, Users.Name().As(to.Alias())).On( + to.ID.EQ(cols.PublicUserID), + )) + } + + return mods + }, + }, + UserUserPrivileges: modAs[Q, arcgisUserPrivilegeColumns]{ + c: ArcgisUserPrivileges.Columns, + f: func(to arcgisUserPrivilegeColumns) bob.Mod[Q] { + mods := make(mods.QueryMods[Q], 0, 1) + + { + mods = append(mods, dialect.Join[Q](typ, ArcgisUserPrivileges.Name().As(to.Alias())).On( + to.UserID.EQ(cols.ID), + )) + } + + return mods + }, + }, + } +} diff --git a/db/models/arcgis.user_privilege.bob.go b/db/models/arcgis.user_privilege.bob.go new file mode 100644 index 00000000..0783119b --- /dev/null +++ b/db/models/arcgis.user_privilege.bob.go @@ -0,0 +1,612 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package models + +import ( + "context" + "fmt" + "io" + + "github.com/aarondl/opt/omit" + "github.com/stephenafamo/bob" + "github.com/stephenafamo/bob/dialect/psql" + "github.com/stephenafamo/bob/dialect/psql/dialect" + "github.com/stephenafamo/bob/dialect/psql/dm" + "github.com/stephenafamo/bob/dialect/psql/sm" + "github.com/stephenafamo/bob/dialect/psql/um" + "github.com/stephenafamo/bob/expr" + "github.com/stephenafamo/bob/mods" + "github.com/stephenafamo/bob/orm" + "github.com/stephenafamo/bob/types/pgtypes" +) + +// ArcgisUserPrivilege is an object representing the database table. +type ArcgisUserPrivilege struct { + UserID string `db:"user_id,pk" ` + Privilege string `db:"privilege,pk" ` + + R arcgisUserPrivilegeR `db:"-" ` +} + +// ArcgisUserPrivilegeSlice is an alias for a slice of pointers to ArcgisUserPrivilege. +// This should almost always be used instead of []*ArcgisUserPrivilege. +type ArcgisUserPrivilegeSlice []*ArcgisUserPrivilege + +// ArcgisUserPrivileges contains methods to work with the user_privilege table +var ArcgisUserPrivileges = psql.NewTablex[*ArcgisUserPrivilege, ArcgisUserPrivilegeSlice, *ArcgisUserPrivilegeSetter]("arcgis", "user_privilege", buildArcgisUserPrivilegeColumns("arcgis.user_privilege")) + +// ArcgisUserPrivilegesQuery is a query on the user_privilege table +type ArcgisUserPrivilegesQuery = *psql.ViewQuery[*ArcgisUserPrivilege, ArcgisUserPrivilegeSlice] + +// arcgisUserPrivilegeR is where relationships are stored. +type arcgisUserPrivilegeR struct { + UserUser *ArcgisUser // arcgis.user_privilege.user_privilege_user_id_fkey +} + +func buildArcgisUserPrivilegeColumns(alias string) arcgisUserPrivilegeColumns { + return arcgisUserPrivilegeColumns{ + ColumnsExpr: expr.NewColumnsExpr( + "user_id", "privilege", + ).WithParent("arcgis.user_privilege"), + tableAlias: alias, + UserID: psql.Quote(alias, "user_id"), + Privilege: psql.Quote(alias, "privilege"), + } +} + +type arcgisUserPrivilegeColumns struct { + expr.ColumnsExpr + tableAlias string + UserID psql.Expression + Privilege psql.Expression +} + +func (c arcgisUserPrivilegeColumns) Alias() string { + return c.tableAlias +} + +func (arcgisUserPrivilegeColumns) AliasedAs(alias string) arcgisUserPrivilegeColumns { + return buildArcgisUserPrivilegeColumns(alias) +} + +// ArcgisUserPrivilegeSetter is used for insert/upsert/update operations +// All values are optional, and do not have to be set +// Generated columns are not included +type ArcgisUserPrivilegeSetter struct { + UserID omit.Val[string] `db:"user_id,pk" ` + Privilege omit.Val[string] `db:"privilege,pk" ` +} + +func (s ArcgisUserPrivilegeSetter) SetColumns() []string { + vals := make([]string, 0, 2) + if s.UserID.IsValue() { + vals = append(vals, "user_id") + } + if s.Privilege.IsValue() { + vals = append(vals, "privilege") + } + return vals +} + +func (s ArcgisUserPrivilegeSetter) Overwrite(t *ArcgisUserPrivilege) { + if s.UserID.IsValue() { + t.UserID = s.UserID.MustGet() + } + if s.Privilege.IsValue() { + t.Privilege = s.Privilege.MustGet() + } +} + +func (s *ArcgisUserPrivilegeSetter) Apply(q *dialect.InsertQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return ArcgisUserPrivileges.BeforeInsertHooks.RunHooks(ctx, exec, s) + }) + + q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + vals := make([]bob.Expression, 2) + if s.UserID.IsValue() { + vals[0] = psql.Arg(s.UserID.MustGet()) + } else { + vals[0] = psql.Raw("DEFAULT") + } + + if s.Privilege.IsValue() { + vals[1] = psql.Arg(s.Privilege.MustGet()) + } else { + vals[1] = psql.Raw("DEFAULT") + } + + return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "") + })) +} + +func (s ArcgisUserPrivilegeSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { + return um.Set(s.Expressions()...) +} + +func (s ArcgisUserPrivilegeSetter) Expressions(prefix ...string) []bob.Expression { + exprs := make([]bob.Expression, 0, 2) + + if s.UserID.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "user_id")...), + psql.Arg(s.UserID), + }}) + } + + if s.Privilege.IsValue() { + exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{ + psql.Quote(append(prefix, "privilege")...), + psql.Arg(s.Privilege), + }}) + } + + return exprs +} + +// FindArcgisUserPrivilege retrieves a single record by primary key +// If cols is empty Find will return all columns. +func FindArcgisUserPrivilege(ctx context.Context, exec bob.Executor, UserIDPK string, PrivilegePK string, cols ...string) (*ArcgisUserPrivilege, error) { + if len(cols) == 0 { + return ArcgisUserPrivileges.Query( + sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(UserIDPK))), + sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(PrivilegePK))), + ).One(ctx, exec) + } + + return ArcgisUserPrivileges.Query( + sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(UserIDPK))), + sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(PrivilegePK))), + sm.Columns(ArcgisUserPrivileges.Columns.Only(cols...)), + ).One(ctx, exec) +} + +// ArcgisUserPrivilegeExists checks the presence of a single record by primary key +func ArcgisUserPrivilegeExists(ctx context.Context, exec bob.Executor, UserIDPK string, PrivilegePK string) (bool, error) { + return ArcgisUserPrivileges.Query( + sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(UserIDPK))), + sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(PrivilegePK))), + ).Exists(ctx, exec) +} + +// AfterQueryHook is called after ArcgisUserPrivilege is retrieved from the database +func (o *ArcgisUserPrivilege) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { + var err error + + switch queryType { + case bob.QueryTypeSelect: + ctx, err = ArcgisUserPrivileges.AfterSelectHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o}) + case bob.QueryTypeInsert: + ctx, err = ArcgisUserPrivileges.AfterInsertHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o}) + case bob.QueryTypeUpdate: + ctx, err = ArcgisUserPrivileges.AfterUpdateHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o}) + case bob.QueryTypeDelete: + ctx, err = ArcgisUserPrivileges.AfterDeleteHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o}) + } + + return err +} + +// primaryKeyVals returns the primary key values of the ArcgisUserPrivilege +func (o *ArcgisUserPrivilege) primaryKeyVals() bob.Expression { + return psql.ArgGroup( + o.UserID, + o.Privilege, + ) +} + +func (o *ArcgisUserPrivilege) pkEQ() dialect.Expression { + return psql.Group(psql.Quote("arcgis.user_privilege", "user_id"), psql.Quote("arcgis.user_privilege", "privilege")).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) + })) +} + +// Update uses an executor to update the ArcgisUserPrivilege +func (o *ArcgisUserPrivilege) Update(ctx context.Context, exec bob.Executor, s *ArcgisUserPrivilegeSetter) error { + v, err := ArcgisUserPrivileges.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec) + if err != nil { + return err + } + + o.R = v.R + *o = *v + + return nil +} + +// Delete deletes a single ArcgisUserPrivilege record with an executor +func (o *ArcgisUserPrivilege) Delete(ctx context.Context, exec bob.Executor) error { + _, err := ArcgisUserPrivileges.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec) + return err +} + +// Reload refreshes the ArcgisUserPrivilege using the executor +func (o *ArcgisUserPrivilege) Reload(ctx context.Context, exec bob.Executor) error { + o2, err := ArcgisUserPrivileges.Query( + sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(o.UserID))), + sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(o.Privilege))), + ).One(ctx, exec) + if err != nil { + return err + } + o2.R = o.R + *o = *o2 + + return nil +} + +// AfterQueryHook is called after ArcgisUserPrivilegeSlice is retrieved from the database +func (o ArcgisUserPrivilegeSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error { + var err error + + switch queryType { + case bob.QueryTypeSelect: + ctx, err = ArcgisUserPrivileges.AfterSelectHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeInsert: + ctx, err = ArcgisUserPrivileges.AfterInsertHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeUpdate: + ctx, err = ArcgisUserPrivileges.AfterUpdateHooks.RunHooks(ctx, exec, o) + case bob.QueryTypeDelete: + ctx, err = ArcgisUserPrivileges.AfterDeleteHooks.RunHooks(ctx, exec, o) + } + + return err +} + +func (o ArcgisUserPrivilegeSlice) pkIN() dialect.Expression { + if len(o) == 0 { + return psql.Raw("NULL") + } + + return psql.Group(psql.Quote("arcgis.user_privilege", "user_id"), psql.Quote("arcgis.user_privilege", "privilege")).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() + } + return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "") + })) +} + +// copyMatchingRows finds models in the given slice that have the same primary key +// then it first copies the existing relationships from the old model to the new model +// and then replaces the old model in the slice with the new model +func (o ArcgisUserPrivilegeSlice) copyMatchingRows(from ...*ArcgisUserPrivilege) { + for i, old := range o { + for _, new := range from { + if new.UserID != old.UserID { + continue + } + if new.Privilege != old.Privilege { + continue + } + new.R = old.R + o[i] = new + break + } + } +} + +// UpdateMod modifies an update query with "WHERE primary_key IN (o...)" +func (o ArcgisUserPrivilegeSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] { + return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return ArcgisUserPrivileges.BeforeUpdateHooks.RunHooks(ctx, exec, o) + }) + + q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { + var err error + switch retrieved := retrieved.(type) { + case *ArcgisUserPrivilege: + o.copyMatchingRows(retrieved) + case []*ArcgisUserPrivilege: + o.copyMatchingRows(retrieved...) + case ArcgisUserPrivilegeSlice: + o.copyMatchingRows(retrieved...) + default: + // If the retrieved value is not a ArcgisUserPrivilege or a slice of ArcgisUserPrivilege + // then run the AfterUpdateHooks on the slice + _, err = ArcgisUserPrivileges.AfterUpdateHooks.RunHooks(ctx, exec, o) + } + + return err + })) + + q.AppendWhere(o.pkIN()) + }) +} + +// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)" +func (o ArcgisUserPrivilegeSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] { + return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) { + q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) { + return ArcgisUserPrivileges.BeforeDeleteHooks.RunHooks(ctx, exec, o) + }) + + q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error { + var err error + switch retrieved := retrieved.(type) { + case *ArcgisUserPrivilege: + o.copyMatchingRows(retrieved) + case []*ArcgisUserPrivilege: + o.copyMatchingRows(retrieved...) + case ArcgisUserPrivilegeSlice: + o.copyMatchingRows(retrieved...) + default: + // If the retrieved value is not a ArcgisUserPrivilege or a slice of ArcgisUserPrivilege + // then run the AfterDeleteHooks on the slice + _, err = ArcgisUserPrivileges.AfterDeleteHooks.RunHooks(ctx, exec, o) + } + + return err + })) + + q.AppendWhere(o.pkIN()) + }) +} + +func (o ArcgisUserPrivilegeSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals ArcgisUserPrivilegeSetter) error { + if len(o) == 0 { + return nil + } + + _, err := ArcgisUserPrivileges.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec) + return err +} + +func (o ArcgisUserPrivilegeSlice) DeleteAll(ctx context.Context, exec bob.Executor) error { + if len(o) == 0 { + return nil + } + + _, err := ArcgisUserPrivileges.Delete(o.DeleteMod()).Exec(ctx, exec) + return err +} + +func (o ArcgisUserPrivilegeSlice) ReloadAll(ctx context.Context, exec bob.Executor) error { + if len(o) == 0 { + return nil + } + + o2, err := ArcgisUserPrivileges.Query(sm.Where(o.pkIN())).All(ctx, exec) + if err != nil { + return err + } + + o.copyMatchingRows(o2...) + + return nil +} + +// UserUser starts a query for related objects on arcgis.user_ +func (o *ArcgisUserPrivilege) UserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery { + return ArcgisUsers.Query(append(mods, + sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(o.UserID))), + )...) +} + +func (os ArcgisUserPrivilegeSlice) UserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery { + pkUserID := make(pgtypes.Array[string], 0, len(os)) + for _, o := range os { + if o == nil { + continue + } + pkUserID = append(pkUserID, o.UserID) + } + PKArgExpr := psql.Select(sm.Columns( + psql.F("unnest", psql.Cast(psql.Arg(pkUserID), "text[]")), + )) + + return ArcgisUsers.Query(append(mods, + sm.Where(psql.Group(ArcgisUsers.Columns.ID).OP("IN", PKArgExpr)), + )...) +} + +func attachArcgisUserPrivilegeUserUser0(ctx context.Context, exec bob.Executor, count int, arcgisUserPrivilege0 *ArcgisUserPrivilege, arcgisuser1 *ArcgisUser) (*ArcgisUserPrivilege, error) { + setter := &ArcgisUserPrivilegeSetter{ + UserID: omit.From(arcgisuser1.ID), + } + + err := arcgisUserPrivilege0.Update(ctx, exec, setter) + if err != nil { + return nil, fmt.Errorf("attachArcgisUserPrivilegeUserUser0: %w", err) + } + + return arcgisUserPrivilege0, nil +} + +func (arcgisUserPrivilege0 *ArcgisUserPrivilege) InsertUserUser(ctx context.Context, exec bob.Executor, related *ArcgisUserSetter) error { + var err error + + arcgisuser1, err := ArcgisUsers.Insert(related).One(ctx, exec) + if err != nil { + return fmt.Errorf("inserting related objects: %w", err) + } + + _, err = attachArcgisUserPrivilegeUserUser0(ctx, exec, 1, arcgisUserPrivilege0, arcgisuser1) + if err != nil { + return err + } + + arcgisUserPrivilege0.R.UserUser = arcgisuser1 + + arcgisuser1.R.UserUserPrivileges = append(arcgisuser1.R.UserUserPrivileges, arcgisUserPrivilege0) + + return nil +} + +func (arcgisUserPrivilege0 *ArcgisUserPrivilege) AttachUserUser(ctx context.Context, exec bob.Executor, arcgisuser1 *ArcgisUser) error { + var err error + + _, err = attachArcgisUserPrivilegeUserUser0(ctx, exec, 1, arcgisUserPrivilege0, arcgisuser1) + if err != nil { + return err + } + + arcgisUserPrivilege0.R.UserUser = arcgisuser1 + + arcgisuser1.R.UserUserPrivileges = append(arcgisuser1.R.UserUserPrivileges, arcgisUserPrivilege0) + + return nil +} + +type arcgisUserPrivilegeWhere[Q psql.Filterable] struct { + UserID psql.WhereMod[Q, string] + Privilege psql.WhereMod[Q, string] +} + +func (arcgisUserPrivilegeWhere[Q]) AliasedAs(alias string) arcgisUserPrivilegeWhere[Q] { + return buildArcgisUserPrivilegeWhere[Q](buildArcgisUserPrivilegeColumns(alias)) +} + +func buildArcgisUserPrivilegeWhere[Q psql.Filterable](cols arcgisUserPrivilegeColumns) arcgisUserPrivilegeWhere[Q] { + return arcgisUserPrivilegeWhere[Q]{ + UserID: psql.Where[Q, string](cols.UserID), + Privilege: psql.Where[Q, string](cols.Privilege), + } +} + +func (o *ArcgisUserPrivilege) Preload(name string, retrieved any) error { + if o == nil { + return nil + } + + switch name { + case "UserUser": + rel, ok := retrieved.(*ArcgisUser) + if !ok { + return fmt.Errorf("arcgisUserPrivilege cannot load %T as %q", retrieved, name) + } + + o.R.UserUser = rel + + if rel != nil { + rel.R.UserUserPrivileges = ArcgisUserPrivilegeSlice{o} + } + return nil + default: + return fmt.Errorf("arcgisUserPrivilege has no relationship %q", name) + } +} + +type arcgisUserPrivilegePreloader struct { + UserUser func(...psql.PreloadOption) psql.Preloader +} + +func buildArcgisUserPrivilegePreloader() arcgisUserPrivilegePreloader { + return arcgisUserPrivilegePreloader{ + UserUser: func(opts ...psql.PreloadOption) psql.Preloader { + return psql.Preload[*ArcgisUser, ArcgisUserSlice](psql.PreloadRel{ + Name: "UserUser", + Sides: []psql.PreloadSide{ + { + From: ArcgisUserPrivileges, + To: ArcgisUsers, + FromColumns: []string{"user_id"}, + ToColumns: []string{"id"}, + }, + }, + }, ArcgisUsers.Columns.Names(), opts...) + }, + } +} + +type arcgisUserPrivilegeThenLoader[Q orm.Loadable] struct { + UserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildArcgisUserPrivilegeThenLoader[Q orm.Loadable]() arcgisUserPrivilegeThenLoader[Q] { + type UserUserLoadInterface interface { + LoadUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return arcgisUserPrivilegeThenLoader[Q]{ + UserUser: thenLoadBuilder[Q]( + "UserUser", + func(ctx context.Context, exec bob.Executor, retrieved UserUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadUserUser(ctx, exec, mods...) + }, + ), + } +} + +// LoadUserUser loads the arcgisUserPrivilege's UserUser into the .R struct +func (o *ArcgisUserPrivilege) LoadUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + // Reset the relationship + o.R.UserUser = nil + + related, err := o.UserUser(mods...).One(ctx, exec) + if err != nil { + return err + } + + related.R.UserUserPrivileges = ArcgisUserPrivilegeSlice{o} + + o.R.UserUser = related + return nil +} + +// LoadUserUser loads the arcgisUserPrivilege's UserUser into the .R struct +func (os ArcgisUserPrivilegeSlice) LoadUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + arcgisusers, err := os.UserUser(mods...).All(ctx, exec) + if err != nil { + return err + } + + for _, o := range os { + if o == nil { + continue + } + + for _, rel := range arcgisusers { + + if !(o.UserID == rel.ID) { + continue + } + + rel.R.UserUserPrivileges = append(rel.R.UserUserPrivileges, o) + + o.R.UserUser = rel + break + } + } + + return nil +} + +type arcgisUserPrivilegeJoins[Q dialect.Joinable] struct { + typ string + UserUser modAs[Q, arcgisuserColumns] +} + +func (j arcgisUserPrivilegeJoins[Q]) aliasedAs(alias string) arcgisUserPrivilegeJoins[Q] { + return buildArcgisUserPrivilegeJoins[Q](buildArcgisUserPrivilegeColumns(alias), j.typ) +} + +func buildArcgisUserPrivilegeJoins[Q dialect.Joinable](cols arcgisUserPrivilegeColumns, typ string) arcgisUserPrivilegeJoins[Q] { + return arcgisUserPrivilegeJoins[Q]{ + typ: typ, + UserUser: modAs[Q, arcgisuserColumns]{ + c: ArcgisUsers.Columns, + f: func(to arcgisuserColumns) bob.Mod[Q] { + mods := make(mods.QueryMods[Q], 0, 1) + + { + mods = append(mods, dialect.Join[Q](typ, ArcgisUsers.Name().As(to.Alias())).On( + to.ID.EQ(cols.UserID), + )) + } + + return mods + }, + }, + } +} diff --git a/db/models/bob_counts.bob.go b/db/models/bob_counts.bob.go new file mode 100644 index 00000000..be17543e --- /dev/null +++ b/db/models/bob_counts.bob.go @@ -0,0 +1,168 @@ +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package models + +import ( + "context" + "io" + + "github.com/stephenafamo/bob" + "github.com/stephenafamo/bob/dialect/psql" + "github.com/stephenafamo/bob/dialect/psql/dialect" + "github.com/stephenafamo/bob/orm" + "github.com/stephenafamo/scan" +) + +var ( + PreloadCount = getPreloadCount() + ThenLoadCount = getThenLoadCount[*dialect.SelectQuery]() + InsertThenLoadCount = getThenLoadCount[*dialect.InsertQuery]() +) + +type preloadCounts struct { + ArcgisUser arcgisuserCountPreloader + NoteAudio noteAudioCountPreloader + NoteImage noteImageCountPreloader + Organization organizationCountPreloader + PublicreportPool publicreportPoolCountPreloader + PublicreportQuick publicreportQuickCountPreloader + User userCountPreloader +} + +func getPreloadCount() preloadCounts { + return preloadCounts{ + ArcgisUser: buildArcgisUserCountPreloader(), + NoteAudio: buildNoteAudioCountPreloader(), + NoteImage: buildNoteImageCountPreloader(), + Organization: buildOrganizationCountPreloader(), + PublicreportPool: buildPublicreportPoolCountPreloader(), + PublicreportQuick: buildPublicreportQuickCountPreloader(), + User: buildUserCountPreloader(), + } +} + +type thenLoadCounts[Q orm.Loadable] struct { + ArcgisUser arcgisuserCountThenLoader[Q] + NoteAudio noteAudioCountThenLoader[Q] + NoteImage noteImageCountThenLoader[Q] + Organization organizationCountThenLoader[Q] + PublicreportPool publicreportPoolCountThenLoader[Q] + PublicreportQuick publicreportQuickCountThenLoader[Q] + User userCountThenLoader[Q] +} + +func getThenLoadCount[Q orm.Loadable]() thenLoadCounts[Q] { + return thenLoadCounts[Q]{ + ArcgisUser: buildArcgisUserCountThenLoader[Q](), + NoteAudio: buildNoteAudioCountThenLoader[Q](), + NoteImage: buildNoteImageCountThenLoader[Q](), + Organization: buildOrganizationCountThenLoader[Q](), + PublicreportPool: buildPublicreportPoolCountThenLoader[Q](), + PublicreportQuick: buildPublicreportQuickCountThenLoader[Q](), + User: buildUserCountThenLoader[Q](), + } +} + +func countThenLoadBuilder[Q orm.Loadable, T any](name string, f func(context.Context, bob.Executor, T, ...bob.Mod[*dialect.SelectQuery]) error) func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] { + return func(queryMods ...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] { + return func(ctx context.Context, exec bob.Executor, retrieved any) error { + loader, isLoader := retrieved.(T) + if !isLoader { + return nil // silently skip if not the right type + } + + return f(ctx, exec, loader, queryMods...) + } + } +} + +// countPreloadable is an interface for models that can have counts preloaded +type countPreloadable interface { + PreloadCount(name string, count int64) error +} + +// countPreloadMod is used to add a count subquery to the SELECT +type countPreloadMod[T countPreloadable] struct { + name string + countExpr func(from string) bob.Expression +} + +// Apply implements bob.Mod +func (c countPreloadMod[T]) Apply(q *dialect.SelectQuery) { + c.applyCount(q, "") +} + +// applyCount adds the count subquery to the query +func (c countPreloadMod[T]) applyCount(q *dialect.SelectQuery, parent string) { + countCol := c.countExpr(parent) + q.AppendPreloadSelect(aliasedExpr{expr: countCol, alias: "__count_" + c.name}) +} + +// aliasedExpr wraps an expression with an alias +type aliasedExpr struct { + expr bob.Expression + alias string +} + +func (a aliasedExpr) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { + args, err := a.expr.WriteSQL(ctx, w, d, start) + if err != nil { + return nil, err + } + w.WriteString(" AS ") + d.WriteQuoted(w, a.alias) + return args, nil +} + +// countPreloader returns a Preloader that adds a count subquery +func countPreloader[T countPreloadable](name string, countExpr func(from string) bob.Expression) psql.Preloader { + return func(parent string) (bob.Mod[*dialect.SelectQuery], scan.MapperMod, []bob.Loader) { + m := countPreloadMod[T]{ + name: name, + countExpr: countExpr, + } + + queryMod := bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) { + m.applyCount(q, parent) + }) + + mapperMod := func(ctx context.Context, cols []string) (scan.BeforeFunc, scan.AfterMod) { + // Find the count column + countColName := "__count_" + name + colIndex := -1 + for i, col := range cols { + if col == countColName { + colIndex = i + break + } + } + + return func(r *scan.Row) (any, error) { + if colIndex >= 0 { + var count *int64 + r.ScheduleScanByIndex(colIndex, &count) + return &count, nil + } + return nil, nil + }, func(link, retrieved any) error { + if link == nil { + return nil + } + countPtr, ok := link.(**int64) + if !ok || countPtr == nil || *countPtr == nil { + return nil + } + + loader, isLoader := retrieved.(countPreloadable) + if !isLoader { + return nil + } + + return loader.PreloadCount(name, **countPtr) + } + } + + return queryMod, mapperMod, nil + } +} diff --git a/db/models/bob_joins.bob.go b/db/models/bob_joins.bob.go index 37643b0c..03d85cb1 100644 --- a/db/models/bob_joins.bob.go +++ b/db/models/bob_joins.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -32,6 +32,8 @@ func (j joinSet[Q]) AliasedAs(alias string) joinSet[Q] { } type joins[Q dialect.Joinable] struct { + ArcgisUsers joinSet[arcgisuserJoins[Q]] + ArcgisUserPrivileges joinSet[arcgisUserPrivilegeJoins[Q]] FieldseekerContainerrelates joinSet[fieldseekerContainerrelateJoins[Q]] FieldseekerFieldscoutinglogs joinSet[fieldseekerFieldscoutinglogJoins[Q]] FieldseekerHabitatrelates joinSet[fieldseekerHabitatrelateJoins[Q]] @@ -87,6 +89,8 @@ func buildJoinSet[Q interface{ aliasedAs(string) Q }, C any, F func(C, string) Q func getJoins[Q dialect.Joinable]() joins[Q] { return joins[Q]{ + ArcgisUsers: buildJoinSet[arcgisuserJoins[Q]](ArcgisUsers.Columns, buildArcgisUserJoins), + ArcgisUserPrivileges: buildJoinSet[arcgisUserPrivilegeJoins[Q]](ArcgisUserPrivileges.Columns, buildArcgisUserPrivilegeJoins), FieldseekerContainerrelates: buildJoinSet[fieldseekerContainerrelateJoins[Q]](FieldseekerContainerrelates.Columns, buildFieldseekerContainerrelateJoins), FieldseekerFieldscoutinglogs: buildJoinSet[fieldseekerFieldscoutinglogJoins[Q]](FieldseekerFieldscoutinglogs.Columns, buildFieldseekerFieldscoutinglogJoins), FieldseekerHabitatrelates: buildJoinSet[fieldseekerHabitatrelateJoins[Q]](FieldseekerHabitatrelates.Columns, buildFieldseekerHabitatrelateJoins), diff --git a/db/models/bob_loaders.bob.go b/db/models/bob_loaders.bob.go index 5af29980..21748f91 100644 --- a/db/models/bob_loaders.bob.go +++ b/db/models/bob_loaders.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -17,6 +17,8 @@ import ( var Preload = getPreloaders() type preloaders struct { + ArcgisUser arcgisuserPreloader + ArcgisUserPrivilege arcgisUserPrivilegePreloader FieldseekerContainerrelate fieldseekerContainerrelatePreloader FieldseekerFieldscoutinglog fieldseekerFieldscoutinglogPreloader FieldseekerHabitatrelate fieldseekerHabitatrelatePreloader @@ -64,6 +66,8 @@ type preloaders struct { func getPreloaders() preloaders { return preloaders{ + ArcgisUser: buildArcgisUserPreloader(), + ArcgisUserPrivilege: buildArcgisUserPrivilegePreloader(), FieldseekerContainerrelate: buildFieldseekerContainerrelatePreloader(), FieldseekerFieldscoutinglog: buildFieldseekerFieldscoutinglogPreloader(), FieldseekerHabitatrelate: buildFieldseekerHabitatrelatePreloader(), @@ -117,6 +121,8 @@ var ( ) type thenLoaders[Q orm.Loadable] struct { + ArcgisUser arcgisuserThenLoader[Q] + ArcgisUserPrivilege arcgisUserPrivilegeThenLoader[Q] FieldseekerContainerrelate fieldseekerContainerrelateThenLoader[Q] FieldseekerFieldscoutinglog fieldseekerFieldscoutinglogThenLoader[Q] FieldseekerHabitatrelate fieldseekerHabitatrelateThenLoader[Q] @@ -164,6 +170,8 @@ type thenLoaders[Q orm.Loadable] struct { func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] { return thenLoaders[Q]{ + ArcgisUser: buildArcgisUserThenLoader[Q](), + ArcgisUserPrivilege: buildArcgisUserPrivilegeThenLoader[Q](), FieldseekerContainerrelate: buildFieldseekerContainerrelateThenLoader[Q](), FieldseekerFieldscoutinglog: buildFieldseekerFieldscoutinglogThenLoader[Q](), FieldseekerHabitatrelate: buildFieldseekerHabitatrelateThenLoader[Q](), diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go index 6af44c49..69ff2736 100644 --- a/db/models/bob_where.bob.go +++ b/db/models/bob_where.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -17,6 +17,8 @@ var ( ) func Where[Q psql.Filterable]() struct { + ArcgisUsers arcgisuserWhere[Q] + ArcgisUserPrivileges arcgisUserPrivilegeWhere[Q] Districts districtWhere[Q] FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q] FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q] @@ -72,6 +74,8 @@ func Where[Q psql.Filterable]() struct { Users userWhere[Q] } { return struct { + ArcgisUsers arcgisuserWhere[Q] + ArcgisUserPrivileges arcgisUserPrivilegeWhere[Q] Districts districtWhere[Q] FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q] FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q] @@ -126,6 +130,8 @@ func Where[Q psql.Filterable]() struct { SpatialRefSys spatialRefSyWhere[Q] Users userWhere[Q] }{ + ArcgisUsers: buildArcgisUserWhere[Q](ArcgisUsers.Columns), + ArcgisUserPrivileges: buildArcgisUserPrivilegeWhere[Q](ArcgisUserPrivileges.Columns), Districts: buildDistrictWhere[Q](Districts.Columns), FieldseekerContainerrelates: buildFieldseekerContainerrelateWhere[Q](FieldseekerContainerrelates.Columns), FieldseekerFieldscoutinglogs: buildFieldseekerFieldscoutinglogWhere[Q](FieldseekerFieldscoutinglogs.Columns), diff --git a/db/models/district.bob.go b/db/models/district.bob.go index 026f4c47..a0c3bb5b 100644 --- a/db/models/district.bob.go +++ b/db/models/district.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.containerrelate.bob.go b/db/models/fieldseeker.containerrelate.bob.go index 434c2320..8b439dce 100644 --- a/db/models/fieldseeker.containerrelate.bob.go +++ b/db/models/fieldseeker.containerrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.fieldscoutinglog.bob.go b/db/models/fieldseeker.fieldscoutinglog.bob.go index 3d88e8fd..a0caa392 100644 --- a/db/models/fieldseeker.fieldscoutinglog.bob.go +++ b/db/models/fieldseeker.fieldscoutinglog.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.habitatrelate.bob.go b/db/models/fieldseeker.habitatrelate.bob.go index f78468e3..cefb73a8 100644 --- a/db/models/fieldseeker.habitatrelate.bob.go +++ b/db/models/fieldseeker.habitatrelate.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.inspectionsample.bob.go b/db/models/fieldseeker.inspectionsample.bob.go index 16fd4908..73aaa6da 100644 --- a/db/models/fieldseeker.inspectionsample.bob.go +++ b/db/models/fieldseeker.inspectionsample.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.inspectionsampledetail.bob.go b/db/models/fieldseeker.inspectionsampledetail.bob.go index de4bebc5..d9d4d406 100644 --- a/db/models/fieldseeker.inspectionsampledetail.bob.go +++ b/db/models/fieldseeker.inspectionsampledetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.linelocation.bob.go b/db/models/fieldseeker.linelocation.bob.go index 9cafe385..9efc4ee5 100644 --- a/db/models/fieldseeker.linelocation.bob.go +++ b/db/models/fieldseeker.linelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.locationtracking.bob.go b/db/models/fieldseeker.locationtracking.bob.go index da97a897..facfcf7d 100644 --- a/db/models/fieldseeker.locationtracking.bob.go +++ b/db/models/fieldseeker.locationtracking.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.mosquitoinspection.bob.go b/db/models/fieldseeker.mosquitoinspection.bob.go index 85baa2b7..db094235 100644 --- a/db/models/fieldseeker.mosquitoinspection.bob.go +++ b/db/models/fieldseeker.mosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.pointlocation.bob.go b/db/models/fieldseeker.pointlocation.bob.go index 4a879030..e212b558 100644 --- a/db/models/fieldseeker.pointlocation.bob.go +++ b/db/models/fieldseeker.pointlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.polygonlocation.bob.go b/db/models/fieldseeker.polygonlocation.bob.go index 2e65aa46..5003caa2 100644 --- a/db/models/fieldseeker.polygonlocation.bob.go +++ b/db/models/fieldseeker.polygonlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.pool.bob.go b/db/models/fieldseeker.pool.bob.go index c204b6c0..898e7bcb 100644 --- a/db/models/fieldseeker.pool.bob.go +++ b/db/models/fieldseeker.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.pooldetail.bob.go b/db/models/fieldseeker.pooldetail.bob.go index 385f4543..a9cbd612 100644 --- a/db/models/fieldseeker.pooldetail.bob.go +++ b/db/models/fieldseeker.pooldetail.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.proposedtreatmentarea.bob.go b/db/models/fieldseeker.proposedtreatmentarea.bob.go index 9669e95f..8f89fe65 100644 --- a/db/models/fieldseeker.proposedtreatmentarea.bob.go +++ b/db/models/fieldseeker.proposedtreatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.qamosquitoinspection.bob.go b/db/models/fieldseeker.qamosquitoinspection.bob.go index b742d6b3..76fcae96 100644 --- a/db/models/fieldseeker.qamosquitoinspection.bob.go +++ b/db/models/fieldseeker.qamosquitoinspection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.rodentlocation.bob.go b/db/models/fieldseeker.rodentlocation.bob.go index 6e57a0a1..28117cfb 100644 --- a/db/models/fieldseeker.rodentlocation.bob.go +++ b/db/models/fieldseeker.rodentlocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.samplecollection.bob.go b/db/models/fieldseeker.samplecollection.bob.go index 512a787f..f3648eda 100644 --- a/db/models/fieldseeker.samplecollection.bob.go +++ b/db/models/fieldseeker.samplecollection.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.samplelocation.bob.go b/db/models/fieldseeker.samplelocation.bob.go index 6782a33b..cde38c45 100644 --- a/db/models/fieldseeker.samplelocation.bob.go +++ b/db/models/fieldseeker.samplelocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.servicerequest.bob.go b/db/models/fieldseeker.servicerequest.bob.go index 5cac059f..f3b89f50 100644 --- a/db/models/fieldseeker.servicerequest.bob.go +++ b/db/models/fieldseeker.servicerequest.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.speciesabundance.bob.go b/db/models/fieldseeker.speciesabundance.bob.go index bb8fef8f..f8b46124 100644 --- a/db/models/fieldseeker.speciesabundance.bob.go +++ b/db/models/fieldseeker.speciesabundance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.stormdrain.bob.go b/db/models/fieldseeker.stormdrain.bob.go index 8169a1cd..c603b20c 100644 --- a/db/models/fieldseeker.stormdrain.bob.go +++ b/db/models/fieldseeker.stormdrain.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.timecard.bob.go b/db/models/fieldseeker.timecard.bob.go index d5571f34..8b7b1805 100644 --- a/db/models/fieldseeker.timecard.bob.go +++ b/db/models/fieldseeker.timecard.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.trapdata.bob.go b/db/models/fieldseeker.trapdata.bob.go index e23fa62d..f6fe3f01 100644 --- a/db/models/fieldseeker.trapdata.bob.go +++ b/db/models/fieldseeker.trapdata.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.traplocation.bob.go b/db/models/fieldseeker.traplocation.bob.go index ae0123ef..a3e56cda 100644 --- a/db/models/fieldseeker.traplocation.bob.go +++ b/db/models/fieldseeker.traplocation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.treatment.bob.go b/db/models/fieldseeker.treatment.bob.go index f4129dbd..d219c571 100644 --- a/db/models/fieldseeker.treatment.bob.go +++ b/db/models/fieldseeker.treatment.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.treatmentarea.bob.go b/db/models/fieldseeker.treatmentarea.bob.go index 507f947c..6e1ffcb8 100644 --- a/db/models/fieldseeker.treatmentarea.bob.go +++ b/db/models/fieldseeker.treatmentarea.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.zones.bob.go b/db/models/fieldseeker.zones.bob.go index c6b8695b..e5e9f7b4 100644 --- a/db/models/fieldseeker.zones.bob.go +++ b/db/models/fieldseeker.zones.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker.zones2.bob.go b/db/models/fieldseeker.zones2.bob.go index 93c6badb..02e3a743 100644 --- a/db/models/fieldseeker.zones2.bob.go +++ b/db/models/fieldseeker.zones2.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/fieldseeker_sync.bob.go b/db/models/fieldseeker_sync.bob.go index b2a8ea0e..fcf5e738 100644 --- a/db/models/fieldseeker_sync.bob.go +++ b/db/models/fieldseeker_sync.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/geography_columns.bob.go b/db/models/geography_columns.bob.go index 4e1b1c04..c1452873 100644 --- a/db/models/geography_columns.bob.go +++ b/db/models/geography_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/geometry_columns.bob.go b/db/models/geometry_columns.bob.go index 9b93f543..5d875b78 100644 --- a/db/models/geometry_columns.bob.go +++ b/db/models/geometry_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/goose_db_version.bob.go b/db/models/goose_db_version.bob.go index d65bd269..19519e27 100644 --- a/db/models/goose_db_version.bob.go +++ b/db/models/goose_db_version.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/h3_aggregation.bob.go b/db/models/h3_aggregation.bob.go index 476bdba1..7e09d5c5 100644 --- a/db/models/h3_aggregation.bob.go +++ b/db/models/h3_aggregation.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/note_audio.bob.go b/db/models/note_audio.bob.go index b491baed..204cb229 100644 --- a/db/models/note_audio.bob.go +++ b/db/models/note_audio.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -39,6 +39,8 @@ type NoteAudio struct { UUID uuid.UUID `db:"uuid,pk" ` R noteAudioR `db:"-" ` + + C noteAudioC `db:"-" ` } // NoteAudioSlice is an alias for a slice of pointers to NoteAudio. @@ -1487,6 +1489,162 @@ func (os NoteAudioSlice) LoadNoteAudioData(ctx context.Context, exec bob.Executo return nil } +// noteAudioC is where relationship counts are stored. +type noteAudioC struct { + NoteAudioBreadcrumbs *int64 + NoteAudioData *int64 +} + +// PreloadCount sets a count in the C struct by name +func (o *NoteAudio) PreloadCount(name string, count int64) error { + if o == nil { + return nil + } + + switch name { + case "NoteAudioBreadcrumbs": + o.C.NoteAudioBreadcrumbs = &count + case "NoteAudioData": + o.C.NoteAudioData = &count + } + return nil +} + +type noteAudioCountPreloader struct { + NoteAudioBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + NoteAudioData func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader +} + +func buildNoteAudioCountPreloader() noteAudioCountPreloader { + return noteAudioCountPreloader{ + NoteAudioBreadcrumbs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*NoteAudio]("NoteAudioBreadcrumbs", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = NoteAudios.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteAudioBreadcrumbs.Name()), + sm.Where(psql.Quote(NoteAudioBreadcrumbs.Alias(), "note_audio_version").EQ(psql.Quote(parent, "version"))), + sm.Where(psql.Quote(NoteAudioBreadcrumbs.Alias(), "note_audio_uuid").EQ(psql.Quote(parent, "uuid"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + NoteAudioData: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*NoteAudio]("NoteAudioData", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = NoteAudios.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteAudioData.Name()), + sm.Where(psql.Quote(NoteAudioData.Alias(), "note_audio_version").EQ(psql.Quote(parent, "version"))), + sm.Where(psql.Quote(NoteAudioData.Alias(), "note_audio_uuid").EQ(psql.Quote(parent, "uuid"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + } +} + +type noteAudioCountThenLoader[Q orm.Loadable] struct { + NoteAudioBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + NoteAudioData func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildNoteAudioCountThenLoader[Q orm.Loadable]() noteAudioCountThenLoader[Q] { + type NoteAudioBreadcrumbsCountInterface interface { + LoadCountNoteAudioBreadcrumbs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type NoteAudioDataCountInterface interface { + LoadCountNoteAudioData(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return noteAudioCountThenLoader[Q]{ + NoteAudioBreadcrumbs: countThenLoadBuilder[Q]( + "NoteAudioBreadcrumbs", + func(ctx context.Context, exec bob.Executor, retrieved NoteAudioBreadcrumbsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountNoteAudioBreadcrumbs(ctx, exec, mods...) + }, + ), + NoteAudioData: countThenLoadBuilder[Q]( + "NoteAudioData", + func(ctx context.Context, exec bob.Executor, retrieved NoteAudioDataCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountNoteAudioData(ctx, exec, mods...) + }, + ), + } +} + +// LoadCountNoteAudioBreadcrumbs loads the count of NoteAudioBreadcrumbs into the C struct +func (o *NoteAudio) LoadCountNoteAudioBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.NoteAudioBreadcrumbs(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.NoteAudioBreadcrumbs = &count + return nil +} + +// LoadCountNoteAudioBreadcrumbs loads the count of NoteAudioBreadcrumbs for a slice +func (os NoteAudioSlice) LoadCountNoteAudioBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountNoteAudioBreadcrumbs(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountNoteAudioData loads the count of NoteAudioData into the C struct +func (o *NoteAudio) LoadCountNoteAudioData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.NoteAudioData(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.NoteAudioData = &count + return nil +} + +// LoadCountNoteAudioData loads the count of NoteAudioData for a slice +func (os NoteAudioSlice) LoadCountNoteAudioData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountNoteAudioData(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + type noteAudioJoins[Q dialect.Joinable] struct { typ string CreatorUser modAs[Q, userColumns] diff --git a/db/models/note_audio_breadcrumb.bob.go b/db/models/note_audio_breadcrumb.bob.go index 5dd41d5b..67165c53 100644 --- a/db/models/note_audio_breadcrumb.bob.go +++ b/db/models/note_audio_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/note_audio_data.bob.go b/db/models/note_audio_data.bob.go index b4a9ec78..89dd6055 100644 --- a/db/models/note_audio_data.bob.go +++ b/db/models/note_audio_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/note_image.bob.go b/db/models/note_image.bob.go index 071a1ace..34e4edd2 100644 --- a/db/models/note_image.bob.go +++ b/db/models/note_image.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -36,6 +36,8 @@ type NoteImage struct { UUID uuid.UUID `db:"uuid,pk" ` R noteImageR `db:"-" ` + + C noteImageC `db:"-" ` } // NoteImageSlice is an alias for a slice of pointers to NoteImage. @@ -1412,6 +1414,162 @@ func (os NoteImageSlice) LoadNoteImageData(ctx context.Context, exec bob.Executo return nil } +// noteImageC is where relationship counts are stored. +type noteImageC struct { + NoteImageBreadcrumbs *int64 + NoteImageData *int64 +} + +// PreloadCount sets a count in the C struct by name +func (o *NoteImage) PreloadCount(name string, count int64) error { + if o == nil { + return nil + } + + switch name { + case "NoteImageBreadcrumbs": + o.C.NoteImageBreadcrumbs = &count + case "NoteImageData": + o.C.NoteImageData = &count + } + return nil +} + +type noteImageCountPreloader struct { + NoteImageBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + NoteImageData func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader +} + +func buildNoteImageCountPreloader() noteImageCountPreloader { + return noteImageCountPreloader{ + NoteImageBreadcrumbs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*NoteImage]("NoteImageBreadcrumbs", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = NoteImages.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteImageBreadcrumbs.Name()), + sm.Where(psql.Quote(NoteImageBreadcrumbs.Alias(), "note_image_version").EQ(psql.Quote(parent, "version"))), + sm.Where(psql.Quote(NoteImageBreadcrumbs.Alias(), "note_image_uuid").EQ(psql.Quote(parent, "uuid"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + NoteImageData: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*NoteImage]("NoteImageData", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = NoteImages.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteImageData.Name()), + sm.Where(psql.Quote(NoteImageData.Alias(), "note_image_version").EQ(psql.Quote(parent, "version"))), + sm.Where(psql.Quote(NoteImageData.Alias(), "note_image_uuid").EQ(psql.Quote(parent, "uuid"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + } +} + +type noteImageCountThenLoader[Q orm.Loadable] struct { + NoteImageBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + NoteImageData func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildNoteImageCountThenLoader[Q orm.Loadable]() noteImageCountThenLoader[Q] { + type NoteImageBreadcrumbsCountInterface interface { + LoadCountNoteImageBreadcrumbs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type NoteImageDataCountInterface interface { + LoadCountNoteImageData(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return noteImageCountThenLoader[Q]{ + NoteImageBreadcrumbs: countThenLoadBuilder[Q]( + "NoteImageBreadcrumbs", + func(ctx context.Context, exec bob.Executor, retrieved NoteImageBreadcrumbsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountNoteImageBreadcrumbs(ctx, exec, mods...) + }, + ), + NoteImageData: countThenLoadBuilder[Q]( + "NoteImageData", + func(ctx context.Context, exec bob.Executor, retrieved NoteImageDataCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountNoteImageData(ctx, exec, mods...) + }, + ), + } +} + +// LoadCountNoteImageBreadcrumbs loads the count of NoteImageBreadcrumbs into the C struct +func (o *NoteImage) LoadCountNoteImageBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.NoteImageBreadcrumbs(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.NoteImageBreadcrumbs = &count + return nil +} + +// LoadCountNoteImageBreadcrumbs loads the count of NoteImageBreadcrumbs for a slice +func (os NoteImageSlice) LoadCountNoteImageBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountNoteImageBreadcrumbs(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountNoteImageData loads the count of NoteImageData into the C struct +func (o *NoteImage) LoadCountNoteImageData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.NoteImageData(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.NoteImageData = &count + return nil +} + +// LoadCountNoteImageData loads the count of NoteImageData for a slice +func (os NoteImageSlice) LoadCountNoteImageData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountNoteImageData(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + type noteImageJoins[Q dialect.Joinable] struct { typ string CreatorUser modAs[Q, userColumns] diff --git a/db/models/note_image_breadcrumb.bob.go b/db/models/note_image_breadcrumb.bob.go index eee5ba78..be232187 100644 --- a/db/models/note_image_breadcrumb.bob.go +++ b/db/models/note_image_breadcrumb.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/note_image_data.bob.go b/db/models/note_image_data.bob.go index 7adfe9b2..2eb3f729 100644 --- a/db/models/note_image_data.bob.go +++ b/db/models/note_image_data.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/notification.bob.go b/db/models/notification.bob.go index 5456125b..ee150774 100644 --- a/db/models/notification.bob.go +++ b/db/models/notification.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/oauth_token.bob.go b/db/models/oauth_token.bob.go index cd7ff27d..9b8c7156 100644 --- a/db/models/oauth_token.bob.go +++ b/db/models/oauth_token.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/organization.bob.go b/db/models/organization.bob.go index f9bfcc28..256a8f90 100644 --- a/db/models/organization.bob.go +++ b/db/models/organization.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -32,6 +32,8 @@ type Organization struct { FieldseekerURL null.Val[string] `db:"fieldseeker_url" ` R organizationR `db:"-" ` + + C organizationC `db:"-" ` } // OrganizationSlice is an alias for a slice of pointers to Organization. @@ -6182,6 +6184,1990 @@ func (os OrganizationSlice) LoadUser(ctx context.Context, exec bob.Executor, mod return nil } +// organizationC is where relationship counts are stored. +type organizationC struct { + Containerrelates *int64 + Fieldscoutinglogs *int64 + Habitatrelates *int64 + Inspectionsamples *int64 + Inspectionsampledetails *int64 + Linelocations *int64 + Locationtrackings *int64 + Mosquitoinspections *int64 + Pointlocations *int64 + Polygonlocations *int64 + Pools *int64 + Pooldetails *int64 + Proposedtreatmentareas *int64 + Qamosquitoinspections *int64 + Rodentlocations *int64 + Samplecollections *int64 + Samplelocations *int64 + Servicerequests *int64 + Speciesabundances *int64 + Stormdrains *int64 + Timecards *int64 + Trapdata *int64 + Traplocations *int64 + Treatments *int64 + Treatmentareas *int64 + Zones *int64 + Zones2s *int64 + FieldseekerSyncs *int64 + H3Aggregations *int64 + NoteAudios *int64 + NoteImages *int64 + User *int64 +} + +// PreloadCount sets a count in the C struct by name +func (o *Organization) PreloadCount(name string, count int64) error { + if o == nil { + return nil + } + + switch name { + case "Containerrelates": + o.C.Containerrelates = &count + case "Fieldscoutinglogs": + o.C.Fieldscoutinglogs = &count + case "Habitatrelates": + o.C.Habitatrelates = &count + case "Inspectionsamples": + o.C.Inspectionsamples = &count + case "Inspectionsampledetails": + o.C.Inspectionsampledetails = &count + case "Linelocations": + o.C.Linelocations = &count + case "Locationtrackings": + o.C.Locationtrackings = &count + case "Mosquitoinspections": + o.C.Mosquitoinspections = &count + case "Pointlocations": + o.C.Pointlocations = &count + case "Polygonlocations": + o.C.Polygonlocations = &count + case "Pools": + o.C.Pools = &count + case "Pooldetails": + o.C.Pooldetails = &count + case "Proposedtreatmentareas": + o.C.Proposedtreatmentareas = &count + case "Qamosquitoinspections": + o.C.Qamosquitoinspections = &count + case "Rodentlocations": + o.C.Rodentlocations = &count + case "Samplecollections": + o.C.Samplecollections = &count + case "Samplelocations": + o.C.Samplelocations = &count + case "Servicerequests": + o.C.Servicerequests = &count + case "Speciesabundances": + o.C.Speciesabundances = &count + case "Stormdrains": + o.C.Stormdrains = &count + case "Timecards": + o.C.Timecards = &count + case "Trapdata": + o.C.Trapdata = &count + case "Traplocations": + o.C.Traplocations = &count + case "Treatments": + o.C.Treatments = &count + case "Treatmentareas": + o.C.Treatmentareas = &count + case "Zones": + o.C.Zones = &count + case "Zones2s": + o.C.Zones2s = &count + case "FieldseekerSyncs": + o.C.FieldseekerSyncs = &count + case "H3Aggregations": + o.C.H3Aggregations = &count + case "NoteAudios": + o.C.NoteAudios = &count + case "NoteImages": + o.C.NoteImages = &count + case "User": + o.C.User = &count + } + return nil +} + +type organizationCountPreloader struct { + Containerrelates func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Linelocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Pointlocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Pools func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Pooldetails func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Samplecollections func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Samplelocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Servicerequests func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Stormdrains func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Timecards func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Trapdata func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Traplocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Treatments func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Zones func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + Zones2s func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + NoteAudios func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + NoteImages func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + User func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader +} + +func buildOrganizationCountPreloader() organizationCountPreloader { + return organizationCountPreloader{ + Containerrelates: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Containerrelates", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerContainerrelates.Name()), + sm.Where(psql.Quote(FieldseekerContainerrelates.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Fieldscoutinglogs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Fieldscoutinglogs", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerFieldscoutinglogs.Name()), + sm.Where(psql.Quote(FieldseekerFieldscoutinglogs.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Habitatrelates: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Habitatrelates", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerHabitatrelates.Name()), + sm.Where(psql.Quote(FieldseekerHabitatrelates.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Inspectionsamples: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Inspectionsamples", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerInspectionsamples.Name()), + sm.Where(psql.Quote(FieldseekerInspectionsamples.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Inspectionsampledetails: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Inspectionsampledetails", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerInspectionsampledetails.Name()), + sm.Where(psql.Quote(FieldseekerInspectionsampledetails.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Linelocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Linelocations", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerLinelocations.Name()), + sm.Where(psql.Quote(FieldseekerLinelocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Locationtrackings: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Locationtrackings", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerLocationtrackings.Name()), + sm.Where(psql.Quote(FieldseekerLocationtrackings.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Mosquitoinspections: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Mosquitoinspections", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerMosquitoinspections.Name()), + sm.Where(psql.Quote(FieldseekerMosquitoinspections.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Pointlocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Pointlocations", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerPointlocations.Name()), + sm.Where(psql.Quote(FieldseekerPointlocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Polygonlocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Polygonlocations", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerPolygonlocations.Name()), + sm.Where(psql.Quote(FieldseekerPolygonlocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Pools: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Pools", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerPools.Name()), + sm.Where(psql.Quote(FieldseekerPools.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Pooldetails: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Pooldetails", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerPooldetails.Name()), + sm.Where(psql.Quote(FieldseekerPooldetails.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Proposedtreatmentareas: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Proposedtreatmentareas", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerProposedtreatmentareas.Name()), + sm.Where(psql.Quote(FieldseekerProposedtreatmentareas.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Qamosquitoinspections: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Qamosquitoinspections", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerQamosquitoinspections.Name()), + sm.Where(psql.Quote(FieldseekerQamosquitoinspections.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Rodentlocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Rodentlocations", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerRodentlocations.Name()), + sm.Where(psql.Quote(FieldseekerRodentlocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Samplecollections: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Samplecollections", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerSamplecollections.Name()), + sm.Where(psql.Quote(FieldseekerSamplecollections.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Samplelocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Samplelocations", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerSamplelocations.Name()), + sm.Where(psql.Quote(FieldseekerSamplelocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Servicerequests: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Servicerequests", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerServicerequests.Name()), + sm.Where(psql.Quote(FieldseekerServicerequests.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Speciesabundances: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Speciesabundances", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerSpeciesabundances.Name()), + sm.Where(psql.Quote(FieldseekerSpeciesabundances.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Stormdrains: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Stormdrains", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerStormdrains.Name()), + sm.Where(psql.Quote(FieldseekerStormdrains.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Timecards: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Timecards", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerTimecards.Name()), + sm.Where(psql.Quote(FieldseekerTimecards.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Trapdata: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Trapdata", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerTrapdata.Name()), + sm.Where(psql.Quote(FieldseekerTrapdata.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Traplocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Traplocations", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerTraplocations.Name()), + sm.Where(psql.Quote(FieldseekerTraplocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Treatments: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Treatments", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerTreatments.Name()), + sm.Where(psql.Quote(FieldseekerTreatments.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Treatmentareas: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Treatmentareas", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerTreatmentareas.Name()), + sm.Where(psql.Quote(FieldseekerTreatmentareas.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Zones: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Zones", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerZones.Name()), + sm.Where(psql.Quote(FieldseekerZones.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + Zones2s: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("Zones2s", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerZones2s.Name()), + sm.Where(psql.Quote(FieldseekerZones2s.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + FieldseekerSyncs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("FieldseekerSyncs", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(FieldseekerSyncs.Name()), + sm.Where(psql.Quote(FieldseekerSyncs.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + H3Aggregations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("H3Aggregations", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(H3Aggregations.Name()), + sm.Where(psql.Quote(H3Aggregations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + NoteAudios: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("NoteAudios", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteAudios.Name()), + sm.Where(psql.Quote(NoteAudios.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + NoteImages: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("NoteImages", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteImages.Name()), + sm.Where(psql.Quote(NoteImages.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + User: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*Organization]("User", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Organizations.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(Users.Name()), + sm.Where(psql.Quote(Users.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + } +} + +type organizationCountThenLoader[Q orm.Loadable] struct { + Containerrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Linelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Pointlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Pooldetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Samplecollections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Samplelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Servicerequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Stormdrains func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Timecards func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Trapdata func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Traplocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Treatments func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Zones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + User func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildOrganizationCountThenLoader[Q orm.Loadable]() organizationCountThenLoader[Q] { + type ContainerrelatesCountInterface interface { + LoadCountContainerrelates(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type FieldscoutinglogsCountInterface interface { + LoadCountFieldscoutinglogs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type HabitatrelatesCountInterface interface { + LoadCountHabitatrelates(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type InspectionsamplesCountInterface interface { + LoadCountInspectionsamples(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type InspectionsampledetailsCountInterface interface { + LoadCountInspectionsampledetails(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type LinelocationsCountInterface interface { + LoadCountLinelocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type LocationtrackingsCountInterface interface { + LoadCountLocationtrackings(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type MosquitoinspectionsCountInterface interface { + LoadCountMosquitoinspections(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type PointlocationsCountInterface interface { + LoadCountPointlocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type PolygonlocationsCountInterface interface { + LoadCountPolygonlocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type PoolsCountInterface interface { + LoadCountPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type PooldetailsCountInterface interface { + LoadCountPooldetails(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type ProposedtreatmentareasCountInterface interface { + LoadCountProposedtreatmentareas(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type QamosquitoinspectionsCountInterface interface { + LoadCountQamosquitoinspections(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type RodentlocationsCountInterface interface { + LoadCountRodentlocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type SamplecollectionsCountInterface interface { + LoadCountSamplecollections(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type SamplelocationsCountInterface interface { + LoadCountSamplelocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type ServicerequestsCountInterface interface { + LoadCountServicerequests(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type SpeciesabundancesCountInterface interface { + LoadCountSpeciesabundances(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type StormdrainsCountInterface interface { + LoadCountStormdrains(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type TimecardsCountInterface interface { + LoadCountTimecards(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type TrapdataCountInterface interface { + LoadCountTrapdata(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type TraplocationsCountInterface interface { + LoadCountTraplocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type TreatmentsCountInterface interface { + LoadCountTreatments(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type TreatmentareasCountInterface interface { + LoadCountTreatmentareas(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type ZonesCountInterface interface { + LoadCountZones(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type Zones2sCountInterface interface { + LoadCountZones2s(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type FieldseekerSyncsCountInterface interface { + LoadCountFieldseekerSyncs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type H3AggregationsCountInterface interface { + LoadCountH3Aggregations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type NoteAudiosCountInterface interface { + LoadCountNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type NoteImagesCountInterface interface { + LoadCountNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type UserCountInterface interface { + LoadCountUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return organizationCountThenLoader[Q]{ + Containerrelates: countThenLoadBuilder[Q]( + "Containerrelates", + func(ctx context.Context, exec bob.Executor, retrieved ContainerrelatesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountContainerrelates(ctx, exec, mods...) + }, + ), + Fieldscoutinglogs: countThenLoadBuilder[Q]( + "Fieldscoutinglogs", + func(ctx context.Context, exec bob.Executor, retrieved FieldscoutinglogsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountFieldscoutinglogs(ctx, exec, mods...) + }, + ), + Habitatrelates: countThenLoadBuilder[Q]( + "Habitatrelates", + func(ctx context.Context, exec bob.Executor, retrieved HabitatrelatesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountHabitatrelates(ctx, exec, mods...) + }, + ), + Inspectionsamples: countThenLoadBuilder[Q]( + "Inspectionsamples", + func(ctx context.Context, exec bob.Executor, retrieved InspectionsamplesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountInspectionsamples(ctx, exec, mods...) + }, + ), + Inspectionsampledetails: countThenLoadBuilder[Q]( + "Inspectionsampledetails", + func(ctx context.Context, exec bob.Executor, retrieved InspectionsampledetailsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountInspectionsampledetails(ctx, exec, mods...) + }, + ), + Linelocations: countThenLoadBuilder[Q]( + "Linelocations", + func(ctx context.Context, exec bob.Executor, retrieved LinelocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountLinelocations(ctx, exec, mods...) + }, + ), + Locationtrackings: countThenLoadBuilder[Q]( + "Locationtrackings", + func(ctx context.Context, exec bob.Executor, retrieved LocationtrackingsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountLocationtrackings(ctx, exec, mods...) + }, + ), + Mosquitoinspections: countThenLoadBuilder[Q]( + "Mosquitoinspections", + func(ctx context.Context, exec bob.Executor, retrieved MosquitoinspectionsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountMosquitoinspections(ctx, exec, mods...) + }, + ), + Pointlocations: countThenLoadBuilder[Q]( + "Pointlocations", + func(ctx context.Context, exec bob.Executor, retrieved PointlocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountPointlocations(ctx, exec, mods...) + }, + ), + Polygonlocations: countThenLoadBuilder[Q]( + "Polygonlocations", + func(ctx context.Context, exec bob.Executor, retrieved PolygonlocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountPolygonlocations(ctx, exec, mods...) + }, + ), + Pools: countThenLoadBuilder[Q]( + "Pools", + func(ctx context.Context, exec bob.Executor, retrieved PoolsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountPools(ctx, exec, mods...) + }, + ), + Pooldetails: countThenLoadBuilder[Q]( + "Pooldetails", + func(ctx context.Context, exec bob.Executor, retrieved PooldetailsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountPooldetails(ctx, exec, mods...) + }, + ), + Proposedtreatmentareas: countThenLoadBuilder[Q]( + "Proposedtreatmentareas", + func(ctx context.Context, exec bob.Executor, retrieved ProposedtreatmentareasCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountProposedtreatmentareas(ctx, exec, mods...) + }, + ), + Qamosquitoinspections: countThenLoadBuilder[Q]( + "Qamosquitoinspections", + func(ctx context.Context, exec bob.Executor, retrieved QamosquitoinspectionsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountQamosquitoinspections(ctx, exec, mods...) + }, + ), + Rodentlocations: countThenLoadBuilder[Q]( + "Rodentlocations", + func(ctx context.Context, exec bob.Executor, retrieved RodentlocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountRodentlocations(ctx, exec, mods...) + }, + ), + Samplecollections: countThenLoadBuilder[Q]( + "Samplecollections", + func(ctx context.Context, exec bob.Executor, retrieved SamplecollectionsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountSamplecollections(ctx, exec, mods...) + }, + ), + Samplelocations: countThenLoadBuilder[Q]( + "Samplelocations", + func(ctx context.Context, exec bob.Executor, retrieved SamplelocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountSamplelocations(ctx, exec, mods...) + }, + ), + Servicerequests: countThenLoadBuilder[Q]( + "Servicerequests", + func(ctx context.Context, exec bob.Executor, retrieved ServicerequestsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountServicerequests(ctx, exec, mods...) + }, + ), + Speciesabundances: countThenLoadBuilder[Q]( + "Speciesabundances", + func(ctx context.Context, exec bob.Executor, retrieved SpeciesabundancesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountSpeciesabundances(ctx, exec, mods...) + }, + ), + Stormdrains: countThenLoadBuilder[Q]( + "Stormdrains", + func(ctx context.Context, exec bob.Executor, retrieved StormdrainsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountStormdrains(ctx, exec, mods...) + }, + ), + Timecards: countThenLoadBuilder[Q]( + "Timecards", + func(ctx context.Context, exec bob.Executor, retrieved TimecardsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountTimecards(ctx, exec, mods...) + }, + ), + Trapdata: countThenLoadBuilder[Q]( + "Trapdata", + func(ctx context.Context, exec bob.Executor, retrieved TrapdataCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountTrapdata(ctx, exec, mods...) + }, + ), + Traplocations: countThenLoadBuilder[Q]( + "Traplocations", + func(ctx context.Context, exec bob.Executor, retrieved TraplocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountTraplocations(ctx, exec, mods...) + }, + ), + Treatments: countThenLoadBuilder[Q]( + "Treatments", + func(ctx context.Context, exec bob.Executor, retrieved TreatmentsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountTreatments(ctx, exec, mods...) + }, + ), + Treatmentareas: countThenLoadBuilder[Q]( + "Treatmentareas", + func(ctx context.Context, exec bob.Executor, retrieved TreatmentareasCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountTreatmentareas(ctx, exec, mods...) + }, + ), + Zones: countThenLoadBuilder[Q]( + "Zones", + func(ctx context.Context, exec bob.Executor, retrieved ZonesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountZones(ctx, exec, mods...) + }, + ), + Zones2s: countThenLoadBuilder[Q]( + "Zones2s", + func(ctx context.Context, exec bob.Executor, retrieved Zones2sCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountZones2s(ctx, exec, mods...) + }, + ), + FieldseekerSyncs: countThenLoadBuilder[Q]( + "FieldseekerSyncs", + func(ctx context.Context, exec bob.Executor, retrieved FieldseekerSyncsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountFieldseekerSyncs(ctx, exec, mods...) + }, + ), + H3Aggregations: countThenLoadBuilder[Q]( + "H3Aggregations", + func(ctx context.Context, exec bob.Executor, retrieved H3AggregationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountH3Aggregations(ctx, exec, mods...) + }, + ), + NoteAudios: countThenLoadBuilder[Q]( + "NoteAudios", + func(ctx context.Context, exec bob.Executor, retrieved NoteAudiosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountNoteAudios(ctx, exec, mods...) + }, + ), + NoteImages: countThenLoadBuilder[Q]( + "NoteImages", + func(ctx context.Context, exec bob.Executor, retrieved NoteImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountNoteImages(ctx, exec, mods...) + }, + ), + User: countThenLoadBuilder[Q]( + "User", + func(ctx context.Context, exec bob.Executor, retrieved UserCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountUser(ctx, exec, mods...) + }, + ), + } +} + +// LoadCountContainerrelates loads the count of Containerrelates into the C struct +func (o *Organization) LoadCountContainerrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Containerrelates(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Containerrelates = &count + return nil +} + +// LoadCountContainerrelates loads the count of Containerrelates for a slice +func (os OrganizationSlice) LoadCountContainerrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountContainerrelates(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountFieldscoutinglogs loads the count of Fieldscoutinglogs into the C struct +func (o *Organization) LoadCountFieldscoutinglogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Fieldscoutinglogs(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Fieldscoutinglogs = &count + return nil +} + +// LoadCountFieldscoutinglogs loads the count of Fieldscoutinglogs for a slice +func (os OrganizationSlice) LoadCountFieldscoutinglogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountFieldscoutinglogs(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountHabitatrelates loads the count of Habitatrelates into the C struct +func (o *Organization) LoadCountHabitatrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Habitatrelates(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Habitatrelates = &count + return nil +} + +// LoadCountHabitatrelates loads the count of Habitatrelates for a slice +func (os OrganizationSlice) LoadCountHabitatrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountHabitatrelates(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountInspectionsamples loads the count of Inspectionsamples into the C struct +func (o *Organization) LoadCountInspectionsamples(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Inspectionsamples(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Inspectionsamples = &count + return nil +} + +// LoadCountInspectionsamples loads the count of Inspectionsamples for a slice +func (os OrganizationSlice) LoadCountInspectionsamples(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountInspectionsamples(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountInspectionsampledetails loads the count of Inspectionsampledetails into the C struct +func (o *Organization) LoadCountInspectionsampledetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Inspectionsampledetails(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Inspectionsampledetails = &count + return nil +} + +// LoadCountInspectionsampledetails loads the count of Inspectionsampledetails for a slice +func (os OrganizationSlice) LoadCountInspectionsampledetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountInspectionsampledetails(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountLinelocations loads the count of Linelocations into the C struct +func (o *Organization) LoadCountLinelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Linelocations(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Linelocations = &count + return nil +} + +// LoadCountLinelocations loads the count of Linelocations for a slice +func (os OrganizationSlice) LoadCountLinelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountLinelocations(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountLocationtrackings loads the count of Locationtrackings into the C struct +func (o *Organization) LoadCountLocationtrackings(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Locationtrackings(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Locationtrackings = &count + return nil +} + +// LoadCountLocationtrackings loads the count of Locationtrackings for a slice +func (os OrganizationSlice) LoadCountLocationtrackings(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountLocationtrackings(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountMosquitoinspections loads the count of Mosquitoinspections into the C struct +func (o *Organization) LoadCountMosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Mosquitoinspections(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Mosquitoinspections = &count + return nil +} + +// LoadCountMosquitoinspections loads the count of Mosquitoinspections for a slice +func (os OrganizationSlice) LoadCountMosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountMosquitoinspections(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountPointlocations loads the count of Pointlocations into the C struct +func (o *Organization) LoadCountPointlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Pointlocations(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Pointlocations = &count + return nil +} + +// LoadCountPointlocations loads the count of Pointlocations for a slice +func (os OrganizationSlice) LoadCountPointlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountPointlocations(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountPolygonlocations loads the count of Polygonlocations into the C struct +func (o *Organization) LoadCountPolygonlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Polygonlocations(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Polygonlocations = &count + return nil +} + +// LoadCountPolygonlocations loads the count of Polygonlocations for a slice +func (os OrganizationSlice) LoadCountPolygonlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountPolygonlocations(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountPools loads the count of Pools into the C struct +func (o *Organization) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Pools(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Pools = &count + return nil +} + +// LoadCountPools loads the count of Pools for a slice +func (os OrganizationSlice) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountPools(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountPooldetails loads the count of Pooldetails into the C struct +func (o *Organization) LoadCountPooldetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Pooldetails(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Pooldetails = &count + return nil +} + +// LoadCountPooldetails loads the count of Pooldetails for a slice +func (os OrganizationSlice) LoadCountPooldetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountPooldetails(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountProposedtreatmentareas loads the count of Proposedtreatmentareas into the C struct +func (o *Organization) LoadCountProposedtreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Proposedtreatmentareas(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Proposedtreatmentareas = &count + return nil +} + +// LoadCountProposedtreatmentareas loads the count of Proposedtreatmentareas for a slice +func (os OrganizationSlice) LoadCountProposedtreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountProposedtreatmentareas(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountQamosquitoinspections loads the count of Qamosquitoinspections into the C struct +func (o *Organization) LoadCountQamosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Qamosquitoinspections(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Qamosquitoinspections = &count + return nil +} + +// LoadCountQamosquitoinspections loads the count of Qamosquitoinspections for a slice +func (os OrganizationSlice) LoadCountQamosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountQamosquitoinspections(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountRodentlocations loads the count of Rodentlocations into the C struct +func (o *Organization) LoadCountRodentlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Rodentlocations(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Rodentlocations = &count + return nil +} + +// LoadCountRodentlocations loads the count of Rodentlocations for a slice +func (os OrganizationSlice) LoadCountRodentlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountRodentlocations(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountSamplecollections loads the count of Samplecollections into the C struct +func (o *Organization) LoadCountSamplecollections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Samplecollections(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Samplecollections = &count + return nil +} + +// LoadCountSamplecollections loads the count of Samplecollections for a slice +func (os OrganizationSlice) LoadCountSamplecollections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountSamplecollections(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountSamplelocations loads the count of Samplelocations into the C struct +func (o *Organization) LoadCountSamplelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Samplelocations(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Samplelocations = &count + return nil +} + +// LoadCountSamplelocations loads the count of Samplelocations for a slice +func (os OrganizationSlice) LoadCountSamplelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountSamplelocations(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountServicerequests loads the count of Servicerequests into the C struct +func (o *Organization) LoadCountServicerequests(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Servicerequests(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Servicerequests = &count + return nil +} + +// LoadCountServicerequests loads the count of Servicerequests for a slice +func (os OrganizationSlice) LoadCountServicerequests(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountServicerequests(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountSpeciesabundances loads the count of Speciesabundances into the C struct +func (o *Organization) LoadCountSpeciesabundances(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Speciesabundances(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Speciesabundances = &count + return nil +} + +// LoadCountSpeciesabundances loads the count of Speciesabundances for a slice +func (os OrganizationSlice) LoadCountSpeciesabundances(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountSpeciesabundances(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountStormdrains loads the count of Stormdrains into the C struct +func (o *Organization) LoadCountStormdrains(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Stormdrains(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Stormdrains = &count + return nil +} + +// LoadCountStormdrains loads the count of Stormdrains for a slice +func (os OrganizationSlice) LoadCountStormdrains(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountStormdrains(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountTimecards loads the count of Timecards into the C struct +func (o *Organization) LoadCountTimecards(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Timecards(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Timecards = &count + return nil +} + +// LoadCountTimecards loads the count of Timecards for a slice +func (os OrganizationSlice) LoadCountTimecards(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountTimecards(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountTrapdata loads the count of Trapdata into the C struct +func (o *Organization) LoadCountTrapdata(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Trapdata(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Trapdata = &count + return nil +} + +// LoadCountTrapdata loads the count of Trapdata for a slice +func (os OrganizationSlice) LoadCountTrapdata(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountTrapdata(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountTraplocations loads the count of Traplocations into the C struct +func (o *Organization) LoadCountTraplocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Traplocations(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Traplocations = &count + return nil +} + +// LoadCountTraplocations loads the count of Traplocations for a slice +func (os OrganizationSlice) LoadCountTraplocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountTraplocations(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountTreatments loads the count of Treatments into the C struct +func (o *Organization) LoadCountTreatments(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Treatments(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Treatments = &count + return nil +} + +// LoadCountTreatments loads the count of Treatments for a slice +func (os OrganizationSlice) LoadCountTreatments(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountTreatments(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountTreatmentareas loads the count of Treatmentareas into the C struct +func (o *Organization) LoadCountTreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Treatmentareas(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Treatmentareas = &count + return nil +} + +// LoadCountTreatmentareas loads the count of Treatmentareas for a slice +func (os OrganizationSlice) LoadCountTreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountTreatmentareas(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountZones loads the count of Zones into the C struct +func (o *Organization) LoadCountZones(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Zones(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Zones = &count + return nil +} + +// LoadCountZones loads the count of Zones for a slice +func (os OrganizationSlice) LoadCountZones(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountZones(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountZones2s loads the count of Zones2s into the C struct +func (o *Organization) LoadCountZones2s(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.Zones2s(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.Zones2s = &count + return nil +} + +// LoadCountZones2s loads the count of Zones2s for a slice +func (os OrganizationSlice) LoadCountZones2s(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountZones2s(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountFieldseekerSyncs loads the count of FieldseekerSyncs into the C struct +func (o *Organization) LoadCountFieldseekerSyncs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.FieldseekerSyncs(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.FieldseekerSyncs = &count + return nil +} + +// LoadCountFieldseekerSyncs loads the count of FieldseekerSyncs for a slice +func (os OrganizationSlice) LoadCountFieldseekerSyncs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountFieldseekerSyncs(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountH3Aggregations loads the count of H3Aggregations into the C struct +func (o *Organization) LoadCountH3Aggregations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.H3Aggregations(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.H3Aggregations = &count + return nil +} + +// LoadCountH3Aggregations loads the count of H3Aggregations for a slice +func (os OrganizationSlice) LoadCountH3Aggregations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountH3Aggregations(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountNoteAudios loads the count of NoteAudios into the C struct +func (o *Organization) LoadCountNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.NoteAudios(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.NoteAudios = &count + return nil +} + +// LoadCountNoteAudios loads the count of NoteAudios for a slice +func (os OrganizationSlice) LoadCountNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountNoteAudios(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountNoteImages loads the count of NoteImages into the C struct +func (o *Organization) LoadCountNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.NoteImages(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.NoteImages = &count + return nil +} + +// LoadCountNoteImages loads the count of NoteImages for a slice +func (os OrganizationSlice) LoadCountNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountNoteImages(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountUser loads the count of User into the C struct +func (o *Organization) LoadCountUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.User(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.User = &count + return nil +} + +// LoadCountUser loads the count of User for a slice +func (os OrganizationSlice) LoadCountUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountUser(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + type organizationJoins[Q dialect.Joinable] struct { typ string Containerrelates modAs[Q, fieldseekerContainerrelateColumns] diff --git a/db/models/publicreport.nuisance.bob.go b/db/models/publicreport.nuisance.bob.go index 78ce3f54..031d4bf0 100644 --- a/db/models/publicreport.nuisance.bob.go +++ b/db/models/publicreport.nuisance.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/publicreport.pool.bob.go b/db/models/publicreport.pool.bob.go index 805c0576..350af417 100644 --- a/db/models/publicreport.pool.bob.go +++ b/db/models/publicreport.pool.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -59,6 +59,8 @@ type PublicreportPool struct { Status enums.PublicreportReportstatustype `db:"status" ` R publicreportPoolR `db:"-" ` + + C publicreportPoolC `db:"-" ` } // PublicreportPoolSlice is an alias for a slice of pointers to PublicreportPool. @@ -1291,6 +1293,99 @@ func (os PublicreportPoolSlice) LoadPoolPhotos(ctx context.Context, exec bob.Exe return nil } +// publicreportPoolC is where relationship counts are stored. +type publicreportPoolC struct { + PoolPhotos *int64 +} + +// PreloadCount sets a count in the C struct by name +func (o *PublicreportPool) PreloadCount(name string, count int64) error { + if o == nil { + return nil + } + + switch name { + case "PoolPhotos": + o.C.PoolPhotos = &count + } + return nil +} + +type publicreportPoolCountPreloader struct { + PoolPhotos func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader +} + +func buildPublicreportPoolCountPreloader() publicreportPoolCountPreloader { + return publicreportPoolCountPreloader{ + PoolPhotos: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*PublicreportPool]("PoolPhotos", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = PublicreportPools.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(PublicreportPoolPhotos.Name()), + sm.Where(psql.Quote(PublicreportPoolPhotos.Alias(), "pool_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + } +} + +type publicreportPoolCountThenLoader[Q orm.Loadable] struct { + PoolPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildPublicreportPoolCountThenLoader[Q orm.Loadable]() publicreportPoolCountThenLoader[Q] { + type PoolPhotosCountInterface interface { + LoadCountPoolPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return publicreportPoolCountThenLoader[Q]{ + PoolPhotos: countThenLoadBuilder[Q]( + "PoolPhotos", + func(ctx context.Context, exec bob.Executor, retrieved PoolPhotosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountPoolPhotos(ctx, exec, mods...) + }, + ), + } +} + +// LoadCountPoolPhotos loads the count of PoolPhotos into the C struct +func (o *PublicreportPool) LoadCountPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.PoolPhotos(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.PoolPhotos = &count + return nil +} + +// LoadCountPoolPhotos loads the count of PoolPhotos for a slice +func (os PublicreportPoolSlice) LoadCountPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountPoolPhotos(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + type publicreportPoolJoins[Q dialect.Joinable] struct { typ string PoolPhotos modAs[Q, publicreportPoolPhotoColumns] diff --git a/db/models/publicreport.pool_photo.bob.go b/db/models/publicreport.pool_photo.bob.go index 11a67efb..1240a0e3 100644 --- a/db/models/publicreport.pool_photo.bob.go +++ b/db/models/publicreport.pool_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/publicreport.quick.bob.go b/db/models/publicreport.quick.bob.go index 1a97365f..5cec372c 100644 --- a/db/models/publicreport.quick.bob.go +++ b/db/models/publicreport.quick.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -39,6 +39,8 @@ type PublicreportQuick struct { Status enums.PublicreportReportstatustype `db:"status" ` R publicreportQuickR `db:"-" ` + + C publicreportQuickC `db:"-" ` } // PublicreportQuickSlice is an alias for a slice of pointers to PublicreportQuick. @@ -791,6 +793,99 @@ func (os PublicreportQuickSlice) LoadQuickPhotos(ctx context.Context, exec bob.E return nil } +// publicreportQuickC is where relationship counts are stored. +type publicreportQuickC struct { + QuickPhotos *int64 +} + +// PreloadCount sets a count in the C struct by name +func (o *PublicreportQuick) PreloadCount(name string, count int64) error { + if o == nil { + return nil + } + + switch name { + case "QuickPhotos": + o.C.QuickPhotos = &count + } + return nil +} + +type publicreportQuickCountPreloader struct { + QuickPhotos func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader +} + +func buildPublicreportQuickCountPreloader() publicreportQuickCountPreloader { + return publicreportQuickCountPreloader{ + QuickPhotos: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*PublicreportQuick]("QuickPhotos", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = PublicreportQuicks.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(PublicreportQuickPhotos.Name()), + sm.Where(psql.Quote(PublicreportQuickPhotos.Alias(), "quick_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + } +} + +type publicreportQuickCountThenLoader[Q orm.Loadable] struct { + QuickPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildPublicreportQuickCountThenLoader[Q orm.Loadable]() publicreportQuickCountThenLoader[Q] { + type QuickPhotosCountInterface interface { + LoadCountQuickPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return publicreportQuickCountThenLoader[Q]{ + QuickPhotos: countThenLoadBuilder[Q]( + "QuickPhotos", + func(ctx context.Context, exec bob.Executor, retrieved QuickPhotosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountQuickPhotos(ctx, exec, mods...) + }, + ), + } +} + +// LoadCountQuickPhotos loads the count of QuickPhotos into the C struct +func (o *PublicreportQuick) LoadCountQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.QuickPhotos(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.QuickPhotos = &count + return nil +} + +// LoadCountQuickPhotos loads the count of QuickPhotos for a slice +func (os PublicreportQuickSlice) LoadCountQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountQuickPhotos(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + type publicreportQuickJoins[Q dialect.Joinable] struct { typ string QuickPhotos modAs[Q, publicreportQuickPhotoColumns] diff --git a/db/models/publicreport.quick_photo.bob.go b/db/models/publicreport.quick_photo.bob.go index 0dc99964..9f5171d4 100644 --- a/db/models/publicreport.quick_photo.bob.go +++ b/db/models/publicreport.quick_photo.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/publicreport.report_location.bob.go b/db/models/publicreport.report_location.bob.go index 7882ba24..1bbb46e9 100644 --- a/db/models/publicreport.report_location.bob.go +++ b/db/models/publicreport.report_location.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/raster_columns.bob.go b/db/models/raster_columns.bob.go index f53ea1e0..a97fc1cb 100644 --- a/db/models/raster_columns.bob.go +++ b/db/models/raster_columns.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/raster_overviews.bob.go b/db/models/raster_overviews.bob.go index b21dcf47..bc5115b3 100644 --- a/db/models/raster_overviews.bob.go +++ b/db/models/raster_overviews.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/sessions.bob.go b/db/models/sessions.bob.go index 7e0d3f29..4899065f 100644 --- a/db/models/sessions.bob.go +++ b/db/models/sessions.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/spatial_ref_sys.bob.go b/db/models/spatial_ref_sys.bob.go index 20b5bfcb..651d4ad9 100644 --- a/db/models/spatial_ref_sys.bob.go +++ b/db/models/spatial_ref_sys.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/db/models/user_.bob.go b/db/models/user_.bob.go index 7063a0e8..2b8e80c2 100644 --- a/db/models/user_.bob.go +++ b/db/models/user_.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -41,6 +41,8 @@ type User struct { PasswordHash string `db:"password_hash" ` R userR `db:"-" ` + + C userC `db:"-" ` } // UserSlice is an alias for a slice of pointers to User. @@ -55,6 +57,7 @@ type UsersQuery = *psql.ViewQuery[*User, UserSlice] // userR is where relationships are stored. type userR struct { + PublicUserUser ArcgisUserSlice // arcgis.user_.user__public_user_id_fkey CreatorNoteAudios NoteAudioSlice // note_audio.note_audio_creator_id_fkey DeletorNoteAudios NoteAudioSlice // note_audio.note_audio_deletor_id_fkey CreatorNoteImages NoteImageSlice // note_image.note_image_creator_id_fkey @@ -608,6 +611,30 @@ func (o UserSlice) ReloadAll(ctx context.Context, exec bob.Executor) error { return nil } +// PublicUserUser starts a query for related objects on arcgis.user_ +func (o *User) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery { + return ArcgisUsers.Query(append(mods, + sm.Where(ArcgisUsers.Columns.PublicUserID.EQ(psql.Arg(o.ID))), + )...) +} + +func (os UserSlice) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery { + pkID := make(pgtypes.Array[int32], 0, len(os)) + for _, o := range os { + if o == nil { + continue + } + pkID = append(pkID, o.ID) + } + PKArgExpr := psql.Select(sm.Columns( + psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")), + )) + + return ArcgisUsers.Query(append(mods, + sm.Where(psql.Group(ArcgisUsers.Columns.PublicUserID).OP("IN", PKArgExpr)), + )...) +} + // CreatorNoteAudios starts a query for related objects on note_audio func (o *User) CreatorNoteAudios(mods ...bob.Mod[*dialect.SelectQuery]) NoteAudiosQuery { return NoteAudios.Query(append(mods, @@ -776,6 +803,74 @@ func (os UserSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) Organiza )...) } +func insertUserPublicUserUser0(ctx context.Context, exec bob.Executor, arcgisusers1 []*ArcgisUserSetter, user0 *User) (ArcgisUserSlice, error) { + for i := range arcgisusers1 { + arcgisusers1[i].PublicUserID = omit.From(user0.ID) + } + + ret, err := ArcgisUsers.Insert(bob.ToMods(arcgisusers1...)).All(ctx, exec) + if err != nil { + return ret, fmt.Errorf("insertUserPublicUserUser0: %w", err) + } + + return ret, nil +} + +func attachUserPublicUserUser0(ctx context.Context, exec bob.Executor, count int, arcgisusers1 ArcgisUserSlice, user0 *User) (ArcgisUserSlice, error) { + setter := &ArcgisUserSetter{ + PublicUserID: omit.From(user0.ID), + } + + err := arcgisusers1.UpdateAll(ctx, exec, *setter) + if err != nil { + return nil, fmt.Errorf("attachUserPublicUserUser0: %w", err) + } + + return arcgisusers1, nil +} + +func (user0 *User) InsertPublicUserUser(ctx context.Context, exec bob.Executor, related ...*ArcgisUserSetter) error { + if len(related) == 0 { + return nil + } + + var err error + + arcgisusers1, err := insertUserPublicUserUser0(ctx, exec, related, user0) + if err != nil { + return err + } + + user0.R.PublicUserUser = append(user0.R.PublicUserUser, arcgisusers1...) + + for _, rel := range arcgisusers1 { + rel.R.PublicUserUser = user0 + } + return nil +} + +func (user0 *User) AttachPublicUserUser(ctx context.Context, exec bob.Executor, related ...*ArcgisUser) error { + if len(related) == 0 { + return nil + } + + var err error + arcgisusers1 := ArcgisUserSlice(related) + + _, err = attachUserPublicUserUser0(ctx, exec, len(related), arcgisusers1, user0) + if err != nil { + return err + } + + user0.R.PublicUserUser = append(user0.R.PublicUserUser, arcgisusers1...) + + for _, rel := range related { + rel.R.PublicUserUser = user0 + } + + return nil +} + func insertUserCreatorNoteAudios0(ctx context.Context, exec bob.Executor, noteAudios1 []*NoteAudioSetter, user0 *User) (NoteAudioSlice, error) { for i := range noteAudios1 { noteAudios1[i].CreatorID = omit.From(user0.ID) @@ -1274,6 +1369,20 @@ func (o *User) Preload(name string, retrieved any) error { } switch name { + case "PublicUserUser": + rels, ok := retrieved.(ArcgisUserSlice) + if !ok { + return fmt.Errorf("user cannot load %T as %q", retrieved, name) + } + + o.R.PublicUserUser = rels + + for _, rel := range rels { + if rel != nil { + rel.R.PublicUserUser = o + } + } + return nil case "CreatorNoteAudios": rels, ok := retrieved.(NoteAudioSlice) if !ok { @@ -1398,6 +1507,7 @@ func buildUserPreloader() userPreloader { } type userThenLoader[Q orm.Loadable] struct { + PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] @@ -1408,6 +1518,9 @@ type userThenLoader[Q orm.Loadable] struct { } func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] { + type PublicUserUserLoadInterface interface { + LoadPublicUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } type CreatorNoteAudiosLoadInterface interface { LoadCreatorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error } @@ -1431,6 +1544,12 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] { } return userThenLoader[Q]{ + PublicUserUser: thenLoadBuilder[Q]( + "PublicUserUser", + func(ctx context.Context, exec bob.Executor, retrieved PublicUserUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadPublicUserUser(ctx, exec, mods...) + }, + ), CreatorNoteAudios: thenLoadBuilder[Q]( "CreatorNoteAudios", func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteAudiosLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { @@ -1476,6 +1595,67 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] { } } +// LoadPublicUserUser loads the user's PublicUserUser into the .R struct +func (o *User) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + // Reset the relationship + o.R.PublicUserUser = nil + + related, err := o.PublicUserUser(mods...).All(ctx, exec) + if err != nil { + return err + } + + for _, rel := range related { + rel.R.PublicUserUser = o + } + + o.R.PublicUserUser = related + return nil +} + +// LoadPublicUserUser loads the user's PublicUserUser into the .R struct +func (os UserSlice) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + arcgisusers, err := os.PublicUserUser(mods...).All(ctx, exec) + if err != nil { + return err + } + + for _, o := range os { + if o == nil { + continue + } + + o.R.PublicUserUser = nil + } + + for _, o := range os { + if o == nil { + continue + } + + for _, rel := range arcgisusers { + + if !(o.ID == rel.PublicUserID) { + continue + } + + rel.R.PublicUserUser = o + + o.R.PublicUserUser = append(o.R.PublicUserUser, rel) + } + } + + return nil +} + // LoadCreatorNoteAudios loads the user's CreatorNoteAudios into the .R struct func (o *User) LoadCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { if o == nil { @@ -1900,8 +2080,468 @@ func (os UserSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mod return nil } +// userC is where relationship counts are stored. +type userC struct { + PublicUserUser *int64 + CreatorNoteAudios *int64 + DeletorNoteAudios *int64 + CreatorNoteImages *int64 + DeletorNoteImages *int64 + UserNotifications *int64 + UserOauthTokens *int64 +} + +// PreloadCount sets a count in the C struct by name +func (o *User) PreloadCount(name string, count int64) error { + if o == nil { + return nil + } + + switch name { + case "PublicUserUser": + o.C.PublicUserUser = &count + case "CreatorNoteAudios": + o.C.CreatorNoteAudios = &count + case "DeletorNoteAudios": + o.C.DeletorNoteAudios = &count + case "CreatorNoteImages": + o.C.CreatorNoteImages = &count + case "DeletorNoteImages": + o.C.DeletorNoteImages = &count + case "UserNotifications": + o.C.UserNotifications = &count + case "UserOauthTokens": + o.C.UserOauthTokens = &count + } + return nil +} + +type userCountPreloader struct { + PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + DeletorNoteImages func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + UserNotifications func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader + UserOauthTokens func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader +} + +func buildUserCountPreloader() userCountPreloader { + return userCountPreloader{ + PublicUserUser: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*User]("PublicUserUser", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Users.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(ArcgisUsers.Name()), + sm.Where(psql.Quote(ArcgisUsers.Alias(), "public_user_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + CreatorNoteAudios: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*User]("CreatorNoteAudios", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Users.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteAudios.Name()), + sm.Where(psql.Quote(NoteAudios.Alias(), "creator_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + DeletorNoteAudios: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*User]("DeletorNoteAudios", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Users.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteAudios.Name()), + sm.Where(psql.Quote(NoteAudios.Alias(), "deletor_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + CreatorNoteImages: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*User]("CreatorNoteImages", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Users.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteImages.Name()), + sm.Where(psql.Quote(NoteImages.Alias(), "creator_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + DeletorNoteImages: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*User]("DeletorNoteImages", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Users.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(NoteImages.Name()), + sm.Where(psql.Quote(NoteImages.Alias(), "deletor_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + UserNotifications: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*User]("UserNotifications", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Users.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(Notifications.Name()), + sm.Where(psql.Quote(Notifications.Alias(), "user_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + UserOauthTokens: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader { + return countPreloader[*User]("UserOauthTokens", func(parent string) bob.Expression { + // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk) + if parent == "" { + parent = Users.Alias() + } + + subqueryMods := []bob.Mod[*dialect.SelectQuery]{ + sm.Columns(psql.Raw("count(*)")), + + sm.From(OauthTokens.Name()), + sm.Where(psql.Quote(OauthTokens.Alias(), "user_id").EQ(psql.Quote(parent, "id"))), + } + subqueryMods = append(subqueryMods, mods...) + return psql.Group(psql.Select(subqueryMods...).Expression) + }) + }, + } +} + +type userCountThenLoader[Q orm.Loadable] struct { + PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + DeletorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + UserNotifications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] + UserOauthTokens func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] +} + +func buildUserCountThenLoader[Q orm.Loadable]() userCountThenLoader[Q] { + type PublicUserUserCountInterface interface { + LoadCountPublicUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type CreatorNoteAudiosCountInterface interface { + LoadCountCreatorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type DeletorNoteAudiosCountInterface interface { + LoadCountDeletorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type CreatorNoteImagesCountInterface interface { + LoadCountCreatorNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type DeletorNoteImagesCountInterface interface { + LoadCountDeletorNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type UserNotificationsCountInterface interface { + LoadCountUserNotifications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + type UserOauthTokensCountInterface interface { + LoadCountUserOauthTokens(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error + } + + return userCountThenLoader[Q]{ + PublicUserUser: countThenLoadBuilder[Q]( + "PublicUserUser", + func(ctx context.Context, exec bob.Executor, retrieved PublicUserUserCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountPublicUserUser(ctx, exec, mods...) + }, + ), + CreatorNoteAudios: countThenLoadBuilder[Q]( + "CreatorNoteAudios", + func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteAudiosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountCreatorNoteAudios(ctx, exec, mods...) + }, + ), + DeletorNoteAudios: countThenLoadBuilder[Q]( + "DeletorNoteAudios", + func(ctx context.Context, exec bob.Executor, retrieved DeletorNoteAudiosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountDeletorNoteAudios(ctx, exec, mods...) + }, + ), + CreatorNoteImages: countThenLoadBuilder[Q]( + "CreatorNoteImages", + func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountCreatorNoteImages(ctx, exec, mods...) + }, + ), + DeletorNoteImages: countThenLoadBuilder[Q]( + "DeletorNoteImages", + func(ctx context.Context, exec bob.Executor, retrieved DeletorNoteImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountDeletorNoteImages(ctx, exec, mods...) + }, + ), + UserNotifications: countThenLoadBuilder[Q]( + "UserNotifications", + func(ctx context.Context, exec bob.Executor, retrieved UserNotificationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountUserNotifications(ctx, exec, mods...) + }, + ), + UserOauthTokens: countThenLoadBuilder[Q]( + "UserOauthTokens", + func(ctx context.Context, exec bob.Executor, retrieved UserOauthTokensCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error { + return retrieved.LoadCountUserOauthTokens(ctx, exec, mods...) + }, + ), + } +} + +// LoadCountPublicUserUser loads the count of PublicUserUser into the C struct +func (o *User) LoadCountPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.PublicUserUser(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.PublicUserUser = &count + return nil +} + +// LoadCountPublicUserUser loads the count of PublicUserUser for a slice +func (os UserSlice) LoadCountPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountPublicUserUser(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountCreatorNoteAudios loads the count of CreatorNoteAudios into the C struct +func (o *User) LoadCountCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.CreatorNoteAudios(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.CreatorNoteAudios = &count + return nil +} + +// LoadCountCreatorNoteAudios loads the count of CreatorNoteAudios for a slice +func (os UserSlice) LoadCountCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountCreatorNoteAudios(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountDeletorNoteAudios loads the count of DeletorNoteAudios into the C struct +func (o *User) LoadCountDeletorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.DeletorNoteAudios(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.DeletorNoteAudios = &count + return nil +} + +// LoadCountDeletorNoteAudios loads the count of DeletorNoteAudios for a slice +func (os UserSlice) LoadCountDeletorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountDeletorNoteAudios(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountCreatorNoteImages loads the count of CreatorNoteImages into the C struct +func (o *User) LoadCountCreatorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.CreatorNoteImages(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.CreatorNoteImages = &count + return nil +} + +// LoadCountCreatorNoteImages loads the count of CreatorNoteImages for a slice +func (os UserSlice) LoadCountCreatorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountCreatorNoteImages(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountDeletorNoteImages loads the count of DeletorNoteImages into the C struct +func (o *User) LoadCountDeletorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.DeletorNoteImages(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.DeletorNoteImages = &count + return nil +} + +// LoadCountDeletorNoteImages loads the count of DeletorNoteImages for a slice +func (os UserSlice) LoadCountDeletorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountDeletorNoteImages(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountUserNotifications loads the count of UserNotifications into the C struct +func (o *User) LoadCountUserNotifications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.UserNotifications(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.UserNotifications = &count + return nil +} + +// LoadCountUserNotifications loads the count of UserNotifications for a slice +func (os UserSlice) LoadCountUserNotifications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountUserNotifications(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + +// LoadCountUserOauthTokens loads the count of UserOauthTokens into the C struct +func (o *User) LoadCountUserOauthTokens(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if o == nil { + return nil + } + + count, err := o.UserOauthTokens(mods...).Count(ctx, exec) + if err != nil { + return err + } + + o.C.UserOauthTokens = &count + return nil +} + +// LoadCountUserOauthTokens loads the count of UserOauthTokens for a slice +func (os UserSlice) LoadCountUserOauthTokens(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error { + if len(os) == 0 { + return nil + } + + for _, o := range os { + if err := o.LoadCountUserOauthTokens(ctx, exec, mods...); err != nil { + return err + } + } + + return nil +} + type userJoins[Q dialect.Joinable] struct { typ string + PublicUserUser modAs[Q, arcgisuserColumns] CreatorNoteAudios modAs[Q, noteAudioColumns] DeletorNoteAudios modAs[Q, noteAudioColumns] CreatorNoteImages modAs[Q, noteImageColumns] @@ -1918,6 +2558,20 @@ func (j userJoins[Q]) aliasedAs(alias string) userJoins[Q] { func buildUserJoins[Q dialect.Joinable](cols userColumns, typ string) userJoins[Q] { return userJoins[Q]{ typ: typ, + PublicUserUser: modAs[Q, arcgisuserColumns]{ + c: ArcgisUsers.Columns, + f: func(to arcgisuserColumns) bob.Mod[Q] { + mods := make(mods.QueryMods[Q], 0, 1) + + { + mods = append(mods, dialect.Join[Q](typ, ArcgisUsers.Name().As(to.Alias())).On( + to.PublicUserID.EQ(cols.ID), + )) + } + + return mods + }, + }, CreatorNoteAudios: modAs[Q, noteAudioColumns]{ c: NoteAudios.Columns, f: func(to noteAudioColumns) bob.Mod[Q] { diff --git a/db/sql/oauth_by_user_id.bob.go b/db/sql/oauth_by_user_id.bob.go deleted file mode 100644 index f2b6eb5d..00000000 --- a/db/sql/oauth_by_user_id.bob.go +++ /dev/null @@ -1,111 +0,0 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. -// This file is meant to be re-generated in place and/or deleted at any time. - -package sql - -import ( - "context" - _ "embed" - "io" - "iter" - "time" - - "github.com/aarondl/opt/null" - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - "github.com/stephenafamo/bob/dialect/psql/dialect" - "github.com/stephenafamo/bob/orm" - "github.com/stephenafamo/scan" -) - -//go:embed oauth_by_user_id.bob.sql -var formattedQueries_oauth_by_user_id string - -var oauthTokenByUserIdSQL = formattedQueries_oauth_by_user_id[191:729] - -type OauthTokenByUserIdQuery = orm.ModQuery[*dialect.SelectQuery, oauthTokenByUserId, OauthTokenByUserIdRow, []OauthTokenByUserIdRow, oauthTokenByUserIdTransformer] - -func OauthTokenByUserId(UserID int32) *OauthTokenByUserIdQuery { - var expressionTypArgs oauthTokenByUserId - - expressionTypArgs.UserID = psql.Arg(UserID) - - return &OauthTokenByUserIdQuery{ - Query: orm.Query[oauthTokenByUserId, OauthTokenByUserIdRow, []OauthTokenByUserIdRow, oauthTokenByUserIdTransformer]{ - ExecQuery: orm.ExecQuery[oauthTokenByUserId]{ - BaseQuery: bob.BaseQuery[oauthTokenByUserId]{ - Expression: expressionTypArgs, - Dialect: dialect.Dialect, - QueryType: bob.QueryTypeSelect, - }, - }, - Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (OauthTokenByUserIdRow, error)) { - return func(row *scan.Row) (any, error) { - var t OauthTokenByUserIdRow - row.ScheduleScanByIndex(0, &t.ID) - row.ScheduleScanByIndex(1, &t.AccessToken) - row.ScheduleScanByIndex(2, &t.AccessTokenExpires) - row.ScheduleScanByIndex(3, &t.RefreshToken) - row.ScheduleScanByIndex(4, &t.Username) - row.ScheduleScanByIndex(5, &t.UserID) - row.ScheduleScanByIndex(6, &t.ArcgisID) - row.ScheduleScanByIndex(7, &t.ArcgisLicenseTypeID) - row.ScheduleScanByIndex(8, &t.RefreshTokenExpires) - row.ScheduleScanByIndex(9, &t.InvalidatedAt) - return &t, nil - }, func(v any) (OauthTokenByUserIdRow, error) { - return *(v.(*OauthTokenByUserIdRow)), nil - } - }, - }, - Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) { - q.AppendSelect(expressionTypArgs.subExpr(7, 501)) - q.SetTable(expressionTypArgs.subExpr(507, 518)) - q.AppendWhere(expressionTypArgs.subExpr(526, 538)) - }), - } -} - -type OauthTokenByUserIdRow = struct { - ID int32 `db:"id"` - AccessToken string `db:"access_token"` - AccessTokenExpires time.Time `db:"access_token_expires"` - RefreshToken string `db:"refresh_token"` - Username string `db:"username"` - UserID int32 `db:"user_id"` - ArcgisID null.Val[string] `db:"arcgis_id"` - ArcgisLicenseTypeID null.Val[string] `db:"arcgis_license_type_id"` - RefreshTokenExpires time.Time `db:"refresh_token_expires"` - InvalidatedAt null.Val[time.Time] `db:"invalidated_at"` -} - -type oauthTokenByUserIdTransformer = bob.SliceTransformer[OauthTokenByUserIdRow, []OauthTokenByUserIdRow] - -type oauthTokenByUserId struct { - UserID bob.Expression -} - -func (o oauthTokenByUserId) args() iter.Seq[orm.ArgWithPosition] { - return func(yield func(arg orm.ArgWithPosition) bool) { - if !yield(orm.ArgWithPosition{ - Name: "userID", - Start: 536, - Stop: 538, - Expression: o.UserID, - }) { - return - } - } -} - -func (o oauthTokenByUserId) raw(from, to int) string { - return oauthTokenByUserIdSQL[from:to] -} - -func (o oauthTokenByUserId) subExpr(from, to int) bob.Expression { - return orm.ArgsToExpression(oauthTokenByUserIdSQL, from, to, o.args()) -} - -func (o oauthTokenByUserId) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) { - return o.subExpr(0, len(oauthTokenByUserIdSQL)).WriteSQL(ctx, w, d, start) -} diff --git a/db/sql/oauth_by_user_id.bob.sql b/db/sql/oauth_by_user_id.bob.sql deleted file mode 100644 index ff32b8e7..00000000 --- a/db/sql/oauth_by_user_id.bob.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. --- This file is meant to be re-generated in place and/or deleted at any time. - --- OauthTokenByUserId -SELECT "oauth_token"."id" AS "id", "oauth_token"."access_token" AS "access_token", "oauth_token"."access_token_expires" AS "access_token_expires", "oauth_token"."refresh_token" AS "refresh_token", "oauth_token"."username" AS "username", "oauth_token"."user_id" AS "user_id", "oauth_token"."arcgis_id" AS "arcgis_id", "oauth_token"."arcgis_license_type_id" AS "arcgis_license_type_id", "oauth_token"."refresh_token_expires" AS "refresh_token_expires", "oauth_token"."invalidated_at" AS "invalidated_at" FROM oauth_token WHERE - user_id = $1; diff --git a/db/sql/oauth_by_user_id.sql b/db/sql/oauth_by_user_id.sql deleted file mode 100644 index 40a297b2..00000000 --- a/db/sql/oauth_by_user_id.sql +++ /dev/null @@ -1,3 +0,0 @@ --- OauthTokenByUserId -SELECT * FROM oauth_token WHERE - user_id = $1; diff --git a/db/sql/org_by_oauth_id.bob.go b/db/sql/org_by_oauth_id.bob.go index 690b6ab9..f9b35ccd 100644 --- a/db/sql/org_by_oauth_id.bob.go +++ b/db/sql/org_by_oauth_id.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -20,7 +20,7 @@ import ( //go:embed org_by_oauth_id.bob.sql var formattedQueries_org_by_oauth_id string -var orgByOauthIdSQL = formattedQueries_org_by_oauth_id[185:398] +var orgByOauthIdSQL = formattedQueries_org_by_oauth_id[150:363] type OrgByOauthIdQuery = orm.ModQuery[*dialect.SelectQuery, orgByOauthId, OrgByOauthIdRow, []OrgByOauthIdRow, orgByOauthIdTransformer] diff --git a/db/sql/org_by_oauth_id.bob.sql b/db/sql/org_by_oauth_id.bob.sql index c7be4696..f0945529 100644 --- a/db/sql/org_by_oauth_id.bob.sql +++ b/db/sql/org_by_oauth_id.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +-- Code generated by BobGen psql v0.42.1. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- OrgByOauthId diff --git a/db/sql/publicreport_publicid_table.bob.go b/db/sql/publicreport_publicid_table.bob.go index 9883cb40..f52b9b42 100644 --- a/db/sql/publicreport_publicid_table.bob.go +++ b/db/sql/publicreport_publicid_table.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -20,7 +20,7 @@ import ( //go:embed publicreport_publicid_table.bob.sql var formattedQueries_publicreport_publicid_table string -var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[192:659] +var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[157:624] type PublicreportIDTableQuery = orm.ModQuery[*dialect.SelectQuery, publicreportIDTable, PublicreportIDTableRow, []PublicreportIDTableRow, publicreportIDTableTransformer] diff --git a/db/sql/publicreport_publicid_table.bob.sql b/db/sql/publicreport_publicid_table.bob.sql index 8a6381d9..f9e1c4a6 100644 --- a/db/sql/publicreport_publicid_table.bob.sql +++ b/db/sql/publicreport_publicid_table.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +-- Code generated by BobGen psql v0.42.1. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- PublicreportIDTable diff --git a/db/sql/trapcount_by_location_id.bob.go b/db/sql/trapcount_by_location_id.bob.go index 70a39347..73475582 100644 --- a/db/sql/trapcount_by_location_id.bob.go +++ b/db/sql/trapcount_by_location_id.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -23,7 +23,7 @@ import ( //go:embed trapcount_by_location_id.bob.sql var formattedQueries_trapcount_by_location_id string -var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[194:644] +var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[159:609] type TrapCountByLocationIDQuery = orm.ModQuery[*dialect.SelectQuery, trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer] diff --git a/db/sql/trapcount_by_location_id.bob.sql b/db/sql/trapcount_by_location_id.bob.sql index 385e4c9e..6e76e700 100644 --- a/db/sql/trapcount_by_location_id.bob.sql +++ b/db/sql/trapcount_by_location_id.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +-- Code generated by BobGen psql v0.42.1. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- TrapCountByLocationID diff --git a/db/sql/trapdata_by_location_id_recent.bob.go b/db/sql/trapdata_by_location_id_recent.bob.go index 38db78f9..704f722c 100644 --- a/db/sql/trapdata_by_location_id_recent.bob.go +++ b/db/sql/trapdata_by_location_id_recent.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -22,7 +22,7 @@ import ( //go:embed trapdata_by_location_id_recent.bob.sql var formattedQueries_trapdata_by_location_id_recent string -var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[199:498] +var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[164:463] type TrapDataByLocationIDRecentQuery = orm.ModQuery[*dialect.SelectQuery, trapDataByLocationIDRecent, TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow, trapDataByLocationIDRecentTransformer] diff --git a/db/sql/trapdata_by_location_id_recent.bob.sql b/db/sql/trapdata_by_location_id_recent.bob.sql index c3326b69..917e2ee6 100644 --- a/db/sql/trapdata_by_location_id_recent.bob.sql +++ b/db/sql/trapdata_by_location_id_recent.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +-- Code generated by BobGen psql v0.42.1. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- TrapDataByLocationIDRecent diff --git a/db/sql/traplocation_by_source_id.bob.go b/db/sql/traplocation_by_source_id.bob.go index 8f10bb55..d0b437e3 100644 --- a/db/sql/traplocation_by_source_id.bob.go +++ b/db/sql/traplocation_by_source_id.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -20,7 +20,7 @@ import ( //go:embed traplocation_by_source_id.bob.sql var formattedQueries_traplocation_by_source_id string -var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[195:488] +var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[160:453] type TrapLocationBySourceIDQuery = orm.ModQuery[*dialect.SelectQuery, trapLocationBySourceID, TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow, trapLocationBySourceIDTransformer] @@ -51,11 +51,11 @@ func TrapLocationBySourceID(OrganizationID int32, Globalid uuid.UUID) *TrapLocat }, }, Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) { - q.CombinedLimit.SetLimit(psql.Raw("4")) q.AppendSelect(expressionTypArgs.subExpr(9, 102)) q.SetTable(expressionTypArgs.subExpr(110, 178)) q.AppendWhere(expressionTypArgs.subExpr(187, 232)) q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(244, 285)) + q.CombinedLimit.SetLimit(expressionTypArgs.subExpr(292, 293)) }), } } diff --git a/db/sql/traplocation_by_source_id.bob.sql b/db/sql/traplocation_by_source_id.bob.sql index 9f788cef..b4610521 100644 --- a/db/sql/traplocation_by_source_id.bob.sql +++ b/db/sql/traplocation_by_source_id.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +-- Code generated by BobGen psql v0.42.1. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- TrapLocationBySourceID diff --git a/db/sql/update_oauth_org.bob.go b/db/sql/update_oauth_org.bob.go index 6d8776d5..7bb34302 100644 --- a/db/sql/update_oauth_org.bob.go +++ b/db/sql/update_oauth_org.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -18,7 +18,7 @@ import ( //go:embed update_oauth_org.bob.sql var formattedQueries_update_oauth_org string -var updateOauthTokenOrgSQL = formattedQueries_update_oauth_org[192:284] +var updateOauthTokenOrgSQL = formattedQueries_update_oauth_org[157:249] type UpdateOauthTokenOrgQuery = orm.ModExecQuery[*dialect.UpdateQuery, updateOauthTokenOrg] diff --git a/db/sql/update_oauth_org.bob.sql b/db/sql/update_oauth_org.bob.sql index 080766b8..64bdb6cb 100644 --- a/db/sql/update_oauth_org.bob.sql +++ b/db/sql/update_oauth_org.bob.sql @@ -1,4 +1,4 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +-- Code generated by BobGen psql v0.42.1. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- UpdateOauthTokenOrg diff --git a/db/sql/user_by_username.bob.go b/db/sql/user_by_username.bob.go index e3eef602..4ee9ec2f 100644 --- a/db/sql/user_by_username.bob.go +++ b/db/sql/user_by_username.bob.go @@ -1,4 +1,4 @@ -// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +// Code generated by BobGen psql v0.42.1. DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package sql @@ -22,7 +22,7 @@ import ( //go:embed user_by_username.bob.sql var formattedQueries_user_by_username string -var userByUsernameSQL = formattedQueries_user_by_username[187:808] +var userByUsernameSQL = formattedQueries_user_by_username[152:780] type UserByUsernameQuery = orm.ModQuery[*dialect.SelectQuery, userByUsername, UserByUsernameRow, []UserByUsernameRow, userByUsernameTransformer] @@ -63,8 +63,8 @@ func UserByUsername(Username string) *UserByUsernameQuery { }, Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) { q.AppendSelect(expressionTypArgs.subExpr(7, 551)) - q.SetTable(expressionTypArgs.subExpr(557, 562)) - q.AppendWhere(expressionTypArgs.subExpr(570, 621)) + q.SetTable(expressionTypArgs.subExpr(557, 569)) + q.AppendWhere(expressionTypArgs.subExpr(577, 628)) }), } } @@ -94,8 +94,8 @@ func (o userByUsername) args() iter.Seq[orm.ArgWithPosition] { return func(yield func(arg orm.ArgWithPosition) bool) { if !yield(orm.ArgWithPosition{ Name: "username", - Start: 581, - Stop: 583, + Start: 588, + Stop: 590, Expression: o.Username, }) { return diff --git a/db/sql/user_by_username.bob.sql b/db/sql/user_by_username.bob.sql index 596ef88d..9526a44e 100644 --- a/db/sql/user_by_username.bob.sql +++ b/db/sql/user_by_username.bob.sql @@ -1,7 +1,7 @@ --- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT. +-- Code generated by BobGen psql v0.42.1. DO NOT EDIT. -- This file is meant to be re-generated in place and/or deleted at any time. -- UserByUsername -SELECT "user_"."id" AS "id", "user_"."arcgis_access_token" AS "arcgis_access_token", "user_"."arcgis_license" AS "arcgis_license", "user_"."arcgis_refresh_token" AS "arcgis_refresh_token", "user_"."arcgis_refresh_token_expires" AS "arcgis_refresh_token_expires", "user_"."arcgis_role" AS "arcgis_role", "user_"."display_name" AS "display_name", "user_"."email" AS "email", "user_"."organization_id" AS "organization_id", "user_"."username" AS "username", "user_"."password_hash_type" AS "password_hash_type", "user_"."password_hash" AS "password_hash" FROM user_ WHERE +SELECT "user_"."id" AS "id", "user_"."arcgis_access_token" AS "arcgis_access_token", "user_"."arcgis_license" AS "arcgis_license", "user_"."arcgis_refresh_token" AS "arcgis_refresh_token", "user_"."arcgis_refresh_token_expires" AS "arcgis_refresh_token_expires", "user_"."arcgis_role" AS "arcgis_role", "user_"."display_name" AS "display_name", "user_"."email" AS "email", "user_"."organization_id" AS "organization_id", "user_"."username" AS "username", "user_"."password_hash_type" AS "password_hash_type", "user_"."password_hash" AS "password_hash" FROM public.user_ WHERE username = $1 AND password_hash_type = 'bcrypt-14'; diff --git a/db/sql/user_by_username.sql b/db/sql/user_by_username.sql index 64d96249..6de278cc 100644 --- a/db/sql/user_by_username.sql +++ b/db/sql/user_by_username.sql @@ -1,4 +1,4 @@ -- UserByUsername -SELECT * FROM user_ WHERE +SELECT * FROM public.user_ WHERE username = $1 AND password_hash_type = 'bcrypt-14';