diff --git a/db/migrations/00037_membership_approval_groups.sql b/db/migrations/00037_membership_approval_groups.sql new file mode 100644 index 0000000..c3bfcaa --- /dev/null +++ b/db/migrations/00037_membership_approval_groups.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE groups ADD COLUMN IF NOT EXISTS approver_group UUID NULL REFERENCES groups(id); +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +ALTER TABLE groups DROP COLUMN IF EXISTS approver_group; +-- +goose StatementEnd diff --git a/go.mod b/go.mod index b3bb04f..ed3222b 100644 --- a/go.mod +++ b/go.mod @@ -25,8 +25,8 @@ require ( github.com/spf13/viper v1.17.0 github.com/stretchr/testify v1.8.4 github.com/volatiletech/null/v8 v8.1.2 - github.com/volatiletech/sqlboiler/v4 v4.15.0 - github.com/volatiletech/strmangle v0.0.5 + github.com/volatiletech/sqlboiler/v4 v4.16.1 + github.com/volatiletech/strmangle v0.0.6 github.com/zsais/go-gin-prometheus v0.1.0 go.hollow.sh/toolbox v0.6.2 go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.45.0 @@ -104,7 +104,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.10.0 // indirect - github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/cast v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect diff --git a/go.sum b/go.sum index 7993a75..c8177dd 100644 --- a/go.sum +++ b/go.sum @@ -157,7 +157,7 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/friendsofgo/errors v0.9.2 h1:X6NYxef4efCBdwI7BgS820zFaN7Cphrmb+Pljdzjtgk= github.com/friendsofgo/errors v0.9.2/go.mod h1:yCvFW5AkDIL9qn7suHVLiI/gH228n7PC4Pn44IGoTOI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= @@ -423,6 +423,7 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kat-co/vala v0.0.0-20170210184112-42e1d8b61f12/go.mod h1:u9MdXq/QageOOSGp7qG4XAQsYUMP+V5zEel/Vrl6OOc= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -609,8 +610,8 @@ github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= @@ -655,11 +656,11 @@ github.com/volatiletech/null/v8 v8.1.2 h1:kiTiX1PpwvuugKwfvUNX/SU/5A2KGZMXfGD0DU github.com/volatiletech/null/v8 v8.1.2/go.mod h1:98DbwNoKEpRrYtGjWFctievIfm4n4MxG0A6EBUcoS5g= github.com/volatiletech/randomize v0.0.1 h1:eE5yajattWqTB2/eN8df4dw+8jwAzBtbdo5sbWC4nMk= github.com/volatiletech/randomize v0.0.1/go.mod h1:GN3U0QYqfZ9FOJ67bzax1cqZ5q2xuj2mXrXBjWaRTlY= -github.com/volatiletech/sqlboiler/v4 v4.15.0 h1:+twm3mA34SaUF6wB9U6QkXxkK8AKkV5EfgMSvcKWeY4= -github.com/volatiletech/sqlboiler/v4 v4.15.0/go.mod h1:s643wqYyCQ7Ak2hMVxH7kTS0+lFPNlj+gHKUIukJ0YA= +github.com/volatiletech/sqlboiler/v4 v4.16.1 h1:utSd0n+zoasYAGOwbeGzzLb3p9vdItRyYR6zm20SVP0= +github.com/volatiletech/sqlboiler/v4 v4.16.1/go.mod h1:B14BPBGTrJ2X6l7lwnvV/iXgYR48+ozGSlzHI3frl6U= github.com/volatiletech/strmangle v0.0.1/go.mod h1:F6RA6IkB5vq0yTG4GQ0UsbbRcl3ni9P76i+JrTBKFFg= -github.com/volatiletech/strmangle v0.0.5 h1:CompJPy+lAi9h+YU/IzBR4X2RDRuAuEIP+kjFdyZXcU= -github.com/volatiletech/strmangle v0.0.5/go.mod h1:ycDvbDkjDvhC0NUU8w3fWwl5JEMTV56vTKXzR3GeR+0= +github.com/volatiletech/strmangle v0.0.6 h1:AdOYE3B2ygRDq4rXDij/MMwq6KVK/pWAYxpC7CLrkKQ= +github.com/volatiletech/strmangle v0.0.6/go.mod h1:ycDvbDkjDvhC0NUU8w3fWwl5JEMTV56vTKXzR3GeR+0= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/internal/models/application_types.go b/internal/models/application_types.go index 1a64341..87d2d8c 100644 --- a/internal/models/application_types.go +++ b/internal/models/application_types.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -281,18 +281,27 @@ var ( _ = qmhelper.Where ) +var applicationTypeAfterSelectMu sync.Mutex var applicationTypeAfterSelectHooks []ApplicationTypeHook +var applicationTypeBeforeInsertMu sync.Mutex var applicationTypeBeforeInsertHooks []ApplicationTypeHook +var applicationTypeAfterInsertMu sync.Mutex var applicationTypeAfterInsertHooks []ApplicationTypeHook +var applicationTypeBeforeUpdateMu sync.Mutex var applicationTypeBeforeUpdateHooks []ApplicationTypeHook +var applicationTypeAfterUpdateMu sync.Mutex var applicationTypeAfterUpdateHooks []ApplicationTypeHook +var applicationTypeBeforeDeleteMu sync.Mutex var applicationTypeBeforeDeleteHooks []ApplicationTypeHook +var applicationTypeAfterDeleteMu sync.Mutex var applicationTypeAfterDeleteHooks []ApplicationTypeHook +var applicationTypeBeforeUpsertMu sync.Mutex var applicationTypeBeforeUpsertHooks []ApplicationTypeHook +var applicationTypeAfterUpsertMu sync.Mutex var applicationTypeAfterUpsertHooks []ApplicationTypeHook // doAfterSelectHooks executes all "after Select" hooks. @@ -434,23 +443,41 @@ func (o *ApplicationType) doAfterUpsertHooks(ctx context.Context, exec boil.Cont func AddApplicationTypeHook(hookPoint boil.HookPoint, applicationTypeHook ApplicationTypeHook) { switch hookPoint { case boil.AfterSelectHook: + applicationTypeAfterSelectMu.Lock() applicationTypeAfterSelectHooks = append(applicationTypeAfterSelectHooks, applicationTypeHook) + applicationTypeAfterSelectMu.Unlock() case boil.BeforeInsertHook: + applicationTypeBeforeInsertMu.Lock() applicationTypeBeforeInsertHooks = append(applicationTypeBeforeInsertHooks, applicationTypeHook) + applicationTypeBeforeInsertMu.Unlock() case boil.AfterInsertHook: + applicationTypeAfterInsertMu.Lock() applicationTypeAfterInsertHooks = append(applicationTypeAfterInsertHooks, applicationTypeHook) + applicationTypeAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + applicationTypeBeforeUpdateMu.Lock() applicationTypeBeforeUpdateHooks = append(applicationTypeBeforeUpdateHooks, applicationTypeHook) + applicationTypeBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + applicationTypeAfterUpdateMu.Lock() applicationTypeAfterUpdateHooks = append(applicationTypeAfterUpdateHooks, applicationTypeHook) + applicationTypeAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + applicationTypeBeforeDeleteMu.Lock() applicationTypeBeforeDeleteHooks = append(applicationTypeBeforeDeleteHooks, applicationTypeHook) + applicationTypeBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + applicationTypeAfterDeleteMu.Lock() applicationTypeAfterDeleteHooks = append(applicationTypeAfterDeleteHooks, applicationTypeHook) + applicationTypeAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + applicationTypeBeforeUpsertMu.Lock() applicationTypeBeforeUpsertHooks = append(applicationTypeBeforeUpsertHooks, applicationTypeHook) + applicationTypeBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + applicationTypeAfterUpsertMu.Lock() applicationTypeAfterUpsertHooks = append(applicationTypeAfterUpsertHooks, applicationTypeHook) + applicationTypeAfterUpsertMu.Unlock() } } @@ -568,26 +595,18 @@ func (applicationTypeL) LoadTypeApplications(ctx context.Context, e boil.Context } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &applicationTypeR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &applicationTypeR{} } - - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -595,9 +614,16 @@ func (applicationTypeL) LoadTypeApplications(ctx context.Context, e boil.Context return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`applications`), - qm.WhereIn(`applications.type_id in ?`, args...), + qm.WhereIn(`applications.type_id in ?`, argsSlice...), qmhelper.WhereIsNull(`applications.deleted_at`), ) if mods != nil { diff --git a/internal/models/applications.go b/internal/models/applications.go index 35143c7..efc4092 100644 --- a/internal/models/applications.go +++ b/internal/models/applications.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -207,18 +207,27 @@ var ( _ = qmhelper.Where ) +var applicationAfterSelectMu sync.Mutex var applicationAfterSelectHooks []ApplicationHook +var applicationBeforeInsertMu sync.Mutex var applicationBeforeInsertHooks []ApplicationHook +var applicationAfterInsertMu sync.Mutex var applicationAfterInsertHooks []ApplicationHook +var applicationBeforeUpdateMu sync.Mutex var applicationBeforeUpdateHooks []ApplicationHook +var applicationAfterUpdateMu sync.Mutex var applicationAfterUpdateHooks []ApplicationHook +var applicationBeforeDeleteMu sync.Mutex var applicationBeforeDeleteHooks []ApplicationHook +var applicationAfterDeleteMu sync.Mutex var applicationAfterDeleteHooks []ApplicationHook +var applicationBeforeUpsertMu sync.Mutex var applicationBeforeUpsertHooks []ApplicationHook +var applicationAfterUpsertMu sync.Mutex var applicationAfterUpsertHooks []ApplicationHook // doAfterSelectHooks executes all "after Select" hooks. @@ -360,23 +369,41 @@ func (o *Application) doAfterUpsertHooks(ctx context.Context, exec boil.ContextE func AddApplicationHook(hookPoint boil.HookPoint, applicationHook ApplicationHook) { switch hookPoint { case boil.AfterSelectHook: + applicationAfterSelectMu.Lock() applicationAfterSelectHooks = append(applicationAfterSelectHooks, applicationHook) + applicationAfterSelectMu.Unlock() case boil.BeforeInsertHook: + applicationBeforeInsertMu.Lock() applicationBeforeInsertHooks = append(applicationBeforeInsertHooks, applicationHook) + applicationBeforeInsertMu.Unlock() case boil.AfterInsertHook: + applicationAfterInsertMu.Lock() applicationAfterInsertHooks = append(applicationAfterInsertHooks, applicationHook) + applicationAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + applicationBeforeUpdateMu.Lock() applicationBeforeUpdateHooks = append(applicationBeforeUpdateHooks, applicationHook) + applicationBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + applicationAfterUpdateMu.Lock() applicationAfterUpdateHooks = append(applicationAfterUpdateHooks, applicationHook) + applicationAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + applicationBeforeDeleteMu.Lock() applicationBeforeDeleteHooks = append(applicationBeforeDeleteHooks, applicationHook) + applicationBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + applicationAfterDeleteMu.Lock() applicationAfterDeleteHooks = append(applicationAfterDeleteHooks, applicationHook) + applicationAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + applicationBeforeUpsertMu.Lock() applicationBeforeUpsertHooks = append(applicationBeforeUpsertHooks, applicationHook) + applicationBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + applicationAfterUpsertMu.Lock() applicationAfterUpsertHooks = append(applicationAfterUpsertHooks, applicationHook) + applicationAfterUpsertMu.Unlock() } } @@ -544,30 +571,23 @@ func (applicationL) LoadType(ctx context.Context, e boil.ContextExecutor, singul } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &applicationR{} } if !queries.IsNil(object.TypeID) { - args = append(args, object.TypeID) + args[object.TypeID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &applicationR{} } - for _, a := range args { - if queries.Equal(a, obj.TypeID) { - continue Outer - } - } - if !queries.IsNil(obj.TypeID) { - args = append(args, obj.TypeID) + args[obj.TypeID] = struct{}{} } } @@ -577,9 +597,16 @@ func (applicationL) LoadType(ctx context.Context, e boil.ContextExecutor, singul return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`application_types`), - qm.WhereIn(`application_types.id in ?`, args...), + qm.WhereIn(`application_types.id in ?`, argsSlice...), qmhelper.WhereIsNull(`application_types.deleted_at`), ) if mods != nil { @@ -669,30 +696,23 @@ func (applicationL) LoadApproverGroup(ctx context.Context, e boil.ContextExecuto } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &applicationR{} } if !queries.IsNil(object.ApproverGroupID) { - args = append(args, object.ApproverGroupID) + args[object.ApproverGroupID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &applicationR{} } - for _, a := range args { - if queries.Equal(a, obj.ApproverGroupID) { - continue Outer - } - } - if !queries.IsNil(obj.ApproverGroupID) { - args = append(args, obj.ApproverGroupID) + args[obj.ApproverGroupID] = struct{}{} } } @@ -702,9 +722,16 @@ func (applicationL) LoadApproverGroup(ctx context.Context, e boil.ContextExecuto return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { @@ -794,26 +821,18 @@ func (applicationL) LoadSubjectApplicationAuditEvents(ctx context.Context, e boi } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &applicationR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &applicationR{} } - - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -821,9 +840,16 @@ func (applicationL) LoadSubjectApplicationAuditEvents(ctx context.Context, e boi return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`audit_events`), - qm.WhereIn(`audit_events.subject_application_id in ?`, args...), + qm.WhereIn(`audit_events.subject_application_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -908,26 +934,18 @@ func (applicationL) LoadGroupApplicationRequests(ctx context.Context, e boil.Con } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &applicationR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &applicationR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -935,9 +953,16 @@ func (applicationL) LoadGroupApplicationRequests(ctx context.Context, e boil.Con return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_application_requests`), - qm.WhereIn(`group_application_requests.application_id in ?`, args...), + qm.WhereIn(`group_application_requests.application_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1022,26 +1047,18 @@ func (applicationL) LoadGroupApplications(ctx context.Context, e boil.ContextExe } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &applicationR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &applicationR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1049,9 +1066,16 @@ func (applicationL) LoadGroupApplications(ctx context.Context, e boil.ContextExe return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_applications`), - qm.WhereIn(`group_applications.application_id in ?`, args...), + qm.WhereIn(`group_applications.application_id in ?`, argsSlice...), qmhelper.WhereIsNull(`group_applications.deleted_at`), ) if mods != nil { diff --git a/internal/models/audit_events.go b/internal/models/audit_events.go index b2f3f55..8609cea 100644 --- a/internal/models/audit_events.go +++ b/internal/models/audit_events.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -250,18 +250,27 @@ var ( _ = qmhelper.Where ) +var auditEventAfterSelectMu sync.Mutex var auditEventAfterSelectHooks []AuditEventHook +var auditEventBeforeInsertMu sync.Mutex var auditEventBeforeInsertHooks []AuditEventHook +var auditEventAfterInsertMu sync.Mutex var auditEventAfterInsertHooks []AuditEventHook +var auditEventBeforeUpdateMu sync.Mutex var auditEventBeforeUpdateHooks []AuditEventHook +var auditEventAfterUpdateMu sync.Mutex var auditEventAfterUpdateHooks []AuditEventHook +var auditEventBeforeDeleteMu sync.Mutex var auditEventBeforeDeleteHooks []AuditEventHook +var auditEventAfterDeleteMu sync.Mutex var auditEventAfterDeleteHooks []AuditEventHook +var auditEventBeforeUpsertMu sync.Mutex var auditEventBeforeUpsertHooks []AuditEventHook +var auditEventAfterUpsertMu sync.Mutex var auditEventAfterUpsertHooks []AuditEventHook // doAfterSelectHooks executes all "after Select" hooks. @@ -403,23 +412,41 @@ func (o *AuditEvent) doAfterUpsertHooks(ctx context.Context, exec boil.ContextEx func AddAuditEventHook(hookPoint boil.HookPoint, auditEventHook AuditEventHook) { switch hookPoint { case boil.AfterSelectHook: + auditEventAfterSelectMu.Lock() auditEventAfterSelectHooks = append(auditEventAfterSelectHooks, auditEventHook) + auditEventAfterSelectMu.Unlock() case boil.BeforeInsertHook: + auditEventBeforeInsertMu.Lock() auditEventBeforeInsertHooks = append(auditEventBeforeInsertHooks, auditEventHook) + auditEventBeforeInsertMu.Unlock() case boil.AfterInsertHook: + auditEventAfterInsertMu.Lock() auditEventAfterInsertHooks = append(auditEventAfterInsertHooks, auditEventHook) + auditEventAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + auditEventBeforeUpdateMu.Lock() auditEventBeforeUpdateHooks = append(auditEventBeforeUpdateHooks, auditEventHook) + auditEventBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + auditEventAfterUpdateMu.Lock() auditEventAfterUpdateHooks = append(auditEventAfterUpdateHooks, auditEventHook) + auditEventAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + auditEventBeforeDeleteMu.Lock() auditEventBeforeDeleteHooks = append(auditEventBeforeDeleteHooks, auditEventHook) + auditEventBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + auditEventAfterDeleteMu.Lock() auditEventAfterDeleteHooks = append(auditEventAfterDeleteHooks, auditEventHook) + auditEventAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + auditEventBeforeUpsertMu.Lock() auditEventBeforeUpsertHooks = append(auditEventBeforeUpsertHooks, auditEventHook) + auditEventBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + auditEventAfterUpsertMu.Lock() auditEventAfterUpsertHooks = append(auditEventAfterUpsertHooks, auditEventHook) + auditEventAfterUpsertMu.Unlock() } } @@ -578,30 +605,23 @@ func (auditEventL) LoadSubjectUser(ctx context.Context, e boil.ContextExecutor, } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &auditEventR{} } if !queries.IsNil(object.SubjectUserID) { - args = append(args, object.SubjectUserID) + args[object.SubjectUserID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &auditEventR{} } - for _, a := range args { - if queries.Equal(a, obj.SubjectUserID) { - continue Outer - } - } - if !queries.IsNil(obj.SubjectUserID) { - args = append(args, obj.SubjectUserID) + args[obj.SubjectUserID] = struct{}{} } } @@ -611,9 +631,16 @@ func (auditEventL) LoadSubjectUser(ctx context.Context, e boil.ContextExecutor, return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`users`), - qm.WhereIn(`users.id in ?`, args...), + qm.WhereIn(`users.id in ?`, argsSlice...), qmhelper.WhereIsNull(`users.deleted_at`), ) if mods != nil { @@ -703,30 +730,23 @@ func (auditEventL) LoadSubjectOrganization(ctx context.Context, e boil.ContextEx } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &auditEventR{} } if !queries.IsNil(object.SubjectOrganizationID) { - args = append(args, object.SubjectOrganizationID) + args[object.SubjectOrganizationID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &auditEventR{} } - for _, a := range args { - if queries.Equal(a, obj.SubjectOrganizationID) { - continue Outer - } - } - if !queries.IsNil(obj.SubjectOrganizationID) { - args = append(args, obj.SubjectOrganizationID) + args[obj.SubjectOrganizationID] = struct{}{} } } @@ -736,9 +756,16 @@ func (auditEventL) LoadSubjectOrganization(ctx context.Context, e boil.ContextEx return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`organizations`), - qm.WhereIn(`organizations.id in ?`, args...), + qm.WhereIn(`organizations.id in ?`, argsSlice...), qmhelper.WhereIsNull(`organizations.deleted_at`), ) if mods != nil { @@ -828,30 +855,23 @@ func (auditEventL) LoadSubjectGroup(ctx context.Context, e boil.ContextExecutor, } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &auditEventR{} } if !queries.IsNil(object.SubjectGroupID) { - args = append(args, object.SubjectGroupID) + args[object.SubjectGroupID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &auditEventR{} } - for _, a := range args { - if queries.Equal(a, obj.SubjectGroupID) { - continue Outer - } - } - if !queries.IsNil(obj.SubjectGroupID) { - args = append(args, obj.SubjectGroupID) + args[obj.SubjectGroupID] = struct{}{} } } @@ -861,9 +881,16 @@ func (auditEventL) LoadSubjectGroup(ctx context.Context, e boil.ContextExecutor, return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { @@ -953,30 +980,23 @@ func (auditEventL) LoadSubjectApplication(ctx context.Context, e boil.ContextExe } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &auditEventR{} } if !queries.IsNil(object.SubjectApplicationID) { - args = append(args, object.SubjectApplicationID) + args[object.SubjectApplicationID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &auditEventR{} } - for _, a := range args { - if queries.Equal(a, obj.SubjectApplicationID) { - continue Outer - } - } - if !queries.IsNil(obj.SubjectApplicationID) { - args = append(args, obj.SubjectApplicationID) + args[obj.SubjectApplicationID] = struct{}{} } } @@ -986,9 +1006,16 @@ func (auditEventL) LoadSubjectApplication(ctx context.Context, e boil.ContextExe return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`applications`), - qm.WhereIn(`applications.id in ?`, args...), + qm.WhereIn(`applications.id in ?`, argsSlice...), qmhelper.WhereIsNull(`applications.deleted_at`), ) if mods != nil { @@ -1078,30 +1105,23 @@ func (auditEventL) LoadActor(ctx context.Context, e boil.ContextExecutor, singul } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &auditEventR{} } if !queries.IsNil(object.ActorID) { - args = append(args, object.ActorID) + args[object.ActorID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &auditEventR{} } - for _, a := range args { - if queries.Equal(a, obj.ActorID) { - continue Outer - } - } - if !queries.IsNil(obj.ActorID) { - args = append(args, obj.ActorID) + args[obj.ActorID] = struct{}{} } } @@ -1111,9 +1131,16 @@ func (auditEventL) LoadActor(ctx context.Context, e boil.ContextExecutor, singul return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`users`), - qm.WhereIn(`users.id in ?`, args...), + qm.WhereIn(`users.id in ?`, argsSlice...), qmhelper.WhereIsNull(`users.deleted_at`), ) if mods != nil { diff --git a/internal/models/boil_queries.go b/internal/models/boil_queries.go index 171346b..e8db654 100644 --- a/internal/models/boil_queries.go +++ b/internal/models/boil_queries.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/internal/models/boil_table_names.go b/internal/models/boil_table_names.go index cf93787..403c958 100644 --- a/internal/models/boil_table_names.go +++ b/internal/models/boil_table_names.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/internal/models/boil_types.go b/internal/models/boil_types.go index 23ad5ac..f1157ed 100644 --- a/internal/models/boil_types.go +++ b/internal/models/boil_types.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/internal/models/boil_view_names.go b/internal/models/boil_view_names.go index 9f42d9e..d8e2111 100644 --- a/internal/models/boil_view_names.go +++ b/internal/models/boil_view_names.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/internal/models/crdb_upsert.go b/internal/models/crdb_upsert.go index 2c6c25a..d83918c 100644 --- a/internal/models/crdb_upsert.go +++ b/internal/models/crdb_upsert.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models diff --git a/internal/models/extension_resource_definitions.go b/internal/models/extension_resource_definitions.go index c85c9db..9db6765 100644 --- a/internal/models/extension_resource_definitions.go +++ b/internal/models/extension_resource_definitions.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -253,18 +253,27 @@ var ( _ = qmhelper.Where ) +var extensionResourceDefinitionAfterSelectMu sync.Mutex var extensionResourceDefinitionAfterSelectHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionBeforeInsertMu sync.Mutex var extensionResourceDefinitionBeforeInsertHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionAfterInsertMu sync.Mutex var extensionResourceDefinitionAfterInsertHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionBeforeUpdateMu sync.Mutex var extensionResourceDefinitionBeforeUpdateHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionAfterUpdateMu sync.Mutex var extensionResourceDefinitionAfterUpdateHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionBeforeDeleteMu sync.Mutex var extensionResourceDefinitionBeforeDeleteHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionAfterDeleteMu sync.Mutex var extensionResourceDefinitionAfterDeleteHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionBeforeUpsertMu sync.Mutex var extensionResourceDefinitionBeforeUpsertHooks []ExtensionResourceDefinitionHook +var extensionResourceDefinitionAfterUpsertMu sync.Mutex var extensionResourceDefinitionAfterUpsertHooks []ExtensionResourceDefinitionHook // doAfterSelectHooks executes all "after Select" hooks. @@ -406,23 +415,41 @@ func (o *ExtensionResourceDefinition) doAfterUpsertHooks(ctx context.Context, ex func AddExtensionResourceDefinitionHook(hookPoint boil.HookPoint, extensionResourceDefinitionHook ExtensionResourceDefinitionHook) { switch hookPoint { case boil.AfterSelectHook: + extensionResourceDefinitionAfterSelectMu.Lock() extensionResourceDefinitionAfterSelectHooks = append(extensionResourceDefinitionAfterSelectHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionAfterSelectMu.Unlock() case boil.BeforeInsertHook: + extensionResourceDefinitionBeforeInsertMu.Lock() extensionResourceDefinitionBeforeInsertHooks = append(extensionResourceDefinitionBeforeInsertHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionBeforeInsertMu.Unlock() case boil.AfterInsertHook: + extensionResourceDefinitionAfterInsertMu.Lock() extensionResourceDefinitionAfterInsertHooks = append(extensionResourceDefinitionAfterInsertHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + extensionResourceDefinitionBeforeUpdateMu.Lock() extensionResourceDefinitionBeforeUpdateHooks = append(extensionResourceDefinitionBeforeUpdateHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + extensionResourceDefinitionAfterUpdateMu.Lock() extensionResourceDefinitionAfterUpdateHooks = append(extensionResourceDefinitionAfterUpdateHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + extensionResourceDefinitionBeforeDeleteMu.Lock() extensionResourceDefinitionBeforeDeleteHooks = append(extensionResourceDefinitionBeforeDeleteHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + extensionResourceDefinitionAfterDeleteMu.Lock() extensionResourceDefinitionAfterDeleteHooks = append(extensionResourceDefinitionAfterDeleteHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + extensionResourceDefinitionBeforeUpsertMu.Lock() extensionResourceDefinitionBeforeUpsertHooks = append(extensionResourceDefinitionBeforeUpsertHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + extensionResourceDefinitionAfterUpsertMu.Lock() extensionResourceDefinitionAfterUpsertHooks = append(extensionResourceDefinitionAfterUpsertHooks, extensionResourceDefinitionHook) + extensionResourceDefinitionAfterUpsertMu.Unlock() } } @@ -565,27 +592,20 @@ func (extensionResourceDefinitionL) LoadExtension(ctx context.Context, e boil.Co } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &extensionResourceDefinitionR{} } - args = append(args, object.ExtensionID) + args[object.ExtensionID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &extensionResourceDefinitionR{} } - for _, a := range args { - if a == obj.ExtensionID { - continue Outer - } - } - - args = append(args, obj.ExtensionID) + args[obj.ExtensionID] = struct{}{} } } @@ -594,9 +614,16 @@ func (extensionResourceDefinitionL) LoadExtension(ctx context.Context, e boil.Co return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`extensions`), - qm.WhereIn(`extensions.id in ?`, args...), + qm.WhereIn(`extensions.id in ?`, argsSlice...), qmhelper.WhereIsNull(`extensions.deleted_at`), ) if mods != nil { @@ -686,26 +713,18 @@ func (extensionResourceDefinitionL) LoadSystemExtensionResources(ctx context.Con } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &extensionResourceDefinitionR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &extensionResourceDefinitionR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -713,9 +732,16 @@ func (extensionResourceDefinitionL) LoadSystemExtensionResources(ctx context.Con return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`system_extension_resources`), - qm.WhereIn(`system_extension_resources.extension_resource_definition_id in ?`, args...), + qm.WhereIn(`system_extension_resources.extension_resource_definition_id in ?`, argsSlice...), qmhelper.WhereIsNull(`system_extension_resources.deleted_at`), ) if mods != nil { @@ -801,26 +827,18 @@ func (extensionResourceDefinitionL) LoadUserExtensionResources(ctx context.Conte } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &extensionResourceDefinitionR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &extensionResourceDefinitionR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -828,9 +846,16 @@ func (extensionResourceDefinitionL) LoadUserExtensionResources(ctx context.Conte return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`user_extension_resources`), - qm.WhereIn(`user_extension_resources.extension_resource_definition_id in ?`, args...), + qm.WhereIn(`user_extension_resources.extension_resource_definition_id in ?`, argsSlice...), qmhelper.WhereIsNull(`user_extension_resources.deleted_at`), ) if mods != nil { diff --git a/internal/models/extensions.go b/internal/models/extensions.go index 96c361a..35b29ec 100644 --- a/internal/models/extensions.go +++ b/internal/models/extensions.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -174,18 +174,27 @@ var ( _ = qmhelper.Where ) +var extensionAfterSelectMu sync.Mutex var extensionAfterSelectHooks []ExtensionHook +var extensionBeforeInsertMu sync.Mutex var extensionBeforeInsertHooks []ExtensionHook +var extensionAfterInsertMu sync.Mutex var extensionAfterInsertHooks []ExtensionHook +var extensionBeforeUpdateMu sync.Mutex var extensionBeforeUpdateHooks []ExtensionHook +var extensionAfterUpdateMu sync.Mutex var extensionAfterUpdateHooks []ExtensionHook +var extensionBeforeDeleteMu sync.Mutex var extensionBeforeDeleteHooks []ExtensionHook +var extensionAfterDeleteMu sync.Mutex var extensionAfterDeleteHooks []ExtensionHook +var extensionBeforeUpsertMu sync.Mutex var extensionBeforeUpsertHooks []ExtensionHook +var extensionAfterUpsertMu sync.Mutex var extensionAfterUpsertHooks []ExtensionHook // doAfterSelectHooks executes all "after Select" hooks. @@ -327,23 +336,41 @@ func (o *Extension) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExe func AddExtensionHook(hookPoint boil.HookPoint, extensionHook ExtensionHook) { switch hookPoint { case boil.AfterSelectHook: + extensionAfterSelectMu.Lock() extensionAfterSelectHooks = append(extensionAfterSelectHooks, extensionHook) + extensionAfterSelectMu.Unlock() case boil.BeforeInsertHook: + extensionBeforeInsertMu.Lock() extensionBeforeInsertHooks = append(extensionBeforeInsertHooks, extensionHook) + extensionBeforeInsertMu.Unlock() case boil.AfterInsertHook: + extensionAfterInsertMu.Lock() extensionAfterInsertHooks = append(extensionAfterInsertHooks, extensionHook) + extensionAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + extensionBeforeUpdateMu.Lock() extensionBeforeUpdateHooks = append(extensionBeforeUpdateHooks, extensionHook) + extensionBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + extensionAfterUpdateMu.Lock() extensionAfterUpdateHooks = append(extensionAfterUpdateHooks, extensionHook) + extensionAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + extensionBeforeDeleteMu.Lock() extensionBeforeDeleteHooks = append(extensionBeforeDeleteHooks, extensionHook) + extensionBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + extensionAfterDeleteMu.Lock() extensionAfterDeleteHooks = append(extensionAfterDeleteHooks, extensionHook) + extensionAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + extensionBeforeUpsertMu.Lock() extensionBeforeUpsertHooks = append(extensionBeforeUpsertHooks, extensionHook) + extensionBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + extensionAfterUpsertMu.Lock() extensionAfterUpsertHooks = append(extensionAfterUpsertHooks, extensionHook) + extensionAfterUpsertMu.Unlock() } } @@ -461,26 +488,18 @@ func (extensionL) LoadExtensionResourceDefinitions(ctx context.Context, e boil.C } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &extensionR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &extensionR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -488,9 +507,16 @@ func (extensionL) LoadExtensionResourceDefinitions(ctx context.Context, e boil.C return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`extension_resource_definitions`), - qm.WhereIn(`extension_resource_definitions.extension_id in ?`, args...), + qm.WhereIn(`extension_resource_definitions.extension_id in ?`, argsSlice...), qmhelper.WhereIsNull(`extension_resource_definitions.deleted_at`), ) if mods != nil { diff --git a/internal/models/group_application_requests.go b/internal/models/group_application_requests.go index 0393be5..5338f47 100644 --- a/internal/models/group_application_requests.go +++ b/internal/models/group_application_requests.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -197,18 +197,27 @@ var ( _ = qmhelper.Where ) +var groupApplicationRequestAfterSelectMu sync.Mutex var groupApplicationRequestAfterSelectHooks []GroupApplicationRequestHook +var groupApplicationRequestBeforeInsertMu sync.Mutex var groupApplicationRequestBeforeInsertHooks []GroupApplicationRequestHook +var groupApplicationRequestAfterInsertMu sync.Mutex var groupApplicationRequestAfterInsertHooks []GroupApplicationRequestHook +var groupApplicationRequestBeforeUpdateMu sync.Mutex var groupApplicationRequestBeforeUpdateHooks []GroupApplicationRequestHook +var groupApplicationRequestAfterUpdateMu sync.Mutex var groupApplicationRequestAfterUpdateHooks []GroupApplicationRequestHook +var groupApplicationRequestBeforeDeleteMu sync.Mutex var groupApplicationRequestBeforeDeleteHooks []GroupApplicationRequestHook +var groupApplicationRequestAfterDeleteMu sync.Mutex var groupApplicationRequestAfterDeleteHooks []GroupApplicationRequestHook +var groupApplicationRequestBeforeUpsertMu sync.Mutex var groupApplicationRequestBeforeUpsertHooks []GroupApplicationRequestHook +var groupApplicationRequestAfterUpsertMu sync.Mutex var groupApplicationRequestAfterUpsertHooks []GroupApplicationRequestHook // doAfterSelectHooks executes all "after Select" hooks. @@ -350,23 +359,41 @@ func (o *GroupApplicationRequest) doAfterUpsertHooks(ctx context.Context, exec b func AddGroupApplicationRequestHook(hookPoint boil.HookPoint, groupApplicationRequestHook GroupApplicationRequestHook) { switch hookPoint { case boil.AfterSelectHook: + groupApplicationRequestAfterSelectMu.Lock() groupApplicationRequestAfterSelectHooks = append(groupApplicationRequestAfterSelectHooks, groupApplicationRequestHook) + groupApplicationRequestAfterSelectMu.Unlock() case boil.BeforeInsertHook: + groupApplicationRequestBeforeInsertMu.Lock() groupApplicationRequestBeforeInsertHooks = append(groupApplicationRequestBeforeInsertHooks, groupApplicationRequestHook) + groupApplicationRequestBeforeInsertMu.Unlock() case boil.AfterInsertHook: + groupApplicationRequestAfterInsertMu.Lock() groupApplicationRequestAfterInsertHooks = append(groupApplicationRequestAfterInsertHooks, groupApplicationRequestHook) + groupApplicationRequestAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + groupApplicationRequestBeforeUpdateMu.Lock() groupApplicationRequestBeforeUpdateHooks = append(groupApplicationRequestBeforeUpdateHooks, groupApplicationRequestHook) + groupApplicationRequestBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + groupApplicationRequestAfterUpdateMu.Lock() groupApplicationRequestAfterUpdateHooks = append(groupApplicationRequestAfterUpdateHooks, groupApplicationRequestHook) + groupApplicationRequestAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + groupApplicationRequestBeforeDeleteMu.Lock() groupApplicationRequestBeforeDeleteHooks = append(groupApplicationRequestBeforeDeleteHooks, groupApplicationRequestHook) + groupApplicationRequestBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + groupApplicationRequestAfterDeleteMu.Lock() groupApplicationRequestAfterDeleteHooks = append(groupApplicationRequestAfterDeleteHooks, groupApplicationRequestHook) + groupApplicationRequestAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + groupApplicationRequestBeforeUpsertMu.Lock() groupApplicationRequestBeforeUpsertHooks = append(groupApplicationRequestBeforeUpsertHooks, groupApplicationRequestHook) + groupApplicationRequestBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + groupApplicationRequestAfterUpsertMu.Lock() groupApplicationRequestAfterUpsertHooks = append(groupApplicationRequestAfterUpsertHooks, groupApplicationRequestHook) + groupApplicationRequestAfterUpsertMu.Unlock() } } @@ -514,27 +541,20 @@ func (groupApplicationRequestL) LoadRequesterUser(ctx context.Context, e boil.Co } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupApplicationRequestR{} } - args = append(args, object.RequesterUserID) + args[object.RequesterUserID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupApplicationRequestR{} } - for _, a := range args { - if a == obj.RequesterUserID { - continue Outer - } - } - - args = append(args, obj.RequesterUserID) + args[obj.RequesterUserID] = struct{}{} } } @@ -543,9 +563,16 @@ func (groupApplicationRequestL) LoadRequesterUser(ctx context.Context, e boil.Co return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`users`), - qm.WhereIn(`users.id in ?`, args...), + qm.WhereIn(`users.id in ?`, argsSlice...), qmhelper.WhereIsNull(`users.deleted_at`), ) if mods != nil { @@ -635,27 +662,20 @@ func (groupApplicationRequestL) LoadGroup(ctx context.Context, e boil.ContextExe } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupApplicationRequestR{} } - args = append(args, object.GroupID) + args[object.GroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupApplicationRequestR{} } - for _, a := range args { - if a == obj.GroupID { - continue Outer - } - } - - args = append(args, obj.GroupID) + args[obj.GroupID] = struct{}{} } } @@ -664,9 +684,16 @@ func (groupApplicationRequestL) LoadGroup(ctx context.Context, e boil.ContextExe return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { @@ -756,27 +783,20 @@ func (groupApplicationRequestL) LoadApproverGroup(ctx context.Context, e boil.Co } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupApplicationRequestR{} } - args = append(args, object.ApproverGroupID) + args[object.ApproverGroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupApplicationRequestR{} } - for _, a := range args { - if a == obj.ApproverGroupID { - continue Outer - } - } - - args = append(args, obj.ApproverGroupID) + args[obj.ApproverGroupID] = struct{}{} } } @@ -785,9 +805,16 @@ func (groupApplicationRequestL) LoadApproverGroup(ctx context.Context, e boil.Co return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { @@ -877,27 +904,20 @@ func (groupApplicationRequestL) LoadApplication(ctx context.Context, e boil.Cont } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupApplicationRequestR{} } - args = append(args, object.ApplicationID) + args[object.ApplicationID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupApplicationRequestR{} } - for _, a := range args { - if a == obj.ApplicationID { - continue Outer - } - } - - args = append(args, obj.ApplicationID) + args[obj.ApplicationID] = struct{}{} } } @@ -906,9 +926,16 @@ func (groupApplicationRequestL) LoadApplication(ctx context.Context, e boil.Cont return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`applications`), - qm.WhereIn(`applications.id in ?`, args...), + qm.WhereIn(`applications.id in ?`, argsSlice...), qmhelper.WhereIsNull(`applications.deleted_at`), ) if mods != nil { diff --git a/internal/models/group_applications.go b/internal/models/group_applications.go index 134be7b..7c4c2a7 100644 --- a/internal/models/group_applications.go +++ b/internal/models/group_applications.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -163,18 +163,27 @@ var ( _ = qmhelper.Where ) +var groupApplicationAfterSelectMu sync.Mutex var groupApplicationAfterSelectHooks []GroupApplicationHook +var groupApplicationBeforeInsertMu sync.Mutex var groupApplicationBeforeInsertHooks []GroupApplicationHook +var groupApplicationAfterInsertMu sync.Mutex var groupApplicationAfterInsertHooks []GroupApplicationHook +var groupApplicationBeforeUpdateMu sync.Mutex var groupApplicationBeforeUpdateHooks []GroupApplicationHook +var groupApplicationAfterUpdateMu sync.Mutex var groupApplicationAfterUpdateHooks []GroupApplicationHook +var groupApplicationBeforeDeleteMu sync.Mutex var groupApplicationBeforeDeleteHooks []GroupApplicationHook +var groupApplicationAfterDeleteMu sync.Mutex var groupApplicationAfterDeleteHooks []GroupApplicationHook +var groupApplicationBeforeUpsertMu sync.Mutex var groupApplicationBeforeUpsertHooks []GroupApplicationHook +var groupApplicationAfterUpsertMu sync.Mutex var groupApplicationAfterUpsertHooks []GroupApplicationHook // doAfterSelectHooks executes all "after Select" hooks. @@ -316,23 +325,41 @@ func (o *GroupApplication) doAfterUpsertHooks(ctx context.Context, exec boil.Con func AddGroupApplicationHook(hookPoint boil.HookPoint, groupApplicationHook GroupApplicationHook) { switch hookPoint { case boil.AfterSelectHook: + groupApplicationAfterSelectMu.Lock() groupApplicationAfterSelectHooks = append(groupApplicationAfterSelectHooks, groupApplicationHook) + groupApplicationAfterSelectMu.Unlock() case boil.BeforeInsertHook: + groupApplicationBeforeInsertMu.Lock() groupApplicationBeforeInsertHooks = append(groupApplicationBeforeInsertHooks, groupApplicationHook) + groupApplicationBeforeInsertMu.Unlock() case boil.AfterInsertHook: + groupApplicationAfterInsertMu.Lock() groupApplicationAfterInsertHooks = append(groupApplicationAfterInsertHooks, groupApplicationHook) + groupApplicationAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + groupApplicationBeforeUpdateMu.Lock() groupApplicationBeforeUpdateHooks = append(groupApplicationBeforeUpdateHooks, groupApplicationHook) + groupApplicationBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + groupApplicationAfterUpdateMu.Lock() groupApplicationAfterUpdateHooks = append(groupApplicationAfterUpdateHooks, groupApplicationHook) + groupApplicationAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + groupApplicationBeforeDeleteMu.Lock() groupApplicationBeforeDeleteHooks = append(groupApplicationBeforeDeleteHooks, groupApplicationHook) + groupApplicationBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + groupApplicationAfterDeleteMu.Lock() groupApplicationAfterDeleteHooks = append(groupApplicationAfterDeleteHooks, groupApplicationHook) + groupApplicationAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + groupApplicationBeforeUpsertMu.Lock() groupApplicationBeforeUpsertHooks = append(groupApplicationBeforeUpsertHooks, groupApplicationHook) + groupApplicationBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + groupApplicationAfterUpsertMu.Lock() groupApplicationAfterUpsertHooks = append(groupApplicationAfterUpsertHooks, groupApplicationHook) + groupApplicationAfterUpsertMu.Unlock() } } @@ -458,27 +485,20 @@ func (groupApplicationL) LoadGroup(ctx context.Context, e boil.ContextExecutor, } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupApplicationR{} } - args = append(args, object.GroupID) + args[object.GroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupApplicationR{} } - for _, a := range args { - if a == obj.GroupID { - continue Outer - } - } - - args = append(args, obj.GroupID) + args[obj.GroupID] = struct{}{} } } @@ -487,9 +507,16 @@ func (groupApplicationL) LoadGroup(ctx context.Context, e boil.ContextExecutor, return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { @@ -579,27 +606,20 @@ func (groupApplicationL) LoadApplication(ctx context.Context, e boil.ContextExec } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupApplicationR{} } - args = append(args, object.ApplicationID) + args[object.ApplicationID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupApplicationR{} } - for _, a := range args { - if a == obj.ApplicationID { - continue Outer - } - } - - args = append(args, obj.ApplicationID) + args[obj.ApplicationID] = struct{}{} } } @@ -608,9 +628,16 @@ func (groupApplicationL) LoadApplication(ctx context.Context, e boil.ContextExec return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`applications`), - qm.WhereIn(`applications.id in ?`, args...), + qm.WhereIn(`applications.id in ?`, argsSlice...), qmhelper.WhereIsNull(`applications.deleted_at`), ) if mods != nil { diff --git a/internal/models/group_hierarchies.go b/internal/models/group_hierarchies.go index 3673e02..441dd18 100644 --- a/internal/models/group_hierarchies.go +++ b/internal/models/group_hierarchies.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -163,18 +163,27 @@ var ( _ = qmhelper.Where ) +var groupHierarchyAfterSelectMu sync.Mutex var groupHierarchyAfterSelectHooks []GroupHierarchyHook +var groupHierarchyBeforeInsertMu sync.Mutex var groupHierarchyBeforeInsertHooks []GroupHierarchyHook +var groupHierarchyAfterInsertMu sync.Mutex var groupHierarchyAfterInsertHooks []GroupHierarchyHook +var groupHierarchyBeforeUpdateMu sync.Mutex var groupHierarchyBeforeUpdateHooks []GroupHierarchyHook +var groupHierarchyAfterUpdateMu sync.Mutex var groupHierarchyAfterUpdateHooks []GroupHierarchyHook +var groupHierarchyBeforeDeleteMu sync.Mutex var groupHierarchyBeforeDeleteHooks []GroupHierarchyHook +var groupHierarchyAfterDeleteMu sync.Mutex var groupHierarchyAfterDeleteHooks []GroupHierarchyHook +var groupHierarchyBeforeUpsertMu sync.Mutex var groupHierarchyBeforeUpsertHooks []GroupHierarchyHook +var groupHierarchyAfterUpsertMu sync.Mutex var groupHierarchyAfterUpsertHooks []GroupHierarchyHook // doAfterSelectHooks executes all "after Select" hooks. @@ -316,23 +325,41 @@ func (o *GroupHierarchy) doAfterUpsertHooks(ctx context.Context, exec boil.Conte func AddGroupHierarchyHook(hookPoint boil.HookPoint, groupHierarchyHook GroupHierarchyHook) { switch hookPoint { case boil.AfterSelectHook: + groupHierarchyAfterSelectMu.Lock() groupHierarchyAfterSelectHooks = append(groupHierarchyAfterSelectHooks, groupHierarchyHook) + groupHierarchyAfterSelectMu.Unlock() case boil.BeforeInsertHook: + groupHierarchyBeforeInsertMu.Lock() groupHierarchyBeforeInsertHooks = append(groupHierarchyBeforeInsertHooks, groupHierarchyHook) + groupHierarchyBeforeInsertMu.Unlock() case boil.AfterInsertHook: + groupHierarchyAfterInsertMu.Lock() groupHierarchyAfterInsertHooks = append(groupHierarchyAfterInsertHooks, groupHierarchyHook) + groupHierarchyAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + groupHierarchyBeforeUpdateMu.Lock() groupHierarchyBeforeUpdateHooks = append(groupHierarchyBeforeUpdateHooks, groupHierarchyHook) + groupHierarchyBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + groupHierarchyAfterUpdateMu.Lock() groupHierarchyAfterUpdateHooks = append(groupHierarchyAfterUpdateHooks, groupHierarchyHook) + groupHierarchyAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + groupHierarchyBeforeDeleteMu.Lock() groupHierarchyBeforeDeleteHooks = append(groupHierarchyBeforeDeleteHooks, groupHierarchyHook) + groupHierarchyBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + groupHierarchyAfterDeleteMu.Lock() groupHierarchyAfterDeleteHooks = append(groupHierarchyAfterDeleteHooks, groupHierarchyHook) + groupHierarchyAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + groupHierarchyBeforeUpsertMu.Lock() groupHierarchyBeforeUpsertHooks = append(groupHierarchyBeforeUpsertHooks, groupHierarchyHook) + groupHierarchyBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + groupHierarchyAfterUpsertMu.Lock() groupHierarchyAfterUpsertHooks = append(groupHierarchyAfterUpsertHooks, groupHierarchyHook) + groupHierarchyAfterUpsertMu.Unlock() } } @@ -458,27 +485,20 @@ func (groupHierarchyL) LoadParentGroup(ctx context.Context, e boil.ContextExecut } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupHierarchyR{} } - args = append(args, object.ParentGroupID) + args[object.ParentGroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupHierarchyR{} } - for _, a := range args { - if a == obj.ParentGroupID { - continue Outer - } - } - - args = append(args, obj.ParentGroupID) + args[obj.ParentGroupID] = struct{}{} } } @@ -487,9 +507,16 @@ func (groupHierarchyL) LoadParentGroup(ctx context.Context, e boil.ContextExecut return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { @@ -579,27 +606,20 @@ func (groupHierarchyL) LoadMemberGroup(ctx context.Context, e boil.ContextExecut } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupHierarchyR{} } - args = append(args, object.MemberGroupID) + args[object.MemberGroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupHierarchyR{} } - for _, a := range args { - if a == obj.MemberGroupID { - continue Outer - } - } - - args = append(args, obj.MemberGroupID) + args[obj.MemberGroupID] = struct{}{} } } @@ -608,9 +628,16 @@ func (groupHierarchyL) LoadMemberGroup(ctx context.Context, e boil.ContextExecut return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { diff --git a/internal/models/group_membership_requests.go b/internal/models/group_membership_requests.go index 41d52c0..c4af47a 100644 --- a/internal/models/group_membership_requests.go +++ b/internal/models/group_membership_requests.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -191,18 +191,27 @@ var ( _ = qmhelper.Where ) +var groupMembershipRequestAfterSelectMu sync.Mutex var groupMembershipRequestAfterSelectHooks []GroupMembershipRequestHook +var groupMembershipRequestBeforeInsertMu sync.Mutex var groupMembershipRequestBeforeInsertHooks []GroupMembershipRequestHook +var groupMembershipRequestAfterInsertMu sync.Mutex var groupMembershipRequestAfterInsertHooks []GroupMembershipRequestHook +var groupMembershipRequestBeforeUpdateMu sync.Mutex var groupMembershipRequestBeforeUpdateHooks []GroupMembershipRequestHook +var groupMembershipRequestAfterUpdateMu sync.Mutex var groupMembershipRequestAfterUpdateHooks []GroupMembershipRequestHook +var groupMembershipRequestBeforeDeleteMu sync.Mutex var groupMembershipRequestBeforeDeleteHooks []GroupMembershipRequestHook +var groupMembershipRequestAfterDeleteMu sync.Mutex var groupMembershipRequestAfterDeleteHooks []GroupMembershipRequestHook +var groupMembershipRequestBeforeUpsertMu sync.Mutex var groupMembershipRequestBeforeUpsertHooks []GroupMembershipRequestHook +var groupMembershipRequestAfterUpsertMu sync.Mutex var groupMembershipRequestAfterUpsertHooks []GroupMembershipRequestHook // doAfterSelectHooks executes all "after Select" hooks. @@ -344,23 +353,41 @@ func (o *GroupMembershipRequest) doAfterUpsertHooks(ctx context.Context, exec bo func AddGroupMembershipRequestHook(hookPoint boil.HookPoint, groupMembershipRequestHook GroupMembershipRequestHook) { switch hookPoint { case boil.AfterSelectHook: + groupMembershipRequestAfterSelectMu.Lock() groupMembershipRequestAfterSelectHooks = append(groupMembershipRequestAfterSelectHooks, groupMembershipRequestHook) + groupMembershipRequestAfterSelectMu.Unlock() case boil.BeforeInsertHook: + groupMembershipRequestBeforeInsertMu.Lock() groupMembershipRequestBeforeInsertHooks = append(groupMembershipRequestBeforeInsertHooks, groupMembershipRequestHook) + groupMembershipRequestBeforeInsertMu.Unlock() case boil.AfterInsertHook: + groupMembershipRequestAfterInsertMu.Lock() groupMembershipRequestAfterInsertHooks = append(groupMembershipRequestAfterInsertHooks, groupMembershipRequestHook) + groupMembershipRequestAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + groupMembershipRequestBeforeUpdateMu.Lock() groupMembershipRequestBeforeUpdateHooks = append(groupMembershipRequestBeforeUpdateHooks, groupMembershipRequestHook) + groupMembershipRequestBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + groupMembershipRequestAfterUpdateMu.Lock() groupMembershipRequestAfterUpdateHooks = append(groupMembershipRequestAfterUpdateHooks, groupMembershipRequestHook) + groupMembershipRequestAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + groupMembershipRequestBeforeDeleteMu.Lock() groupMembershipRequestBeforeDeleteHooks = append(groupMembershipRequestBeforeDeleteHooks, groupMembershipRequestHook) + groupMembershipRequestBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + groupMembershipRequestAfterDeleteMu.Lock() groupMembershipRequestAfterDeleteHooks = append(groupMembershipRequestAfterDeleteHooks, groupMembershipRequestHook) + groupMembershipRequestAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + groupMembershipRequestBeforeUpsertMu.Lock() groupMembershipRequestBeforeUpsertHooks = append(groupMembershipRequestBeforeUpsertHooks, groupMembershipRequestHook) + groupMembershipRequestBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + groupMembershipRequestAfterUpsertMu.Lock() groupMembershipRequestAfterUpsertHooks = append(groupMembershipRequestAfterUpsertHooks, groupMembershipRequestHook) + groupMembershipRequestAfterUpsertMu.Unlock() } } @@ -486,27 +513,20 @@ func (groupMembershipRequestL) LoadUser(ctx context.Context, e boil.ContextExecu } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupMembershipRequestR{} } - args = append(args, object.UserID) + args[object.UserID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupMembershipRequestR{} } - for _, a := range args { - if a == obj.UserID { - continue Outer - } - } - - args = append(args, obj.UserID) + args[obj.UserID] = struct{}{} } } @@ -515,9 +535,16 @@ func (groupMembershipRequestL) LoadUser(ctx context.Context, e boil.ContextExecu return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`users`), - qm.WhereIn(`users.id in ?`, args...), + qm.WhereIn(`users.id in ?`, argsSlice...), qmhelper.WhereIsNull(`users.deleted_at`), ) if mods != nil { @@ -607,27 +634,20 @@ func (groupMembershipRequestL) LoadGroup(ctx context.Context, e boil.ContextExec } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupMembershipRequestR{} } - args = append(args, object.GroupID) + args[object.GroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupMembershipRequestR{} } - for _, a := range args { - if a == obj.GroupID { - continue Outer - } - } - - args = append(args, obj.GroupID) + args[obj.GroupID] = struct{}{} } } @@ -636,9 +656,16 @@ func (groupMembershipRequestL) LoadGroup(ctx context.Context, e boil.ContextExec return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { diff --git a/internal/models/group_memberships.go b/internal/models/group_memberships.go index a4d65be..5a0ac56 100644 --- a/internal/models/group_memberships.go +++ b/internal/models/group_memberships.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -177,18 +177,27 @@ var ( _ = qmhelper.Where ) +var groupMembershipAfterSelectMu sync.Mutex var groupMembershipAfterSelectHooks []GroupMembershipHook +var groupMembershipBeforeInsertMu sync.Mutex var groupMembershipBeforeInsertHooks []GroupMembershipHook +var groupMembershipAfterInsertMu sync.Mutex var groupMembershipAfterInsertHooks []GroupMembershipHook +var groupMembershipBeforeUpdateMu sync.Mutex var groupMembershipBeforeUpdateHooks []GroupMembershipHook +var groupMembershipAfterUpdateMu sync.Mutex var groupMembershipAfterUpdateHooks []GroupMembershipHook +var groupMembershipBeforeDeleteMu sync.Mutex var groupMembershipBeforeDeleteHooks []GroupMembershipHook +var groupMembershipAfterDeleteMu sync.Mutex var groupMembershipAfterDeleteHooks []GroupMembershipHook +var groupMembershipBeforeUpsertMu sync.Mutex var groupMembershipBeforeUpsertHooks []GroupMembershipHook +var groupMembershipAfterUpsertMu sync.Mutex var groupMembershipAfterUpsertHooks []GroupMembershipHook // doAfterSelectHooks executes all "after Select" hooks. @@ -330,23 +339,41 @@ func (o *GroupMembership) doAfterUpsertHooks(ctx context.Context, exec boil.Cont func AddGroupMembershipHook(hookPoint boil.HookPoint, groupMembershipHook GroupMembershipHook) { switch hookPoint { case boil.AfterSelectHook: + groupMembershipAfterSelectMu.Lock() groupMembershipAfterSelectHooks = append(groupMembershipAfterSelectHooks, groupMembershipHook) + groupMembershipAfterSelectMu.Unlock() case boil.BeforeInsertHook: + groupMembershipBeforeInsertMu.Lock() groupMembershipBeforeInsertHooks = append(groupMembershipBeforeInsertHooks, groupMembershipHook) + groupMembershipBeforeInsertMu.Unlock() case boil.AfterInsertHook: + groupMembershipAfterInsertMu.Lock() groupMembershipAfterInsertHooks = append(groupMembershipAfterInsertHooks, groupMembershipHook) + groupMembershipAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + groupMembershipBeforeUpdateMu.Lock() groupMembershipBeforeUpdateHooks = append(groupMembershipBeforeUpdateHooks, groupMembershipHook) + groupMembershipBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + groupMembershipAfterUpdateMu.Lock() groupMembershipAfterUpdateHooks = append(groupMembershipAfterUpdateHooks, groupMembershipHook) + groupMembershipAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + groupMembershipBeforeDeleteMu.Lock() groupMembershipBeforeDeleteHooks = append(groupMembershipBeforeDeleteHooks, groupMembershipHook) + groupMembershipBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + groupMembershipAfterDeleteMu.Lock() groupMembershipAfterDeleteHooks = append(groupMembershipAfterDeleteHooks, groupMembershipHook) + groupMembershipAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + groupMembershipBeforeUpsertMu.Lock() groupMembershipBeforeUpsertHooks = append(groupMembershipBeforeUpsertHooks, groupMembershipHook) + groupMembershipBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + groupMembershipAfterUpsertMu.Lock() groupMembershipAfterUpsertHooks = append(groupMembershipAfterUpsertHooks, groupMembershipHook) + groupMembershipAfterUpsertMu.Unlock() } } @@ -472,27 +499,20 @@ func (groupMembershipL) LoadUser(ctx context.Context, e boil.ContextExecutor, si } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupMembershipR{} } - args = append(args, object.UserID) + args[object.UserID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupMembershipR{} } - for _, a := range args { - if a == obj.UserID { - continue Outer - } - } - - args = append(args, obj.UserID) + args[obj.UserID] = struct{}{} } } @@ -501,9 +521,16 @@ func (groupMembershipL) LoadUser(ctx context.Context, e boil.ContextExecutor, si return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`users`), - qm.WhereIn(`users.id in ?`, args...), + qm.WhereIn(`users.id in ?`, argsSlice...), qmhelper.WhereIsNull(`users.deleted_at`), ) if mods != nil { @@ -593,27 +620,20 @@ func (groupMembershipL) LoadGroup(ctx context.Context, e boil.ContextExecutor, s } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupMembershipR{} } - args = append(args, object.GroupID) + args[object.GroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupMembershipR{} } - for _, a := range args { - if a == obj.GroupID { - continue Outer - } - } - - args = append(args, obj.GroupID) + args[obj.GroupID] = struct{}{} } } @@ -622,9 +642,16 @@ func (groupMembershipL) LoadGroup(ctx context.Context, e boil.ContextExecutor, s return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { diff --git a/internal/models/group_organizations.go b/internal/models/group_organizations.go index ea08d7c..3d3160c 100644 --- a/internal/models/group_organizations.go +++ b/internal/models/group_organizations.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -155,18 +155,27 @@ var ( _ = qmhelper.Where ) +var groupOrganizationAfterSelectMu sync.Mutex var groupOrganizationAfterSelectHooks []GroupOrganizationHook +var groupOrganizationBeforeInsertMu sync.Mutex var groupOrganizationBeforeInsertHooks []GroupOrganizationHook +var groupOrganizationAfterInsertMu sync.Mutex var groupOrganizationAfterInsertHooks []GroupOrganizationHook +var groupOrganizationBeforeUpdateMu sync.Mutex var groupOrganizationBeforeUpdateHooks []GroupOrganizationHook +var groupOrganizationAfterUpdateMu sync.Mutex var groupOrganizationAfterUpdateHooks []GroupOrganizationHook +var groupOrganizationBeforeDeleteMu sync.Mutex var groupOrganizationBeforeDeleteHooks []GroupOrganizationHook +var groupOrganizationAfterDeleteMu sync.Mutex var groupOrganizationAfterDeleteHooks []GroupOrganizationHook +var groupOrganizationBeforeUpsertMu sync.Mutex var groupOrganizationBeforeUpsertHooks []GroupOrganizationHook +var groupOrganizationAfterUpsertMu sync.Mutex var groupOrganizationAfterUpsertHooks []GroupOrganizationHook // doAfterSelectHooks executes all "after Select" hooks. @@ -308,23 +317,41 @@ func (o *GroupOrganization) doAfterUpsertHooks(ctx context.Context, exec boil.Co func AddGroupOrganizationHook(hookPoint boil.HookPoint, groupOrganizationHook GroupOrganizationHook) { switch hookPoint { case boil.AfterSelectHook: + groupOrganizationAfterSelectMu.Lock() groupOrganizationAfterSelectHooks = append(groupOrganizationAfterSelectHooks, groupOrganizationHook) + groupOrganizationAfterSelectMu.Unlock() case boil.BeforeInsertHook: + groupOrganizationBeforeInsertMu.Lock() groupOrganizationBeforeInsertHooks = append(groupOrganizationBeforeInsertHooks, groupOrganizationHook) + groupOrganizationBeforeInsertMu.Unlock() case boil.AfterInsertHook: + groupOrganizationAfterInsertMu.Lock() groupOrganizationAfterInsertHooks = append(groupOrganizationAfterInsertHooks, groupOrganizationHook) + groupOrganizationAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + groupOrganizationBeforeUpdateMu.Lock() groupOrganizationBeforeUpdateHooks = append(groupOrganizationBeforeUpdateHooks, groupOrganizationHook) + groupOrganizationBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + groupOrganizationAfterUpdateMu.Lock() groupOrganizationAfterUpdateHooks = append(groupOrganizationAfterUpdateHooks, groupOrganizationHook) + groupOrganizationAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + groupOrganizationBeforeDeleteMu.Lock() groupOrganizationBeforeDeleteHooks = append(groupOrganizationBeforeDeleteHooks, groupOrganizationHook) + groupOrganizationBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + groupOrganizationAfterDeleteMu.Lock() groupOrganizationAfterDeleteHooks = append(groupOrganizationAfterDeleteHooks, groupOrganizationHook) + groupOrganizationAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + groupOrganizationBeforeUpsertMu.Lock() groupOrganizationBeforeUpsertHooks = append(groupOrganizationBeforeUpsertHooks, groupOrganizationHook) + groupOrganizationBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + groupOrganizationAfterUpsertMu.Lock() groupOrganizationAfterUpsertHooks = append(groupOrganizationAfterUpsertHooks, groupOrganizationHook) + groupOrganizationAfterUpsertMu.Unlock() } } @@ -450,27 +477,20 @@ func (groupOrganizationL) LoadOrganization(ctx context.Context, e boil.ContextEx } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupOrganizationR{} } - args = append(args, object.OrganizationID) + args[object.OrganizationID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupOrganizationR{} } - for _, a := range args { - if a == obj.OrganizationID { - continue Outer - } - } - - args = append(args, obj.OrganizationID) + args[obj.OrganizationID] = struct{}{} } } @@ -479,9 +499,16 @@ func (groupOrganizationL) LoadOrganization(ctx context.Context, e boil.ContextEx return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`organizations`), - qm.WhereIn(`organizations.id in ?`, args...), + qm.WhereIn(`organizations.id in ?`, argsSlice...), qmhelper.WhereIsNull(`organizations.deleted_at`), ) if mods != nil { @@ -571,27 +598,20 @@ func (groupOrganizationL) LoadGroup(ctx context.Context, e boil.ContextExecutor, } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupOrganizationR{} } - args = append(args, object.GroupID) + args[object.GroupID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupOrganizationR{} } - for _, a := range args { - if a == obj.GroupID { - continue Outer - } - } - - args = append(args, obj.GroupID) + args[obj.GroupID] = struct{}{} } } @@ -600,9 +620,16 @@ func (groupOrganizationL) LoadGroup(ctx context.Context, e boil.ContextExecutor, return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`groups`), - qm.WhereIn(`groups.id in ?`, args...), + qm.WhereIn(`groups.id in ?`, argsSlice...), qmhelper.WhereIsNull(`groups.deleted_at`), ) if mods != nil { diff --git a/internal/models/groups.go b/internal/models/groups.go index c17b245..c476872 100644 --- a/internal/models/groups.go +++ b/internal/models/groups.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -24,83 +24,91 @@ import ( // Group is an object representing the database table. type Group struct { - ID string `boil:"id" json:"id" toml:"id" yaml:"id"` - Name string `boil:"name" json:"name" toml:"name" yaml:"name"` - Slug string `boil:"slug" json:"slug" toml:"slug" yaml:"slug"` - Description string `boil:"description" json:"description" toml:"description" yaml:"description"` - CreatedAt time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"` - UpdatedAt time.Time `boil:"updated_at" json:"updated_at" toml:"updated_at" yaml:"updated_at"` - DeletedAt null.Time `boil:"deleted_at" json:"deleted_at,omitempty" toml:"deleted_at" yaml:"deleted_at,omitempty"` - Note string `boil:"note" json:"note" toml:"note" yaml:"note"` + ID string `boil:"id" json:"id" toml:"id" yaml:"id"` + Name string `boil:"name" json:"name" toml:"name" yaml:"name"` + Slug string `boil:"slug" json:"slug" toml:"slug" yaml:"slug"` + Description string `boil:"description" json:"description" toml:"description" yaml:"description"` + CreatedAt time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"` + UpdatedAt time.Time `boil:"updated_at" json:"updated_at" toml:"updated_at" yaml:"updated_at"` + DeletedAt null.Time `boil:"deleted_at" json:"deleted_at,omitempty" toml:"deleted_at" yaml:"deleted_at,omitempty"` + Note string `boil:"note" json:"note" toml:"note" yaml:"note"` + ApproverGroup null.String `boil:"approver_group" json:"approver_group,omitempty" toml:"approver_group" yaml:"approver_group,omitempty"` R *groupR `boil:"-" json:"-" toml:"-" yaml:"-"` L groupL `boil:"-" json:"-" toml:"-" yaml:"-"` } var GroupColumns = struct { - ID string - Name string - Slug string - Description string - CreatedAt string - UpdatedAt string - DeletedAt string - Note string + ID string + Name string + Slug string + Description string + CreatedAt string + UpdatedAt string + DeletedAt string + Note string + ApproverGroup string }{ - ID: "id", - Name: "name", - Slug: "slug", - Description: "description", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", - Note: "note", + ID: "id", + Name: "name", + Slug: "slug", + Description: "description", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", + Note: "note", + ApproverGroup: "approver_group", } var GroupTableColumns = struct { - ID string - Name string - Slug string - Description string - CreatedAt string - UpdatedAt string - DeletedAt string - Note string + ID string + Name string + Slug string + Description string + CreatedAt string + UpdatedAt string + DeletedAt string + Note string + ApproverGroup string }{ - ID: "groups.id", - Name: "groups.name", - Slug: "groups.slug", - Description: "groups.description", - CreatedAt: "groups.created_at", - UpdatedAt: "groups.updated_at", - DeletedAt: "groups.deleted_at", - Note: "groups.note", + ID: "groups.id", + Name: "groups.name", + Slug: "groups.slug", + Description: "groups.description", + CreatedAt: "groups.created_at", + UpdatedAt: "groups.updated_at", + DeletedAt: "groups.deleted_at", + Note: "groups.note", + ApproverGroup: "groups.approver_group", } // Generated where var GroupWhere = struct { - ID whereHelperstring - Name whereHelperstring - Slug whereHelperstring - Description whereHelperstring - CreatedAt whereHelpertime_Time - UpdatedAt whereHelpertime_Time - DeletedAt whereHelpernull_Time - Note whereHelperstring + ID whereHelperstring + Name whereHelperstring + Slug whereHelperstring + Description whereHelperstring + CreatedAt whereHelpertime_Time + UpdatedAt whereHelpertime_Time + DeletedAt whereHelpernull_Time + Note whereHelperstring + ApproverGroup whereHelpernull_String }{ - ID: whereHelperstring{field: "\"groups\".\"id\""}, - Name: whereHelperstring{field: "\"groups\".\"name\""}, - Slug: whereHelperstring{field: "\"groups\".\"slug\""}, - Description: whereHelperstring{field: "\"groups\".\"description\""}, - CreatedAt: whereHelpertime_Time{field: "\"groups\".\"created_at\""}, - UpdatedAt: whereHelpertime_Time{field: "\"groups\".\"updated_at\""}, - DeletedAt: whereHelpernull_Time{field: "\"groups\".\"deleted_at\""}, - Note: whereHelperstring{field: "\"groups\".\"note\""}, + ID: whereHelperstring{field: "\"groups\".\"id\""}, + Name: whereHelperstring{field: "\"groups\".\"name\""}, + Slug: whereHelperstring{field: "\"groups\".\"slug\""}, + Description: whereHelperstring{field: "\"groups\".\"description\""}, + CreatedAt: whereHelpertime_Time{field: "\"groups\".\"created_at\""}, + UpdatedAt: whereHelpertime_Time{field: "\"groups\".\"updated_at\""}, + DeletedAt: whereHelpernull_Time{field: "\"groups\".\"deleted_at\""}, + Note: whereHelperstring{field: "\"groups\".\"note\""}, + ApproverGroup: whereHelpernull_String{field: "\"groups\".\"approver_group\""}, } // GroupRels is where relationship names are stored. var GroupRels = struct { + ApproverGroupGroup string ApproverGroupApplications string SubjectGroupAuditEvents string GroupApplicationRequests string @@ -111,7 +119,9 @@ var GroupRels = struct { GroupMembershipRequests string GroupMemberships string GroupOrganizations string + ApproverGroupGroups string }{ + ApproverGroupGroup: "ApproverGroupGroup", ApproverGroupApplications: "ApproverGroupApplications", SubjectGroupAuditEvents: "SubjectGroupAuditEvents", GroupApplicationRequests: "GroupApplicationRequests", @@ -122,10 +132,12 @@ var GroupRels = struct { GroupMembershipRequests: "GroupMembershipRequests", GroupMemberships: "GroupMemberships", GroupOrganizations: "GroupOrganizations", + ApproverGroupGroups: "ApproverGroupGroups", } // groupR is where relationships are stored. type groupR struct { + ApproverGroupGroup *Group `boil:"ApproverGroupGroup" json:"ApproverGroupGroup" toml:"ApproverGroupGroup" yaml:"ApproverGroupGroup"` ApproverGroupApplications ApplicationSlice `boil:"ApproverGroupApplications" json:"ApproverGroupApplications" toml:"ApproverGroupApplications" yaml:"ApproverGroupApplications"` SubjectGroupAuditEvents AuditEventSlice `boil:"SubjectGroupAuditEvents" json:"SubjectGroupAuditEvents" toml:"SubjectGroupAuditEvents" yaml:"SubjectGroupAuditEvents"` GroupApplicationRequests GroupApplicationRequestSlice `boil:"GroupApplicationRequests" json:"GroupApplicationRequests" toml:"GroupApplicationRequests" yaml:"GroupApplicationRequests"` @@ -136,6 +148,7 @@ type groupR struct { GroupMembershipRequests GroupMembershipRequestSlice `boil:"GroupMembershipRequests" json:"GroupMembershipRequests" toml:"GroupMembershipRequests" yaml:"GroupMembershipRequests"` GroupMemberships GroupMembershipSlice `boil:"GroupMemberships" json:"GroupMemberships" toml:"GroupMemberships" yaml:"GroupMemberships"` GroupOrganizations GroupOrganizationSlice `boil:"GroupOrganizations" json:"GroupOrganizations" toml:"GroupOrganizations" yaml:"GroupOrganizations"` + ApproverGroupGroups GroupSlice `boil:"ApproverGroupGroups" json:"ApproverGroupGroups" toml:"ApproverGroupGroups" yaml:"ApproverGroupGroups"` } // NewStruct creates a new relationship struct @@ -143,6 +156,13 @@ func (*groupR) NewStruct() *groupR { return &groupR{} } +func (r *groupR) GetApproverGroupGroup() *Group { + if r == nil { + return nil + } + return r.ApproverGroupGroup +} + func (r *groupR) GetApproverGroupApplications() ApplicationSlice { if r == nil { return nil @@ -213,13 +233,20 @@ func (r *groupR) GetGroupOrganizations() GroupOrganizationSlice { return r.GroupOrganizations } +func (r *groupR) GetApproverGroupGroups() GroupSlice { + if r == nil { + return nil + } + return r.ApproverGroupGroups +} + // groupL is where Load methods for each relationship are stored. type groupL struct{} var ( - groupAllColumns = []string{"id", "name", "slug", "description", "created_at", "updated_at", "deleted_at", "note"} + groupAllColumns = []string{"id", "name", "slug", "description", "created_at", "updated_at", "deleted_at", "note", "approver_group"} groupColumnsWithoutDefault = []string{"name", "slug", "description", "created_at", "updated_at"} - groupColumnsWithDefault = []string{"id", "deleted_at", "note"} + groupColumnsWithDefault = []string{"id", "deleted_at", "note", "approver_group"} groupPrimaryKeyColumns = []string{"id"} groupGeneratedColumns = []string{} ) @@ -257,18 +284,27 @@ var ( _ = qmhelper.Where ) +var groupAfterSelectMu sync.Mutex var groupAfterSelectHooks []GroupHook +var groupBeforeInsertMu sync.Mutex var groupBeforeInsertHooks []GroupHook +var groupAfterInsertMu sync.Mutex var groupAfterInsertHooks []GroupHook +var groupBeforeUpdateMu sync.Mutex var groupBeforeUpdateHooks []GroupHook +var groupAfterUpdateMu sync.Mutex var groupAfterUpdateHooks []GroupHook +var groupBeforeDeleteMu sync.Mutex var groupBeforeDeleteHooks []GroupHook +var groupAfterDeleteMu sync.Mutex var groupAfterDeleteHooks []GroupHook +var groupBeforeUpsertMu sync.Mutex var groupBeforeUpsertHooks []GroupHook +var groupAfterUpsertMu sync.Mutex var groupAfterUpsertHooks []GroupHook // doAfterSelectHooks executes all "after Select" hooks. @@ -410,23 +446,41 @@ func (o *Group) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecuto func AddGroupHook(hookPoint boil.HookPoint, groupHook GroupHook) { switch hookPoint { case boil.AfterSelectHook: + groupAfterSelectMu.Lock() groupAfterSelectHooks = append(groupAfterSelectHooks, groupHook) + groupAfterSelectMu.Unlock() case boil.BeforeInsertHook: + groupBeforeInsertMu.Lock() groupBeforeInsertHooks = append(groupBeforeInsertHooks, groupHook) + groupBeforeInsertMu.Unlock() case boil.AfterInsertHook: + groupAfterInsertMu.Lock() groupAfterInsertHooks = append(groupAfterInsertHooks, groupHook) + groupAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + groupBeforeUpdateMu.Lock() groupBeforeUpdateHooks = append(groupBeforeUpdateHooks, groupHook) + groupBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + groupAfterUpdateMu.Lock() groupAfterUpdateHooks = append(groupAfterUpdateHooks, groupHook) + groupAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + groupBeforeDeleteMu.Lock() groupBeforeDeleteHooks = append(groupBeforeDeleteHooks, groupHook) + groupBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + groupAfterDeleteMu.Lock() groupAfterDeleteHooks = append(groupAfterDeleteHooks, groupHook) + groupAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + groupBeforeUpsertMu.Lock() groupBeforeUpsertHooks = append(groupBeforeUpsertHooks, groupHook) + groupBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + groupAfterUpsertMu.Lock() groupAfterUpsertHooks = append(groupAfterUpsertHooks, groupHook) + groupAfterUpsertMu.Unlock() } } @@ -502,6 +556,17 @@ func (q groupQuery) Exists(ctx context.Context, exec boil.ContextExecutor) (bool return count > 0, nil } +// ApproverGroupGroup pointed to by the foreign key. +func (o *Group) ApproverGroupGroup(mods ...qm.QueryMod) groupQuery { + queryMods := []qm.QueryMod{ + qm.Where("\"id\" = ?", o.ApproverGroup), + } + + queryMods = append(queryMods, mods...) + + return Groups(queryMods...) +} + // ApproverGroupApplications retrieves all the application's Applications with an executor via approver_group_id column. func (o *Group) ApproverGroupApplications(mods ...qm.QueryMod) applicationQuery { var queryMods []qm.QueryMod @@ -642,9 +707,23 @@ func (o *Group) GroupOrganizations(mods ...qm.QueryMod) groupOrganizationQuery { return GroupOrganizations(queryMods...) } -// LoadApproverGroupApplications allows an eager lookup of values, cached into the -// loaded structs of the objects. This is for a 1-M or N-M relationship. -func (groupL) LoadApproverGroupApplications(ctx context.Context, e boil.ContextExecutor, singular bool, maybeGroup interface{}, mods queries.Applicator) error { +// ApproverGroupGroups retrieves all the group's Groups with an executor via approver_group column. +func (o *Group) ApproverGroupGroups(mods ...qm.QueryMod) groupQuery { + var queryMods []qm.QueryMod + if len(mods) != 0 { + queryMods = append(queryMods, mods...) + } + + queryMods = append(queryMods, + qm.Where("\"groups\".\"approver_group\"=?", o.ID), + ) + + return Groups(queryMods...) +} + +// LoadApproverGroupGroup allows an eager lookup of values, cached into the +// loaded structs of the objects. This is for an N-1 relationship. +func (groupL) LoadApproverGroupGroup(ctx context.Context, e boil.ContextExecutor, singular bool, maybeGroup interface{}, mods queries.Applicator) error { var slice []*Group var object *Group @@ -670,26 +749,143 @@ func (groupL) LoadApproverGroupApplications(ctx context.Context, e boil.ContextE } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + if !queries.IsNil(object.ApproverGroup) { + args[object.ApproverGroup] = struct{}{} + } + } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer + if !queries.IsNil(obj.ApproverGroup) { + args[obj.ApproverGroup] = struct{}{} + } + + } + } + + if len(args) == 0 { + return nil + } + + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + + query := NewQuery( + qm.From(`groups`), + qm.WhereIn(`groups.id in ?`, argsSlice...), + qmhelper.WhereIsNull(`groups.deleted_at`), + ) + if mods != nil { + mods.Apply(query) + } + + results, err := query.QueryContext(ctx, e) + if err != nil { + return errors.Wrap(err, "failed to eager load Group") + } + + var resultSlice []*Group + if err = queries.Bind(results, &resultSlice); err != nil { + return errors.Wrap(err, "failed to bind eager loaded slice Group") + } + + if err = results.Close(); err != nil { + return errors.Wrap(err, "failed to close results of eager load for groups") + } + if err = results.Err(); err != nil { + return errors.Wrap(err, "error occurred during iteration of eager loaded relations for groups") + } + + if len(groupAfterSelectHooks) != 0 { + for _, obj := range resultSlice { + if err := obj.doAfterSelectHooks(ctx, e); err != nil { + return err + } + } + } + + if len(resultSlice) == 0 { + return nil + } + + if singular { + foreign := resultSlice[0] + object.R.ApproverGroupGroup = foreign + if foreign.R == nil { + foreign.R = &groupR{} + } + foreign.R.ApproverGroupGroups = append(foreign.R.ApproverGroupGroups, object) + return nil + } + + for _, local := range slice { + for _, foreign := range resultSlice { + if queries.Equal(local.ApproverGroup, foreign.ID) { + local.R.ApproverGroupGroup = foreign + if foreign.R == nil { + foreign.R = &groupR{} } + foreign.R.ApproverGroupGroups = append(foreign.R.ApproverGroupGroups, local) + break } + } + } - args = append(args, obj.ID) + return nil +} + +// LoadApproverGroupApplications allows an eager lookup of values, cached into the +// loaded structs of the objects. This is for a 1-M or N-M relationship. +func (groupL) LoadApproverGroupApplications(ctx context.Context, e boil.ContextExecutor, singular bool, maybeGroup interface{}, mods queries.Applicator) error { + var slice []*Group + var object *Group + + if singular { + var ok bool + object, ok = maybeGroup.(*Group) + if !ok { + object = new(Group) + ok = queries.SetFromEmbeddedStruct(&object, &maybeGroup) + if !ok { + return errors.New(fmt.Sprintf("failed to set %T from embedded struct %T", object, maybeGroup)) + } + } + } else { + s, ok := maybeGroup.(*[]*Group) + if ok { + slice = *s + } else { + ok = queries.SetFromEmbeddedStruct(&slice, maybeGroup) + if !ok { + return errors.New(fmt.Sprintf("failed to set %T from embedded struct %T", slice, maybeGroup)) + } + } + } + + args := make(map[interface{}]struct{}) + if singular { + if object.R == nil { + object.R = &groupR{} + } + args[object.ID] = struct{}{} + } else { + for _, obj := range slice { + if obj.R == nil { + obj.R = &groupR{} + } + args[obj.ID] = struct{}{} } } @@ -697,9 +893,16 @@ func (groupL) LoadApproverGroupApplications(ctx context.Context, e boil.ContextE return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`applications`), - qm.WhereIn(`applications.approver_group_id in ?`, args...), + qm.WhereIn(`applications.approver_group_id in ?`, argsSlice...), qmhelper.WhereIsNull(`applications.deleted_at`), ) if mods != nil { @@ -785,26 +988,18 @@ func (groupL) LoadSubjectGroupAuditEvents(ctx context.Context, e boil.ContextExe } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -812,9 +1007,16 @@ func (groupL) LoadSubjectGroupAuditEvents(ctx context.Context, e boil.ContextExe return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`audit_events`), - qm.WhereIn(`audit_events.subject_group_id in ?`, args...), + qm.WhereIn(`audit_events.subject_group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -899,26 +1101,18 @@ func (groupL) LoadGroupApplicationRequests(ctx context.Context, e boil.ContextEx } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -926,9 +1120,16 @@ func (groupL) LoadGroupApplicationRequests(ctx context.Context, e boil.ContextEx return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_application_requests`), - qm.WhereIn(`group_application_requests.group_id in ?`, args...), + qm.WhereIn(`group_application_requests.group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1013,26 +1214,18 @@ func (groupL) LoadApproverGroupGroupApplicationRequests(ctx context.Context, e b } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1040,9 +1233,16 @@ func (groupL) LoadApproverGroupGroupApplicationRequests(ctx context.Context, e b return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_application_requests`), - qm.WhereIn(`group_application_requests.approver_group_id in ?`, args...), + qm.WhereIn(`group_application_requests.approver_group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1127,26 +1327,18 @@ func (groupL) LoadGroupApplications(ctx context.Context, e boil.ContextExecutor, } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1154,9 +1346,16 @@ func (groupL) LoadGroupApplications(ctx context.Context, e boil.ContextExecutor, return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_applications`), - qm.WhereIn(`group_applications.group_id in ?`, args...), + qm.WhereIn(`group_applications.group_id in ?`, argsSlice...), qmhelper.WhereIsNull(`group_applications.deleted_at`), ) if mods != nil { @@ -1242,26 +1441,18 @@ func (groupL) LoadParentGroupGroupHierarchies(ctx context.Context, e boil.Contex } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1269,9 +1460,16 @@ func (groupL) LoadParentGroupGroupHierarchies(ctx context.Context, e boil.Contex return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_hierarchies`), - qm.WhereIn(`group_hierarchies.parent_group_id in ?`, args...), + qm.WhereIn(`group_hierarchies.parent_group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1356,26 +1554,18 @@ func (groupL) LoadMemberGroupGroupHierarchies(ctx context.Context, e boil.Contex } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1383,9 +1573,16 @@ func (groupL) LoadMemberGroupGroupHierarchies(ctx context.Context, e boil.Contex return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_hierarchies`), - qm.WhereIn(`group_hierarchies.member_group_id in ?`, args...), + qm.WhereIn(`group_hierarchies.member_group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1470,26 +1667,18 @@ func (groupL) LoadGroupMembershipRequests(ctx context.Context, e boil.ContextExe } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1497,9 +1686,16 @@ func (groupL) LoadGroupMembershipRequests(ctx context.Context, e boil.ContextExe return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_membership_requests`), - qm.WhereIn(`group_membership_requests.group_id in ?`, args...), + qm.WhereIn(`group_membership_requests.group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1584,26 +1780,18 @@ func (groupL) LoadGroupMemberships(ctx context.Context, e boil.ContextExecutor, } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1611,9 +1799,16 @@ func (groupL) LoadGroupMemberships(ctx context.Context, e boil.ContextExecutor, return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_memberships`), - qm.WhereIn(`group_memberships.group_id in ?`, args...), + qm.WhereIn(`group_memberships.group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1698,26 +1893,18 @@ func (groupL) LoadGroupOrganizations(ctx context.Context, e boil.ContextExecutor } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &groupR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &groupR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1725,9 +1912,16 @@ func (groupL) LoadGroupOrganizations(ctx context.Context, e boil.ContextExecutor return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_organizations`), - qm.WhereIn(`group_organizations.group_id in ?`, args...), + qm.WhereIn(`group_organizations.group_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1784,6 +1978,200 @@ func (groupL) LoadGroupOrganizations(ctx context.Context, e boil.ContextExecutor return nil } +// LoadApproverGroupGroups allows an eager lookup of values, cached into the +// loaded structs of the objects. This is for a 1-M or N-M relationship. +func (groupL) LoadApproverGroupGroups(ctx context.Context, e boil.ContextExecutor, singular bool, maybeGroup interface{}, mods queries.Applicator) error { + var slice []*Group + var object *Group + + if singular { + var ok bool + object, ok = maybeGroup.(*Group) + if !ok { + object = new(Group) + ok = queries.SetFromEmbeddedStruct(&object, &maybeGroup) + if !ok { + return errors.New(fmt.Sprintf("failed to set %T from embedded struct %T", object, maybeGroup)) + } + } + } else { + s, ok := maybeGroup.(*[]*Group) + if ok { + slice = *s + } else { + ok = queries.SetFromEmbeddedStruct(&slice, maybeGroup) + if !ok { + return errors.New(fmt.Sprintf("failed to set %T from embedded struct %T", slice, maybeGroup)) + } + } + } + + args := make(map[interface{}]struct{}) + if singular { + if object.R == nil { + object.R = &groupR{} + } + args[object.ID] = struct{}{} + } else { + for _, obj := range slice { + if obj.R == nil { + obj.R = &groupR{} + } + args[obj.ID] = struct{}{} + } + } + + if len(args) == 0 { + return nil + } + + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + + query := NewQuery( + qm.From(`groups`), + qm.WhereIn(`groups.approver_group in ?`, argsSlice...), + qmhelper.WhereIsNull(`groups.deleted_at`), + ) + if mods != nil { + mods.Apply(query) + } + + results, err := query.QueryContext(ctx, e) + if err != nil { + return errors.Wrap(err, "failed to eager load groups") + } + + var resultSlice []*Group + if err = queries.Bind(results, &resultSlice); err != nil { + return errors.Wrap(err, "failed to bind eager loaded slice groups") + } + + if err = results.Close(); err != nil { + return errors.Wrap(err, "failed to close results in eager load on groups") + } + if err = results.Err(); err != nil { + return errors.Wrap(err, "error occurred during iteration of eager loaded relations for groups") + } + + if len(groupAfterSelectHooks) != 0 { + for _, obj := range resultSlice { + if err := obj.doAfterSelectHooks(ctx, e); err != nil { + return err + } + } + } + if singular { + object.R.ApproverGroupGroups = resultSlice + for _, foreign := range resultSlice { + if foreign.R == nil { + foreign.R = &groupR{} + } + foreign.R.ApproverGroupGroup = object + } + return nil + } + + for _, foreign := range resultSlice { + for _, local := range slice { + if queries.Equal(local.ID, foreign.ApproverGroup) { + local.R.ApproverGroupGroups = append(local.R.ApproverGroupGroups, foreign) + if foreign.R == nil { + foreign.R = &groupR{} + } + foreign.R.ApproverGroupGroup = local + break + } + } + } + + return nil +} + +// SetApproverGroupGroup of the group to the related item. +// Sets o.R.ApproverGroupGroup to related. +// Adds o to related.R.ApproverGroupGroups. +func (o *Group) SetApproverGroupGroup(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Group) error { + var err error + if insert { + if err = related.Insert(ctx, exec, boil.Infer()); err != nil { + return errors.Wrap(err, "failed to insert into foreign table") + } + } + + updateQuery := fmt.Sprintf( + "UPDATE \"groups\" SET %s WHERE %s", + strmangle.SetParamNames("\"", "\"", 1, []string{"approver_group"}), + strmangle.WhereClause("\"", "\"", 2, groupPrimaryKeyColumns), + ) + values := []interface{}{related.ID, o.ID} + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, updateQuery) + fmt.Fprintln(writer, values) + } + if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil { + return errors.Wrap(err, "failed to update local table") + } + + queries.Assign(&o.ApproverGroup, related.ID) + if o.R == nil { + o.R = &groupR{ + ApproverGroupGroup: related, + } + } else { + o.R.ApproverGroupGroup = related + } + + if related.R == nil { + related.R = &groupR{ + ApproverGroupGroups: GroupSlice{o}, + } + } else { + related.R.ApproverGroupGroups = append(related.R.ApproverGroupGroups, o) + } + + return nil +} + +// RemoveApproverGroupGroup relationship. +// Sets o.R.ApproverGroupGroup to nil. +// Removes o from all passed in related items' relationships struct. +func (o *Group) RemoveApproverGroupGroup(ctx context.Context, exec boil.ContextExecutor, related *Group) error { + var err error + + queries.SetScanner(&o.ApproverGroup, nil) + if _, err = o.Update(ctx, exec, boil.Whitelist("approver_group")); err != nil { + return errors.Wrap(err, "failed to update local table") + } + + if o.R != nil { + o.R.ApproverGroupGroup = nil + } + if related == nil || related.R == nil { + return nil + } + + for i, ri := range related.R.ApproverGroupGroups { + if queries.Equal(o.ApproverGroup, ri.ApproverGroup) { + continue + } + + ln := len(related.R.ApproverGroupGroups) + if ln > 1 && i < ln-1 { + related.R.ApproverGroupGroups[i] = related.R.ApproverGroupGroups[ln-1] + } + related.R.ApproverGroupGroups = related.R.ApproverGroupGroups[:ln-1] + break + } + return nil +} + // AddApproverGroupApplications adds the given related objects to the existing relationships // of the group, optionally inserting them as new records. // Appends related to o.R.ApproverGroupApplications. @@ -2462,6 +2850,133 @@ func (o *Group) AddGroupOrganizations(ctx context.Context, exec boil.ContextExec return nil } +// AddApproverGroupGroups adds the given related objects to the existing relationships +// of the group, optionally inserting them as new records. +// Appends related to o.R.ApproverGroupGroups. +// Sets related.R.ApproverGroupGroup appropriately. +func (o *Group) AddApproverGroupGroups(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Group) error { + var err error + for _, rel := range related { + if insert { + queries.Assign(&rel.ApproverGroup, o.ID) + if err = rel.Insert(ctx, exec, boil.Infer()); err != nil { + return errors.Wrap(err, "failed to insert into foreign table") + } + } else { + updateQuery := fmt.Sprintf( + "UPDATE \"groups\" SET %s WHERE %s", + strmangle.SetParamNames("\"", "\"", 1, []string{"approver_group"}), + strmangle.WhereClause("\"", "\"", 2, groupPrimaryKeyColumns), + ) + values := []interface{}{o.ID, rel.ID} + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, updateQuery) + fmt.Fprintln(writer, values) + } + if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil { + return errors.Wrap(err, "failed to update foreign table") + } + + queries.Assign(&rel.ApproverGroup, o.ID) + } + } + + if o.R == nil { + o.R = &groupR{ + ApproverGroupGroups: related, + } + } else { + o.R.ApproverGroupGroups = append(o.R.ApproverGroupGroups, related...) + } + + for _, rel := range related { + if rel.R == nil { + rel.R = &groupR{ + ApproverGroupGroup: o, + } + } else { + rel.R.ApproverGroupGroup = o + } + } + return nil +} + +// SetApproverGroupGroups removes all previously related items of the +// group replacing them completely with the passed +// in related items, optionally inserting them as new records. +// Sets o.R.ApproverGroupGroup's ApproverGroupGroups accordingly. +// Replaces o.R.ApproverGroupGroups with related. +// Sets related.R.ApproverGroupGroup's ApproverGroupGroups accordingly. +func (o *Group) SetApproverGroupGroups(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Group) error { + query := "update \"groups\" set \"approver_group\" = null where \"approver_group\" = $1" + values := []interface{}{o.ID} + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, query) + fmt.Fprintln(writer, values) + } + _, err := exec.ExecContext(ctx, query, values...) + if err != nil { + return errors.Wrap(err, "failed to remove relationships before set") + } + + if o.R != nil { + for _, rel := range o.R.ApproverGroupGroups { + queries.SetScanner(&rel.ApproverGroup, nil) + if rel.R == nil { + continue + } + + rel.R.ApproverGroupGroup = nil + } + o.R.ApproverGroupGroups = nil + } + + return o.AddApproverGroupGroups(ctx, exec, insert, related...) +} + +// RemoveApproverGroupGroups relationships from objects passed in. +// Removes related items from R.ApproverGroupGroups (uses pointer comparison, removal does not keep order) +// Sets related.R.ApproverGroupGroup. +func (o *Group) RemoveApproverGroupGroups(ctx context.Context, exec boil.ContextExecutor, related ...*Group) error { + if len(related) == 0 { + return nil + } + + var err error + for _, rel := range related { + queries.SetScanner(&rel.ApproverGroup, nil) + if rel.R != nil { + rel.R.ApproverGroupGroup = nil + } + if _, err = rel.Update(ctx, exec, boil.Whitelist("approver_group")); err != nil { + return err + } + } + if o.R == nil { + return nil + } + + for _, rel := range related { + for i, ri := range o.R.ApproverGroupGroups { + if rel != ri { + continue + } + + ln := len(o.R.ApproverGroupGroups) + if ln > 1 && i < ln-1 { + o.R.ApproverGroupGroups[i] = o.R.ApproverGroupGroups[ln-1] + } + o.R.ApproverGroupGroups = o.R.ApproverGroupGroups[:ln-1] + break + } + } + + return nil +} + // Groups retrieves all the records using an executor. func Groups(mods ...qm.QueryMod) groupQuery { mods = append(mods, qm.From("\"groups\""), qmhelper.WhereIsNull("\"groups\".\"deleted_at\"")) diff --git a/internal/models/notification_preferences.go b/internal/models/notification_preferences.go index 0fddadf..27e3f36 100644 --- a/internal/models/notification_preferences.go +++ b/internal/models/notification_preferences.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -173,18 +173,27 @@ var ( _ = qmhelper.Where ) +var notificationPreferenceAfterSelectMu sync.Mutex var notificationPreferenceAfterSelectHooks []NotificationPreferenceHook +var notificationPreferenceBeforeInsertMu sync.Mutex var notificationPreferenceBeforeInsertHooks []NotificationPreferenceHook +var notificationPreferenceAfterInsertMu sync.Mutex var notificationPreferenceAfterInsertHooks []NotificationPreferenceHook +var notificationPreferenceBeforeUpdateMu sync.Mutex var notificationPreferenceBeforeUpdateHooks []NotificationPreferenceHook +var notificationPreferenceAfterUpdateMu sync.Mutex var notificationPreferenceAfterUpdateHooks []NotificationPreferenceHook +var notificationPreferenceBeforeDeleteMu sync.Mutex var notificationPreferenceBeforeDeleteHooks []NotificationPreferenceHook +var notificationPreferenceAfterDeleteMu sync.Mutex var notificationPreferenceAfterDeleteHooks []NotificationPreferenceHook +var notificationPreferenceBeforeUpsertMu sync.Mutex var notificationPreferenceBeforeUpsertHooks []NotificationPreferenceHook +var notificationPreferenceAfterUpsertMu sync.Mutex var notificationPreferenceAfterUpsertHooks []NotificationPreferenceHook // doAfterSelectHooks executes all "after Select" hooks. @@ -326,23 +335,41 @@ func (o *NotificationPreference) doAfterUpsertHooks(ctx context.Context, exec bo func AddNotificationPreferenceHook(hookPoint boil.HookPoint, notificationPreferenceHook NotificationPreferenceHook) { switch hookPoint { case boil.AfterSelectHook: + notificationPreferenceAfterSelectMu.Lock() notificationPreferenceAfterSelectHooks = append(notificationPreferenceAfterSelectHooks, notificationPreferenceHook) + notificationPreferenceAfterSelectMu.Unlock() case boil.BeforeInsertHook: + notificationPreferenceBeforeInsertMu.Lock() notificationPreferenceBeforeInsertHooks = append(notificationPreferenceBeforeInsertHooks, notificationPreferenceHook) + notificationPreferenceBeforeInsertMu.Unlock() case boil.AfterInsertHook: + notificationPreferenceAfterInsertMu.Lock() notificationPreferenceAfterInsertHooks = append(notificationPreferenceAfterInsertHooks, notificationPreferenceHook) + notificationPreferenceAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + notificationPreferenceBeforeUpdateMu.Lock() notificationPreferenceBeforeUpdateHooks = append(notificationPreferenceBeforeUpdateHooks, notificationPreferenceHook) + notificationPreferenceBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + notificationPreferenceAfterUpdateMu.Lock() notificationPreferenceAfterUpdateHooks = append(notificationPreferenceAfterUpdateHooks, notificationPreferenceHook) + notificationPreferenceAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + notificationPreferenceBeforeDeleteMu.Lock() notificationPreferenceBeforeDeleteHooks = append(notificationPreferenceBeforeDeleteHooks, notificationPreferenceHook) + notificationPreferenceBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + notificationPreferenceAfterDeleteMu.Lock() notificationPreferenceAfterDeleteHooks = append(notificationPreferenceAfterDeleteHooks, notificationPreferenceHook) + notificationPreferenceAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + notificationPreferenceBeforeUpsertMu.Lock() notificationPreferenceBeforeUpsertHooks = append(notificationPreferenceBeforeUpsertHooks, notificationPreferenceHook) + notificationPreferenceBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + notificationPreferenceAfterUpsertMu.Lock() notificationPreferenceAfterUpsertHooks = append(notificationPreferenceAfterUpsertHooks, notificationPreferenceHook) + notificationPreferenceAfterUpsertMu.Unlock() } } @@ -479,27 +506,20 @@ func (notificationPreferenceL) LoadUser(ctx context.Context, e boil.ContextExecu } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = ¬ificationPreferenceR{} } - args = append(args, object.UserID) + args[object.UserID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = ¬ificationPreferenceR{} } - for _, a := range args { - if a == obj.UserID { - continue Outer - } - } - - args = append(args, obj.UserID) + args[obj.UserID] = struct{}{} } } @@ -508,9 +528,16 @@ func (notificationPreferenceL) LoadUser(ctx context.Context, e boil.ContextExecu return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`users`), - qm.WhereIn(`users.id in ?`, args...), + qm.WhereIn(`users.id in ?`, argsSlice...), qmhelper.WhereIsNull(`users.deleted_at`), ) if mods != nil { @@ -600,27 +627,20 @@ func (notificationPreferenceL) LoadNotificationType(ctx context.Context, e boil. } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = ¬ificationPreferenceR{} } - args = append(args, object.NotificationTypeID) + args[object.NotificationTypeID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = ¬ificationPreferenceR{} } - for _, a := range args { - if a == obj.NotificationTypeID { - continue Outer - } - } - - args = append(args, obj.NotificationTypeID) + args[obj.NotificationTypeID] = struct{}{} } } @@ -629,9 +649,16 @@ func (notificationPreferenceL) LoadNotificationType(ctx context.Context, e boil. return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`notification_types`), - qm.WhereIn(`notification_types.id in ?`, args...), + qm.WhereIn(`notification_types.id in ?`, argsSlice...), qmhelper.WhereIsNull(`notification_types.deleted_at`), ) if mods != nil { @@ -721,30 +748,23 @@ func (notificationPreferenceL) LoadNotificationTarget(ctx context.Context, e boi } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = ¬ificationPreferenceR{} } if !queries.IsNil(object.NotificationTargetID) { - args = append(args, object.NotificationTargetID) + args[object.NotificationTargetID] = struct{}{} } } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = ¬ificationPreferenceR{} } - for _, a := range args { - if queries.Equal(a, obj.NotificationTargetID) { - continue Outer - } - } - if !queries.IsNil(obj.NotificationTargetID) { - args = append(args, obj.NotificationTargetID) + args[obj.NotificationTargetID] = struct{}{} } } @@ -754,9 +774,16 @@ func (notificationPreferenceL) LoadNotificationTarget(ctx context.Context, e boi return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`notification_targets`), - qm.WhereIn(`notification_targets.id in ?`, args...), + qm.WhereIn(`notification_targets.id in ?`, argsSlice...), qmhelper.WhereIsNull(`notification_targets.deleted_at`), ) if mods != nil { diff --git a/internal/models/notification_targets.go b/internal/models/notification_targets.go index a5dd301..2264d15 100644 --- a/internal/models/notification_targets.go +++ b/internal/models/notification_targets.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -167,18 +167,27 @@ var ( _ = qmhelper.Where ) +var notificationTargetAfterSelectMu sync.Mutex var notificationTargetAfterSelectHooks []NotificationTargetHook +var notificationTargetBeforeInsertMu sync.Mutex var notificationTargetBeforeInsertHooks []NotificationTargetHook +var notificationTargetAfterInsertMu sync.Mutex var notificationTargetAfterInsertHooks []NotificationTargetHook +var notificationTargetBeforeUpdateMu sync.Mutex var notificationTargetBeforeUpdateHooks []NotificationTargetHook +var notificationTargetAfterUpdateMu sync.Mutex var notificationTargetAfterUpdateHooks []NotificationTargetHook +var notificationTargetBeforeDeleteMu sync.Mutex var notificationTargetBeforeDeleteHooks []NotificationTargetHook +var notificationTargetAfterDeleteMu sync.Mutex var notificationTargetAfterDeleteHooks []NotificationTargetHook +var notificationTargetBeforeUpsertMu sync.Mutex var notificationTargetBeforeUpsertHooks []NotificationTargetHook +var notificationTargetAfterUpsertMu sync.Mutex var notificationTargetAfterUpsertHooks []NotificationTargetHook // doAfterSelectHooks executes all "after Select" hooks. @@ -320,23 +329,41 @@ func (o *NotificationTarget) doAfterUpsertHooks(ctx context.Context, exec boil.C func AddNotificationTargetHook(hookPoint boil.HookPoint, notificationTargetHook NotificationTargetHook) { switch hookPoint { case boil.AfterSelectHook: + notificationTargetAfterSelectMu.Lock() notificationTargetAfterSelectHooks = append(notificationTargetAfterSelectHooks, notificationTargetHook) + notificationTargetAfterSelectMu.Unlock() case boil.BeforeInsertHook: + notificationTargetBeforeInsertMu.Lock() notificationTargetBeforeInsertHooks = append(notificationTargetBeforeInsertHooks, notificationTargetHook) + notificationTargetBeforeInsertMu.Unlock() case boil.AfterInsertHook: + notificationTargetAfterInsertMu.Lock() notificationTargetAfterInsertHooks = append(notificationTargetAfterInsertHooks, notificationTargetHook) + notificationTargetAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + notificationTargetBeforeUpdateMu.Lock() notificationTargetBeforeUpdateHooks = append(notificationTargetBeforeUpdateHooks, notificationTargetHook) + notificationTargetBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + notificationTargetAfterUpdateMu.Lock() notificationTargetAfterUpdateHooks = append(notificationTargetAfterUpdateHooks, notificationTargetHook) + notificationTargetAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + notificationTargetBeforeDeleteMu.Lock() notificationTargetBeforeDeleteHooks = append(notificationTargetBeforeDeleteHooks, notificationTargetHook) + notificationTargetBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + notificationTargetAfterDeleteMu.Lock() notificationTargetAfterDeleteHooks = append(notificationTargetAfterDeleteHooks, notificationTargetHook) + notificationTargetAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + notificationTargetBeforeUpsertMu.Lock() notificationTargetBeforeUpsertHooks = append(notificationTargetBeforeUpsertHooks, notificationTargetHook) + notificationTargetBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + notificationTargetAfterUpsertMu.Lock() notificationTargetAfterUpsertHooks = append(notificationTargetAfterUpsertHooks, notificationTargetHook) + notificationTargetAfterUpsertMu.Unlock() } } @@ -454,26 +481,18 @@ func (notificationTargetL) LoadNotificationPreferences(ctx context.Context, e bo } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = ¬ificationTargetR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = ¬ificationTargetR{} } - - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -481,9 +500,16 @@ func (notificationTargetL) LoadNotificationPreferences(ctx context.Context, e bo return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`notification_preferences`), - qm.WhereIn(`notification_preferences.notification_target_id in ?`, args...), + qm.WhereIn(`notification_preferences.notification_target_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) diff --git a/internal/models/notification_types.go b/internal/models/notification_types.go index ba4ccbc..81e3cad 100644 --- a/internal/models/notification_types.go +++ b/internal/models/notification_types.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -167,18 +167,27 @@ var ( _ = qmhelper.Where ) +var notificationTypeAfterSelectMu sync.Mutex var notificationTypeAfterSelectHooks []NotificationTypeHook +var notificationTypeBeforeInsertMu sync.Mutex var notificationTypeBeforeInsertHooks []NotificationTypeHook +var notificationTypeAfterInsertMu sync.Mutex var notificationTypeAfterInsertHooks []NotificationTypeHook +var notificationTypeBeforeUpdateMu sync.Mutex var notificationTypeBeforeUpdateHooks []NotificationTypeHook +var notificationTypeAfterUpdateMu sync.Mutex var notificationTypeAfterUpdateHooks []NotificationTypeHook +var notificationTypeBeforeDeleteMu sync.Mutex var notificationTypeBeforeDeleteHooks []NotificationTypeHook +var notificationTypeAfterDeleteMu sync.Mutex var notificationTypeAfterDeleteHooks []NotificationTypeHook +var notificationTypeBeforeUpsertMu sync.Mutex var notificationTypeBeforeUpsertHooks []NotificationTypeHook +var notificationTypeAfterUpsertMu sync.Mutex var notificationTypeAfterUpsertHooks []NotificationTypeHook // doAfterSelectHooks executes all "after Select" hooks. @@ -320,23 +329,41 @@ func (o *NotificationType) doAfterUpsertHooks(ctx context.Context, exec boil.Con func AddNotificationTypeHook(hookPoint boil.HookPoint, notificationTypeHook NotificationTypeHook) { switch hookPoint { case boil.AfterSelectHook: + notificationTypeAfterSelectMu.Lock() notificationTypeAfterSelectHooks = append(notificationTypeAfterSelectHooks, notificationTypeHook) + notificationTypeAfterSelectMu.Unlock() case boil.BeforeInsertHook: + notificationTypeBeforeInsertMu.Lock() notificationTypeBeforeInsertHooks = append(notificationTypeBeforeInsertHooks, notificationTypeHook) + notificationTypeBeforeInsertMu.Unlock() case boil.AfterInsertHook: + notificationTypeAfterInsertMu.Lock() notificationTypeAfterInsertHooks = append(notificationTypeAfterInsertHooks, notificationTypeHook) + notificationTypeAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + notificationTypeBeforeUpdateMu.Lock() notificationTypeBeforeUpdateHooks = append(notificationTypeBeforeUpdateHooks, notificationTypeHook) + notificationTypeBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + notificationTypeAfterUpdateMu.Lock() notificationTypeAfterUpdateHooks = append(notificationTypeAfterUpdateHooks, notificationTypeHook) + notificationTypeAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + notificationTypeBeforeDeleteMu.Lock() notificationTypeBeforeDeleteHooks = append(notificationTypeBeforeDeleteHooks, notificationTypeHook) + notificationTypeBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + notificationTypeAfterDeleteMu.Lock() notificationTypeAfterDeleteHooks = append(notificationTypeAfterDeleteHooks, notificationTypeHook) + notificationTypeAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + notificationTypeBeforeUpsertMu.Lock() notificationTypeBeforeUpsertHooks = append(notificationTypeBeforeUpsertHooks, notificationTypeHook) + notificationTypeBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + notificationTypeAfterUpsertMu.Lock() notificationTypeAfterUpsertHooks = append(notificationTypeAfterUpsertHooks, notificationTypeHook) + notificationTypeAfterUpsertMu.Unlock() } } @@ -454,26 +481,18 @@ func (notificationTypeL) LoadNotificationPreferences(ctx context.Context, e boil } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = ¬ificationTypeR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = ¬ificationTypeR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -481,9 +500,16 @@ func (notificationTypeL) LoadNotificationPreferences(ctx context.Context, e boil return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`notification_preferences`), - qm.WhereIn(`notification_preferences.notification_type_id in ?`, args...), + qm.WhereIn(`notification_preferences.notification_type_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) diff --git a/internal/models/organizations.go b/internal/models/organizations.go index 15d0c60..d5df997 100644 --- a/internal/models/organizations.go +++ b/internal/models/organizations.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -163,18 +163,27 @@ var ( _ = qmhelper.Where ) +var organizationAfterSelectMu sync.Mutex var organizationAfterSelectHooks []OrganizationHook +var organizationBeforeInsertMu sync.Mutex var organizationBeforeInsertHooks []OrganizationHook +var organizationAfterInsertMu sync.Mutex var organizationAfterInsertHooks []OrganizationHook +var organizationBeforeUpdateMu sync.Mutex var organizationBeforeUpdateHooks []OrganizationHook +var organizationAfterUpdateMu sync.Mutex var organizationAfterUpdateHooks []OrganizationHook +var organizationBeforeDeleteMu sync.Mutex var organizationBeforeDeleteHooks []OrganizationHook +var organizationAfterDeleteMu sync.Mutex var organizationAfterDeleteHooks []OrganizationHook +var organizationBeforeUpsertMu sync.Mutex var organizationBeforeUpsertHooks []OrganizationHook +var organizationAfterUpsertMu sync.Mutex var organizationAfterUpsertHooks []OrganizationHook // doAfterSelectHooks executes all "after Select" hooks. @@ -316,23 +325,41 @@ func (o *Organization) doAfterUpsertHooks(ctx context.Context, exec boil.Context func AddOrganizationHook(hookPoint boil.HookPoint, organizationHook OrganizationHook) { switch hookPoint { case boil.AfterSelectHook: + organizationAfterSelectMu.Lock() organizationAfterSelectHooks = append(organizationAfterSelectHooks, organizationHook) + organizationAfterSelectMu.Unlock() case boil.BeforeInsertHook: + organizationBeforeInsertMu.Lock() organizationBeforeInsertHooks = append(organizationBeforeInsertHooks, organizationHook) + organizationBeforeInsertMu.Unlock() case boil.AfterInsertHook: + organizationAfterInsertMu.Lock() organizationAfterInsertHooks = append(organizationAfterInsertHooks, organizationHook) + organizationAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + organizationBeforeUpdateMu.Lock() organizationBeforeUpdateHooks = append(organizationBeforeUpdateHooks, organizationHook) + organizationBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + organizationAfterUpdateMu.Lock() organizationAfterUpdateHooks = append(organizationAfterUpdateHooks, organizationHook) + organizationAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + organizationBeforeDeleteMu.Lock() organizationBeforeDeleteHooks = append(organizationBeforeDeleteHooks, organizationHook) + organizationBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + organizationAfterDeleteMu.Lock() organizationAfterDeleteHooks = append(organizationAfterDeleteHooks, organizationHook) + organizationAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + organizationBeforeUpsertMu.Lock() organizationBeforeUpsertHooks = append(organizationBeforeUpsertHooks, organizationHook) + organizationBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + organizationAfterUpsertMu.Lock() organizationAfterUpsertHooks = append(organizationAfterUpsertHooks, organizationHook) + organizationAfterUpsertMu.Unlock() } } @@ -464,26 +491,18 @@ func (organizationL) LoadSubjectOrganizationAuditEvents(ctx context.Context, e b } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &organizationR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &organizationR{} } - - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -491,9 +510,16 @@ func (organizationL) LoadSubjectOrganizationAuditEvents(ctx context.Context, e b return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`audit_events`), - qm.WhereIn(`audit_events.subject_organization_id in ?`, args...), + qm.WhereIn(`audit_events.subject_organization_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -578,26 +604,18 @@ func (organizationL) LoadGroupOrganizations(ctx context.Context, e boil.ContextE } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &organizationR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &organizationR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -605,9 +623,16 @@ func (organizationL) LoadGroupOrganizations(ctx context.Context, e boil.ContextE return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_organizations`), - qm.WhereIn(`group_organizations.organization_id in ?`, args...), + qm.WhereIn(`group_organizations.organization_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) diff --git a/internal/models/system_extension_resources.go b/internal/models/system_extension_resources.go index 97d2c47..6d0c578 100644 --- a/internal/models/system_extension_resources.go +++ b/internal/models/system_extension_resources.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -154,18 +154,27 @@ var ( _ = qmhelper.Where ) +var systemExtensionResourceAfterSelectMu sync.Mutex var systemExtensionResourceAfterSelectHooks []SystemExtensionResourceHook +var systemExtensionResourceBeforeInsertMu sync.Mutex var systemExtensionResourceBeforeInsertHooks []SystemExtensionResourceHook +var systemExtensionResourceAfterInsertMu sync.Mutex var systemExtensionResourceAfterInsertHooks []SystemExtensionResourceHook +var systemExtensionResourceBeforeUpdateMu sync.Mutex var systemExtensionResourceBeforeUpdateHooks []SystemExtensionResourceHook +var systemExtensionResourceAfterUpdateMu sync.Mutex var systemExtensionResourceAfterUpdateHooks []SystemExtensionResourceHook +var systemExtensionResourceBeforeDeleteMu sync.Mutex var systemExtensionResourceBeforeDeleteHooks []SystemExtensionResourceHook +var systemExtensionResourceAfterDeleteMu sync.Mutex var systemExtensionResourceAfterDeleteHooks []SystemExtensionResourceHook +var systemExtensionResourceBeforeUpsertMu sync.Mutex var systemExtensionResourceBeforeUpsertHooks []SystemExtensionResourceHook +var systemExtensionResourceAfterUpsertMu sync.Mutex var systemExtensionResourceAfterUpsertHooks []SystemExtensionResourceHook // doAfterSelectHooks executes all "after Select" hooks. @@ -307,23 +316,41 @@ func (o *SystemExtensionResource) doAfterUpsertHooks(ctx context.Context, exec b func AddSystemExtensionResourceHook(hookPoint boil.HookPoint, systemExtensionResourceHook SystemExtensionResourceHook) { switch hookPoint { case boil.AfterSelectHook: + systemExtensionResourceAfterSelectMu.Lock() systemExtensionResourceAfterSelectHooks = append(systemExtensionResourceAfterSelectHooks, systemExtensionResourceHook) + systemExtensionResourceAfterSelectMu.Unlock() case boil.BeforeInsertHook: + systemExtensionResourceBeforeInsertMu.Lock() systemExtensionResourceBeforeInsertHooks = append(systemExtensionResourceBeforeInsertHooks, systemExtensionResourceHook) + systemExtensionResourceBeforeInsertMu.Unlock() case boil.AfterInsertHook: + systemExtensionResourceAfterInsertMu.Lock() systemExtensionResourceAfterInsertHooks = append(systemExtensionResourceAfterInsertHooks, systemExtensionResourceHook) + systemExtensionResourceAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + systemExtensionResourceBeforeUpdateMu.Lock() systemExtensionResourceBeforeUpdateHooks = append(systemExtensionResourceBeforeUpdateHooks, systemExtensionResourceHook) + systemExtensionResourceBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + systemExtensionResourceAfterUpdateMu.Lock() systemExtensionResourceAfterUpdateHooks = append(systemExtensionResourceAfterUpdateHooks, systemExtensionResourceHook) + systemExtensionResourceAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + systemExtensionResourceBeforeDeleteMu.Lock() systemExtensionResourceBeforeDeleteHooks = append(systemExtensionResourceBeforeDeleteHooks, systemExtensionResourceHook) + systemExtensionResourceBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + systemExtensionResourceAfterDeleteMu.Lock() systemExtensionResourceAfterDeleteHooks = append(systemExtensionResourceAfterDeleteHooks, systemExtensionResourceHook) + systemExtensionResourceAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + systemExtensionResourceBeforeUpsertMu.Lock() systemExtensionResourceBeforeUpsertHooks = append(systemExtensionResourceBeforeUpsertHooks, systemExtensionResourceHook) + systemExtensionResourceBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + systemExtensionResourceAfterUpsertMu.Lock() systemExtensionResourceAfterUpsertHooks = append(systemExtensionResourceAfterUpsertHooks, systemExtensionResourceHook) + systemExtensionResourceAfterUpsertMu.Unlock() } } @@ -438,27 +465,20 @@ func (systemExtensionResourceL) LoadExtensionResourceDefinition(ctx context.Cont } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &systemExtensionResourceR{} } - args = append(args, object.ExtensionResourceDefinitionID) + args[object.ExtensionResourceDefinitionID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &systemExtensionResourceR{} } - for _, a := range args { - if a == obj.ExtensionResourceDefinitionID { - continue Outer - } - } - - args = append(args, obj.ExtensionResourceDefinitionID) + args[obj.ExtensionResourceDefinitionID] = struct{}{} } } @@ -467,9 +487,16 @@ func (systemExtensionResourceL) LoadExtensionResourceDefinition(ctx context.Cont return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`extension_resource_definitions`), - qm.WhereIn(`extension_resource_definitions.id in ?`, args...), + qm.WhereIn(`extension_resource_definitions.id in ?`, argsSlice...), qmhelper.WhereIsNull(`extension_resource_definitions.deleted_at`), ) if mods != nil { diff --git a/internal/models/user_extension_resources.go b/internal/models/user_extension_resources.go index 6dedf30..6a9d4b8 100644 --- a/internal/models/user_extension_resources.go +++ b/internal/models/user_extension_resources.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -171,18 +171,27 @@ var ( _ = qmhelper.Where ) +var userExtensionResourceAfterSelectMu sync.Mutex var userExtensionResourceAfterSelectHooks []UserExtensionResourceHook +var userExtensionResourceBeforeInsertMu sync.Mutex var userExtensionResourceBeforeInsertHooks []UserExtensionResourceHook +var userExtensionResourceAfterInsertMu sync.Mutex var userExtensionResourceAfterInsertHooks []UserExtensionResourceHook +var userExtensionResourceBeforeUpdateMu sync.Mutex var userExtensionResourceBeforeUpdateHooks []UserExtensionResourceHook +var userExtensionResourceAfterUpdateMu sync.Mutex var userExtensionResourceAfterUpdateHooks []UserExtensionResourceHook +var userExtensionResourceBeforeDeleteMu sync.Mutex var userExtensionResourceBeforeDeleteHooks []UserExtensionResourceHook +var userExtensionResourceAfterDeleteMu sync.Mutex var userExtensionResourceAfterDeleteHooks []UserExtensionResourceHook +var userExtensionResourceBeforeUpsertMu sync.Mutex var userExtensionResourceBeforeUpsertHooks []UserExtensionResourceHook +var userExtensionResourceAfterUpsertMu sync.Mutex var userExtensionResourceAfterUpsertHooks []UserExtensionResourceHook // doAfterSelectHooks executes all "after Select" hooks. @@ -324,23 +333,41 @@ func (o *UserExtensionResource) doAfterUpsertHooks(ctx context.Context, exec boi func AddUserExtensionResourceHook(hookPoint boil.HookPoint, userExtensionResourceHook UserExtensionResourceHook) { switch hookPoint { case boil.AfterSelectHook: + userExtensionResourceAfterSelectMu.Lock() userExtensionResourceAfterSelectHooks = append(userExtensionResourceAfterSelectHooks, userExtensionResourceHook) + userExtensionResourceAfterSelectMu.Unlock() case boil.BeforeInsertHook: + userExtensionResourceBeforeInsertMu.Lock() userExtensionResourceBeforeInsertHooks = append(userExtensionResourceBeforeInsertHooks, userExtensionResourceHook) + userExtensionResourceBeforeInsertMu.Unlock() case boil.AfterInsertHook: + userExtensionResourceAfterInsertMu.Lock() userExtensionResourceAfterInsertHooks = append(userExtensionResourceAfterInsertHooks, userExtensionResourceHook) + userExtensionResourceAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + userExtensionResourceBeforeUpdateMu.Lock() userExtensionResourceBeforeUpdateHooks = append(userExtensionResourceBeforeUpdateHooks, userExtensionResourceHook) + userExtensionResourceBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + userExtensionResourceAfterUpdateMu.Lock() userExtensionResourceAfterUpdateHooks = append(userExtensionResourceAfterUpdateHooks, userExtensionResourceHook) + userExtensionResourceAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + userExtensionResourceBeforeDeleteMu.Lock() userExtensionResourceBeforeDeleteHooks = append(userExtensionResourceBeforeDeleteHooks, userExtensionResourceHook) + userExtensionResourceBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + userExtensionResourceAfterDeleteMu.Lock() userExtensionResourceAfterDeleteHooks = append(userExtensionResourceAfterDeleteHooks, userExtensionResourceHook) + userExtensionResourceAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + userExtensionResourceBeforeUpsertMu.Lock() userExtensionResourceBeforeUpsertHooks = append(userExtensionResourceBeforeUpsertHooks, userExtensionResourceHook) + userExtensionResourceBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + userExtensionResourceAfterUpsertMu.Lock() userExtensionResourceAfterUpsertHooks = append(userExtensionResourceAfterUpsertHooks, userExtensionResourceHook) + userExtensionResourceAfterUpsertMu.Unlock() } } @@ -466,27 +493,20 @@ func (userExtensionResourceL) LoadUser(ctx context.Context, e boil.ContextExecut } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userExtensionResourceR{} } - args = append(args, object.UserID) + args[object.UserID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userExtensionResourceR{} } - for _, a := range args { - if a == obj.UserID { - continue Outer - } - } - - args = append(args, obj.UserID) + args[obj.UserID] = struct{}{} } } @@ -495,9 +515,16 @@ func (userExtensionResourceL) LoadUser(ctx context.Context, e boil.ContextExecut return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`users`), - qm.WhereIn(`users.id in ?`, args...), + qm.WhereIn(`users.id in ?`, argsSlice...), qmhelper.WhereIsNull(`users.deleted_at`), ) if mods != nil { @@ -587,27 +614,20 @@ func (userExtensionResourceL) LoadExtensionResourceDefinition(ctx context.Contex } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userExtensionResourceR{} } - args = append(args, object.ExtensionResourceDefinitionID) + args[object.ExtensionResourceDefinitionID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userExtensionResourceR{} } - for _, a := range args { - if a == obj.ExtensionResourceDefinitionID { - continue Outer - } - } - - args = append(args, obj.ExtensionResourceDefinitionID) + args[obj.ExtensionResourceDefinitionID] = struct{}{} } } @@ -616,9 +636,16 @@ func (userExtensionResourceL) LoadExtensionResourceDefinition(ctx context.Contex return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`extension_resource_definitions`), - qm.WhereIn(`extension_resource_definitions.id in ?`, args...), + qm.WhereIn(`extension_resource_definitions.id in ?`, argsSlice...), qmhelper.WhereIsNull(`extension_resource_definitions.deleted_at`), ) if mods != nil { diff --git a/internal/models/users.go b/internal/models/users.go index 3cd4b09..2ee27e8 100644 --- a/internal/models/users.go +++ b/internal/models/users.go @@ -1,4 +1,4 @@ -// Code generated by SQLBoiler 4.15.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// Code generated by SQLBoiler 4.16.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models @@ -323,18 +323,27 @@ var ( _ = qmhelper.Where ) +var userAfterSelectMu sync.Mutex var userAfterSelectHooks []UserHook +var userBeforeInsertMu sync.Mutex var userBeforeInsertHooks []UserHook +var userAfterInsertMu sync.Mutex var userAfterInsertHooks []UserHook +var userBeforeUpdateMu sync.Mutex var userBeforeUpdateHooks []UserHook +var userAfterUpdateMu sync.Mutex var userAfterUpdateHooks []UserHook +var userBeforeDeleteMu sync.Mutex var userBeforeDeleteHooks []UserHook +var userAfterDeleteMu sync.Mutex var userAfterDeleteHooks []UserHook +var userBeforeUpsertMu sync.Mutex var userBeforeUpsertHooks []UserHook +var userAfterUpsertMu sync.Mutex var userAfterUpsertHooks []UserHook // doAfterSelectHooks executes all "after Select" hooks. @@ -476,23 +485,41 @@ func (o *User) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor func AddUserHook(hookPoint boil.HookPoint, userHook UserHook) { switch hookPoint { case boil.AfterSelectHook: + userAfterSelectMu.Lock() userAfterSelectHooks = append(userAfterSelectHooks, userHook) + userAfterSelectMu.Unlock() case boil.BeforeInsertHook: + userBeforeInsertMu.Lock() userBeforeInsertHooks = append(userBeforeInsertHooks, userHook) + userBeforeInsertMu.Unlock() case boil.AfterInsertHook: + userAfterInsertMu.Lock() userAfterInsertHooks = append(userAfterInsertHooks, userHook) + userAfterInsertMu.Unlock() case boil.BeforeUpdateHook: + userBeforeUpdateMu.Lock() userBeforeUpdateHooks = append(userBeforeUpdateHooks, userHook) + userBeforeUpdateMu.Unlock() case boil.AfterUpdateHook: + userAfterUpdateMu.Lock() userAfterUpdateHooks = append(userAfterUpdateHooks, userHook) + userAfterUpdateMu.Unlock() case boil.BeforeDeleteHook: + userBeforeDeleteMu.Lock() userBeforeDeleteHooks = append(userBeforeDeleteHooks, userHook) + userBeforeDeleteMu.Unlock() case boil.AfterDeleteHook: + userAfterDeleteMu.Lock() userAfterDeleteHooks = append(userAfterDeleteHooks, userHook) + userAfterDeleteMu.Unlock() case boil.BeforeUpsertHook: + userBeforeUpsertMu.Lock() userBeforeUpsertHooks = append(userBeforeUpsertHooks, userHook) + userBeforeUpsertMu.Unlock() case boil.AfterUpsertHook: + userAfterUpsertMu.Lock() userAfterUpsertHooks = append(userAfterUpsertHooks, userHook) + userAfterUpsertMu.Unlock() } } @@ -694,26 +721,18 @@ func (userL) LoadSubjectUserAuditEvents(ctx context.Context, e boil.ContextExecu } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userR{} } - - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -721,9 +740,16 @@ func (userL) LoadSubjectUserAuditEvents(ctx context.Context, e boil.ContextExecu return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`audit_events`), - qm.WhereIn(`audit_events.subject_user_id in ?`, args...), + qm.WhereIn(`audit_events.subject_user_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -808,26 +834,18 @@ func (userL) LoadActorAuditEvents(ctx context.Context, e boil.ContextExecutor, s } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userR{} } - - for _, a := range args { - if queries.Equal(a, obj.ID) { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -835,9 +853,16 @@ func (userL) LoadActorAuditEvents(ctx context.Context, e boil.ContextExecutor, s return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`audit_events`), - qm.WhereIn(`audit_events.actor_id in ?`, args...), + qm.WhereIn(`audit_events.actor_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -922,26 +947,18 @@ func (userL) LoadRequesterUserGroupApplicationRequests(ctx context.Context, e bo } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -949,9 +966,16 @@ func (userL) LoadRequesterUserGroupApplicationRequests(ctx context.Context, e bo return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_application_requests`), - qm.WhereIn(`group_application_requests.requester_user_id in ?`, args...), + qm.WhereIn(`group_application_requests.requester_user_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1036,26 +1060,18 @@ func (userL) LoadGroupMembershipRequests(ctx context.Context, e boil.ContextExec } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1063,9 +1079,16 @@ func (userL) LoadGroupMembershipRequests(ctx context.Context, e boil.ContextExec return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_membership_requests`), - qm.WhereIn(`group_membership_requests.user_id in ?`, args...), + qm.WhereIn(`group_membership_requests.user_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1150,26 +1173,18 @@ func (userL) LoadGroupMemberships(ctx context.Context, e boil.ContextExecutor, s } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1177,9 +1192,16 @@ func (userL) LoadGroupMemberships(ctx context.Context, e boil.ContextExecutor, s return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`group_memberships`), - qm.WhereIn(`group_memberships.user_id in ?`, args...), + qm.WhereIn(`group_memberships.user_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1264,26 +1286,18 @@ func (userL) LoadNotificationPreferences(ctx context.Context, e boil.ContextExec } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1291,9 +1305,16 @@ func (userL) LoadNotificationPreferences(ctx context.Context, e boil.ContextExec return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`notification_preferences`), - qm.WhereIn(`notification_preferences.user_id in ?`, args...), + qm.WhereIn(`notification_preferences.user_id in ?`, argsSlice...), ) if mods != nil { mods.Apply(query) @@ -1378,26 +1399,18 @@ func (userL) LoadUserExtensionResources(ctx context.Context, e boil.ContextExecu } } - args := make([]interface{}, 0, 1) + args := make(map[interface{}]struct{}) if singular { if object.R == nil { object.R = &userR{} } - args = append(args, object.ID) + args[object.ID] = struct{}{} } else { - Outer: for _, obj := range slice { if obj.R == nil { obj.R = &userR{} } - - for _, a := range args { - if a == obj.ID { - continue Outer - } - } - - args = append(args, obj.ID) + args[obj.ID] = struct{}{} } } @@ -1405,9 +1418,16 @@ func (userL) LoadUserExtensionResources(ctx context.Context, e boil.ContextExecu return nil } + argsSlice := make([]interface{}, len(args)) + i := 0 + for arg := range args { + argsSlice[i] = arg + i++ + } + query := NewQuery( qm.From(`user_extension_resources`), - qm.WhereIn(`user_extension_resources.user_id in ?`, args...), + qm.WhereIn(`user_extension_resources.user_id in ?`, argsSlice...), qmhelper.WhereIsNull(`user_extension_resources.deleted_at`), ) if mods != nil { diff --git a/pkg/api/v1alpha1/auth.go b/pkg/api/v1alpha1/auth.go index 90771a8..90dfc55 100644 --- a/pkg/api/v1alpha1/auth.go +++ b/pkg/api/v1alpha1/auth.go @@ -34,6 +34,8 @@ const ( AuthRoleGroupAdmin // AuthRoleAdminOrGroupAdmin indicates an authenticated user who is an admin in the given group or governor admin AuthRoleAdminOrGroupAdmin + // AuthRoleAdminOrGroupAdminOrGroupApprover indicates an authenticated user who is an admin in the given group or governor admin or a member of the approver group + AuthRoleAdminOrGroupAdminOrGroupApprover ) func (u mwAuthRole) String() string { @@ -43,14 +45,16 @@ func (u mwAuthRole) String() string { "AuthRoleGroupMember", "AuthRoleGroupAdmin", "AuthRoleAdminOrGroupAdmin", + "AuthRoleAdminOrGroupAdminOrGroupApprover", }[u] } const ( - contextKeyUser = "current_user" - contextKeyAdmin = "is_admin" - contextKeyGroupAdmin = "is_group_admin" - contextKeyGroupMember = "is_group_member" + contextKeyUser = "current_user" + contextKeyAdmin = "is_admin" + contextKeyGroupAdmin = "is_group_admin" + contextKeyGroupMember = "is_group_member" + contextKeyGroupApprover = "is_group_approver" ) // oidcScope is the scope that is required for the oidcAuthRequired check @@ -272,6 +276,7 @@ func (r *Router) mwUserAuthRequired(authRole mwAuthRole) gin.HandlerFunc { // mwGroupAuthRequired checks if the current authenticated user is a member or admin in the given group // and adds user information to the gin context. It expects to find the group id (could be also the slug) // in the id context param. +// nolint:gocyclo func (r *Router) mwGroupAuthRequired(authRole mwAuthRole) gin.HandlerFunc { return func(c *gin.Context) { r.Logger.Debug("mwGroupAuthRequired", zap.String("role", authRole.String())) @@ -293,6 +298,18 @@ func (r *Router) mwGroupAuthRequired(authRole mwAuthRole) gin.HandlerFunc { return } + group, err := models.FindGroup(c.Request.Context(), r.DB, id) + if err != nil { + if !errors.Is(err, sql.ErrNoRows) { + sendError(c, http.StatusInternalServerError, "error getting group: "+err.Error()) + return + } + + sendError(c, http.StatusUnauthorized, "group not found") + + return + } + queryMods := []qm.QueryMod{ models.UserWhere.ExternalID.EQ(null.StringFrom(c.GetString("jwt.user"))), } @@ -313,6 +330,7 @@ func (r *Router) mwGroupAuthRequired(authRole mwAuthRole) gin.HandlerFunc { isGroupMember := false isGroupAdmin := false + isGroupApprover := false idIsSlug := false if _, err := uuid.Parse(id); err != nil { @@ -345,12 +363,17 @@ func (r *Router) mwGroupAuthRequired(authRole mwAuthRole) gin.HandlerFunc { break } + + if group.ApproverGroup.Valid && group.ApproverGroup.String == groupID { + isGroupApprover = true + } } // add user to gin context setCtxUser(c, user) setCtxGroupAdmin(c, &isGroupAdmin) setCtxGroupMember(c, &isGroupMember) + setCtxGroupApprover(c, &isGroupApprover) if authRole == AuthRoleGroupMember { if !isGroupMember { @@ -379,9 +402,9 @@ func (r *Router) mwGroupAuthRequired(authRole mwAuthRole) gin.HandlerFunc { if authRole == AuthRoleAdminOrGroupAdmin { isAdmin := false - memberships := make([]string, len(enumeratedMemberships)) - for i, m := range enumeratedMemberships { - memberships[i] = m.GroupID + memberships := make(map[string]struct{}) + for _, m := range enumeratedMemberships { + memberships[m.GroupID] = struct{}{} } ag := make([]interface{}, len(r.AdminGroups)) @@ -396,9 +419,8 @@ func (r *Router) mwGroupAuthRequired(authRole mwAuthRole) gin.HandlerFunc { } for _, g := range adminGroups { - if contains(memberships, g.ID) { + if _, found := memberships[g.ID]; found { isAdmin = true - break } } @@ -413,6 +435,42 @@ func (r *Router) mwGroupAuthRequired(authRole mwAuthRole) gin.HandlerFunc { return } + if authRole == AuthRoleAdminOrGroupAdminOrGroupApprover { + isAdmin := false + + memberships := make(map[string]struct{}) + for _, m := range enumeratedMemberships { + memberships[m.GroupID] = struct{}{} + } + + ag := make([]interface{}, len(r.AdminGroups)) + for i, a := range r.AdminGroups { + ag[i] = a + } + + adminGroups, err := models.Groups(qm.WhereIn("slug IN ?", ag...)).All(c.Request.Context(), r.DB) + if err != nil { + sendError(c, http.StatusInternalServerError, "error getting admin groups: "+err.Error()) + return + } + + for _, g := range adminGroups { + if _, found := memberships[g.ID]; found { + isAdmin = true + } + } + + if !isGroupAdmin && !isAdmin && !isGroupApprover { + r.Logger.Debug("user is not admin or group admin", zap.String("group id", id)) + + sendError(c, http.StatusUnauthorized, "user not admin or group admin") + + return + } + + return + } + r.Logger.Debug("unsupported auth role") sendError(c, http.StatusUnauthorized, "unsupported auth role") } @@ -462,6 +520,10 @@ func setCtxGroupMember(c *gin.Context, m *bool) { c.Set(contextKeyGroupMember, m) } +func setCtxGroupApprover(c *gin.Context, a *bool) { + c.Set(contextKeyGroupApprover, a) +} + func getCtxAuditID(c *gin.Context) string { ca, exists := c.Get(ginaudit.AuditIDContextKey) if !exists { diff --git a/pkg/api/v1alpha1/authenticated_user.go b/pkg/api/v1alpha1/authenticated_user.go index 64b559b..ea5b0f4 100644 --- a/pkg/api/v1alpha1/authenticated_user.go +++ b/pkg/api/v1alpha1/authenticated_user.go @@ -232,6 +232,7 @@ func (r *Router) getAuthenticatedUserGroupApprovals(c *gin.Context) { qm.Load("User"), qm.Load("Group"), qm.Load("Group.GroupMemberships"), + qm.Load("Group.ApproverGroupGroup.GroupMemberships"), ).All(c.Request.Context(), r.DB) if err != nil { sendError(c, http.StatusInternalServerError, "error getting group membership requests: "+err.Error()) @@ -258,6 +259,8 @@ func (r *Router) getAuthenticatedUserGroupApprovals(c *gin.Context) { isGroupAdmin := contains(userAdminGroups, m.GroupID) + isInApproverGroup := m.R.Group.ApproverGroup.Valid && contains(userGroups, m.R.Group.ApproverGroup.String) + groupHasNoAdmins := true for _, groupMember := range m.R.Group.R.GroupMemberships { @@ -266,7 +269,11 @@ func (r *Router) getAuthenticatedUserGroupApprovals(c *gin.Context) { } } - if (*ctxAdmin && groupHasNoAdmins) || isGroupAdmin { + if groupHasNoAdmins && len(m.R.Group.R.ApproverGroupGroup.R.GroupMemberships) > 0 { + groupHasNoAdmins = false + } + + if (*ctxAdmin && groupHasNoAdmins) || isGroupAdmin || isInApproverGroup { memberApprovals = append(memberApprovals, AuthenticatedUserGroupMemberRequest{&GroupMemberRequest{ ID: m.ID, GroupID: m.GroupID, diff --git a/pkg/api/v1alpha1/groups.go b/pkg/api/v1alpha1/groups.go index 469efe1..5705e82 100644 --- a/pkg/api/v1alpha1/groups.go +++ b/pkg/api/v1alpha1/groups.go @@ -6,6 +6,8 @@ import ( "net/http" "regexp" + "github.com/volatiletech/null/v8" + "github.com/gin-gonic/gin" "github.com/google/uuid" "github.com/metal-toolbox/auditevent/ginaudit" @@ -30,9 +32,10 @@ type Group struct { // GroupReq is a group creation/update request type GroupReq struct { - Name string `json:"name"` - Description string `json:"description"` - Note string `json:"note"` + Name string `json:"name"` + Description string `json:"description"` + Note string `json:"note"` + ApproverGroupID string `json:"approver_group_id,omitempty"` } // listGroups lists the groups as JSON @@ -168,10 +171,20 @@ func (r *Router) createGroup(c *gin.Context) { return } + var approverGroupID null.String + + if req.ApproverGroupID != "" { + approverGroupID = null.String{ + String: req.ApproverGroupID, + Valid: true, + } + } + group := &models.Group{ - Description: req.Description, - Name: req.Name, - Note: req.Note, + Description: req.Description, + Name: req.Name, + Note: req.Note, + ApproverGroup: approverGroupID, } // Validation @@ -281,6 +294,17 @@ func (r *Router) updateGroup(c *gin.Context) { return } + var approverGroupID null.String + + if req.ApproverGroupID != "" { + approverGroupID = null.String{ + String: req.ApproverGroupID, + Valid: true, + } + } + + group.ApproverGroup = approverGroupID + group.Description = req.Description tx, err := r.DB.BeginTx(c.Request.Context(), nil) diff --git a/pkg/api/v1alpha1/router.go b/pkg/api/v1alpha1/router.go index aa93c73..29e1f58 100644 --- a/pkg/api/v1alpha1/router.go +++ b/pkg/api/v1alpha1/router.go @@ -223,7 +223,7 @@ func (r *Router) Routes(rg *gin.RouterGroup) { "/groups/:id/requests/:rid", r.AuditMW.AuditWithType("ProcessGroupRequest"), r.AuthMW.AuthRequired([]string{oidcScope}), - r.mwGroupAuthRequired(AuthRoleAdminOrGroupAdmin), + r.mwGroupAuthRequired(AuthRoleAdminOrGroupAdminOrGroupApprover), r.processGroupRequest, )