mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-28 07:56:35 +01:00
* ent re-generation
* add oidc integration
* document oidc integration
* go fmt
* address backend linter findings
* run prettier on index.vue
* State cookie domain can mismatch when Hostname override is used (breaks CSRF check). Add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Delete state cookie with matching domain and MaxAge; add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Fix endpoint path in comments and error to include /api/v1.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Also use request context when verifying the ID token.
* Do not return raw auth errors to clients (user-enumeration risk).
* consistently set cookie the same way across function
* remove baseURL after declaration
* only enable OIDC routes if OIDC is enabled
* swagger doc for failure
* Only block when provider=local; move the check after parsing provider
* fix extended session comment
* reduce pii logging
* futher reduce pii logging
* remove unused DiscoveryDocument
* remove unused offline_access from default oidc scopes
* remove offline access from AuthCodeURL
* support host from X-Forwarded-Host
* set sane default claim names if unset
* error strings should not be capitalized
* Revert "run prettier on index.vue"
This reverts commit aa22330a23.
* Add timeout to provider discovery
* Split scopes robustly
* refactor hostname calculation
* address frontend prettier findings
* add property oidc on type APISummary
* LoginOIDC: Normalize inputs, only create if not found
* add oidc email verification
* oidc handleCallback: clear state cookie before each return
* add support for oidc nonce parameter
* Harden first-login race: handle concurrent creates gracefully and fix log key.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* support email verified claim as bool or string
* fail fast on empty email
* PKCE verifier
* fix: add timing delay to attachment test to resolve CI race condition
The attachment test was failing intermittently in CI due to a race condition
between attachment creation and retrieval. Adding a small 100ms delay after
attachment creation ensures the file system and database operations complete
before the test attempts to verify the attachment exists.
* Revert "fix: add timing delay to attachment test to resolve CI race condition"
This reverts commit 4aa8b2a0d829753e8d2dd1ba76f4b1e04e28c45e.
* oidc error state, use ref
* rename oidc.force to oidc.authRedirect
* remove hardcoded oidc error timeout
* feat: sub/iss based identity matching and userinfo endpoint collection
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
1073 lines
31 KiB
Go
Generated
1073 lines
31 KiB
Go
Generated
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/google/uuid"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
|
)
|
|
|
|
// UserUpdate is the builder for updating User entities.
|
|
type UserUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *UserMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the UserUpdate builder.
|
|
func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *UserUpdate) SetUpdatedAt(v time.Time) *UserUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *UserUpdate) SetName(v string) *UserUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableName(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_u *UserUpdate) SetEmail(v string) *UserUpdate {
|
|
_u.mutation.SetEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_u *UserUpdate) SetPassword(v string) *UserUpdate {
|
|
_u.mutation.SetPassword(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetPassword(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (_u *UserUpdate) ClearPassword() *UserUpdate {
|
|
_u.mutation.ClearPassword()
|
|
return _u
|
|
}
|
|
|
|
// SetIsSuperuser sets the "is_superuser" field.
|
|
func (_u *UserUpdate) SetIsSuperuser(v bool) *UserUpdate {
|
|
_u.mutation.SetIsSuperuser(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsSuperuser sets the "is_superuser" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableIsSuperuser(v *bool) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetIsSuperuser(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSuperuser sets the "superuser" field.
|
|
func (_u *UserUpdate) SetSuperuser(v bool) *UserUpdate {
|
|
_u.mutation.SetSuperuser(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSuperuser sets the "superuser" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableSuperuser(v *bool) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetSuperuser(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (_u *UserUpdate) SetRole(v user.Role) *UserUpdate {
|
|
_u.mutation.SetRole(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableRole(v *user.Role) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetRole(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetActivatedOn sets the "activated_on" field.
|
|
func (_u *UserUpdate) SetActivatedOn(v time.Time) *UserUpdate {
|
|
_u.mutation.SetActivatedOn(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableActivatedOn sets the "activated_on" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableActivatedOn(v *time.Time) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetActivatedOn(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearActivatedOn clears the value of the "activated_on" field.
|
|
func (_u *UserUpdate) ClearActivatedOn() *UserUpdate {
|
|
_u.mutation.ClearActivatedOn()
|
|
return _u
|
|
}
|
|
|
|
// SetOidcIssuer sets the "oidc_issuer" field.
|
|
func (_u *UserUpdate) SetOidcIssuer(v string) *UserUpdate {
|
|
_u.mutation.SetOidcIssuer(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOidcIssuer sets the "oidc_issuer" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableOidcIssuer(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetOidcIssuer(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOidcIssuer clears the value of the "oidc_issuer" field.
|
|
func (_u *UserUpdate) ClearOidcIssuer() *UserUpdate {
|
|
_u.mutation.ClearOidcIssuer()
|
|
return _u
|
|
}
|
|
|
|
// SetOidcSubject sets the "oidc_subject" field.
|
|
func (_u *UserUpdate) SetOidcSubject(v string) *UserUpdate {
|
|
_u.mutation.SetOidcSubject(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOidcSubject sets the "oidc_subject" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableOidcSubject(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetOidcSubject(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOidcSubject clears the value of the "oidc_subject" field.
|
|
func (_u *UserUpdate) ClearOidcSubject() *UserUpdate {
|
|
_u.mutation.ClearOidcSubject()
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (_u *UserUpdate) SetGroupID(id uuid.UUID) *UserUpdate {
|
|
_u.mutation.SetGroupID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *UserUpdate) SetGroup(v *Group) *UserUpdate {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// AddAuthTokenIDs adds the "auth_tokens" edge to the AuthTokens entity by IDs.
|
|
func (_u *UserUpdate) AddAuthTokenIDs(ids ...uuid.UUID) *UserUpdate {
|
|
_u.mutation.AddAuthTokenIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddAuthTokens adds the "auth_tokens" edges to the AuthTokens entity.
|
|
func (_u *UserUpdate) AddAuthTokens(v ...*AuthTokens) *UserUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddAuthTokenIDs(ids...)
|
|
}
|
|
|
|
// AddNotifierIDs adds the "notifiers" edge to the Notifier entity by IDs.
|
|
func (_u *UserUpdate) AddNotifierIDs(ids ...uuid.UUID) *UserUpdate {
|
|
_u.mutation.AddNotifierIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddNotifiers adds the "notifiers" edges to the Notifier entity.
|
|
func (_u *UserUpdate) AddNotifiers(v ...*Notifier) *UserUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddNotifierIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the UserMutation object of the builder.
|
|
func (_u *UserUpdate) Mutation() *UserMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *UserUpdate) ClearGroup() *UserUpdate {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearAuthTokens clears all "auth_tokens" edges to the AuthTokens entity.
|
|
func (_u *UserUpdate) ClearAuthTokens() *UserUpdate {
|
|
_u.mutation.ClearAuthTokens()
|
|
return _u
|
|
}
|
|
|
|
// RemoveAuthTokenIDs removes the "auth_tokens" edge to AuthTokens entities by IDs.
|
|
func (_u *UserUpdate) RemoveAuthTokenIDs(ids ...uuid.UUID) *UserUpdate {
|
|
_u.mutation.RemoveAuthTokenIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveAuthTokens removes "auth_tokens" edges to AuthTokens entities.
|
|
func (_u *UserUpdate) RemoveAuthTokens(v ...*AuthTokens) *UserUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveAuthTokenIDs(ids...)
|
|
}
|
|
|
|
// ClearNotifiers clears all "notifiers" edges to the Notifier entity.
|
|
func (_u *UserUpdate) ClearNotifiers() *UserUpdate {
|
|
_u.mutation.ClearNotifiers()
|
|
return _u
|
|
}
|
|
|
|
// RemoveNotifierIDs removes the "notifiers" edge to Notifier entities by IDs.
|
|
func (_u *UserUpdate) RemoveNotifierIDs(ids ...uuid.UUID) *UserUpdate {
|
|
_u.mutation.RemoveNotifierIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveNotifiers removes "notifiers" edges to Notifier entities.
|
|
func (_u *UserUpdate) RemoveNotifiers(v ...*Notifier) *UserUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveNotifierIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *UserUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *UserUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *UserUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *UserUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *UserUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := user.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *UserUpdate) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := user.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Email(); ok {
|
|
if err := user.EmailValidator(v); err != nil {
|
|
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Password(); ok {
|
|
if err := user.PasswordValidator(v); err != nil {
|
|
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Role(); ok {
|
|
if err := user.RoleValidator(v); err != nil {
|
|
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "User.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(user.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Email(); ok {
|
|
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Password(); ok {
|
|
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
|
}
|
|
if _u.mutation.PasswordCleared() {
|
|
_spec.ClearField(user.FieldPassword, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.IsSuperuser(); ok {
|
|
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Superuser(); ok {
|
|
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Role(); ok {
|
|
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.ActivatedOn(); ok {
|
|
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.ActivatedOnCleared() {
|
|
_spec.ClearField(user.FieldActivatedOn, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.OidcIssuer(); ok {
|
|
_spec.SetField(user.FieldOidcIssuer, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OidcIssuerCleared() {
|
|
_spec.ClearField(user.FieldOidcIssuer, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.OidcSubject(); ok {
|
|
_spec.SetField(user.FieldOidcSubject, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OidcSubjectCleared() {
|
|
_spec.ClearField(user.FieldOidcSubject, field.TypeString)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: user.GroupTable,
|
|
Columns: []string{user.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: user.GroupTable,
|
|
Columns: []string{user.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.AuthTokensCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AuthTokensTable,
|
|
Columns: []string{user.AuthTokensColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedAuthTokensIDs(); len(nodes) > 0 && !_u.mutation.AuthTokensCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AuthTokensTable,
|
|
Columns: []string{user.AuthTokensColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AuthTokensIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AuthTokensTable,
|
|
Columns: []string{user.AuthTokensColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.NotifiersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.NotifiersTable,
|
|
Columns: []string{user.NotifiersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedNotifiersIDs(); len(nodes) > 0 && !_u.mutation.NotifiersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.NotifiersTable,
|
|
Columns: []string{user.NotifiersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.NotifiersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.NotifiersTable,
|
|
Columns: []string{user.NotifiersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{user.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// UserUpdateOne is the builder for updating a single User entity.
|
|
type UserUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *UserMutation
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *UserUpdateOne) SetUpdatedAt(v time.Time) *UserUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *UserUpdateOne) SetName(v string) *UserUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableName(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_u *UserUpdateOne) SetEmail(v string) *UserUpdateOne {
|
|
_u.mutation.SetEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_u *UserUpdateOne) SetPassword(v string) *UserUpdateOne {
|
|
_u.mutation.SetPassword(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetPassword(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (_u *UserUpdateOne) ClearPassword() *UserUpdateOne {
|
|
_u.mutation.ClearPassword()
|
|
return _u
|
|
}
|
|
|
|
// SetIsSuperuser sets the "is_superuser" field.
|
|
func (_u *UserUpdateOne) SetIsSuperuser(v bool) *UserUpdateOne {
|
|
_u.mutation.SetIsSuperuser(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsSuperuser sets the "is_superuser" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableIsSuperuser(v *bool) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetIsSuperuser(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSuperuser sets the "superuser" field.
|
|
func (_u *UserUpdateOne) SetSuperuser(v bool) *UserUpdateOne {
|
|
_u.mutation.SetSuperuser(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSuperuser sets the "superuser" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableSuperuser(v *bool) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetSuperuser(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (_u *UserUpdateOne) SetRole(v user.Role) *UserUpdateOne {
|
|
_u.mutation.SetRole(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableRole(v *user.Role) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetRole(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetActivatedOn sets the "activated_on" field.
|
|
func (_u *UserUpdateOne) SetActivatedOn(v time.Time) *UserUpdateOne {
|
|
_u.mutation.SetActivatedOn(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableActivatedOn sets the "activated_on" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableActivatedOn(v *time.Time) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetActivatedOn(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearActivatedOn clears the value of the "activated_on" field.
|
|
func (_u *UserUpdateOne) ClearActivatedOn() *UserUpdateOne {
|
|
_u.mutation.ClearActivatedOn()
|
|
return _u
|
|
}
|
|
|
|
// SetOidcIssuer sets the "oidc_issuer" field.
|
|
func (_u *UserUpdateOne) SetOidcIssuer(v string) *UserUpdateOne {
|
|
_u.mutation.SetOidcIssuer(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOidcIssuer sets the "oidc_issuer" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableOidcIssuer(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetOidcIssuer(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOidcIssuer clears the value of the "oidc_issuer" field.
|
|
func (_u *UserUpdateOne) ClearOidcIssuer() *UserUpdateOne {
|
|
_u.mutation.ClearOidcIssuer()
|
|
return _u
|
|
}
|
|
|
|
// SetOidcSubject sets the "oidc_subject" field.
|
|
func (_u *UserUpdateOne) SetOidcSubject(v string) *UserUpdateOne {
|
|
_u.mutation.SetOidcSubject(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOidcSubject sets the "oidc_subject" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableOidcSubject(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetOidcSubject(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOidcSubject clears the value of the "oidc_subject" field.
|
|
func (_u *UserUpdateOne) ClearOidcSubject() *UserUpdateOne {
|
|
_u.mutation.ClearOidcSubject()
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (_u *UserUpdateOne) SetGroupID(id uuid.UUID) *UserUpdateOne {
|
|
_u.mutation.SetGroupID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *UserUpdateOne) SetGroup(v *Group) *UserUpdateOne {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// AddAuthTokenIDs adds the "auth_tokens" edge to the AuthTokens entity by IDs.
|
|
func (_u *UserUpdateOne) AddAuthTokenIDs(ids ...uuid.UUID) *UserUpdateOne {
|
|
_u.mutation.AddAuthTokenIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddAuthTokens adds the "auth_tokens" edges to the AuthTokens entity.
|
|
func (_u *UserUpdateOne) AddAuthTokens(v ...*AuthTokens) *UserUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddAuthTokenIDs(ids...)
|
|
}
|
|
|
|
// AddNotifierIDs adds the "notifiers" edge to the Notifier entity by IDs.
|
|
func (_u *UserUpdateOne) AddNotifierIDs(ids ...uuid.UUID) *UserUpdateOne {
|
|
_u.mutation.AddNotifierIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddNotifiers adds the "notifiers" edges to the Notifier entity.
|
|
func (_u *UserUpdateOne) AddNotifiers(v ...*Notifier) *UserUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddNotifierIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the UserMutation object of the builder.
|
|
func (_u *UserUpdateOne) Mutation() *UserMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *UserUpdateOne) ClearGroup() *UserUpdateOne {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearAuthTokens clears all "auth_tokens" edges to the AuthTokens entity.
|
|
func (_u *UserUpdateOne) ClearAuthTokens() *UserUpdateOne {
|
|
_u.mutation.ClearAuthTokens()
|
|
return _u
|
|
}
|
|
|
|
// RemoveAuthTokenIDs removes the "auth_tokens" edge to AuthTokens entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveAuthTokenIDs(ids ...uuid.UUID) *UserUpdateOne {
|
|
_u.mutation.RemoveAuthTokenIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveAuthTokens removes "auth_tokens" edges to AuthTokens entities.
|
|
func (_u *UserUpdateOne) RemoveAuthTokens(v ...*AuthTokens) *UserUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveAuthTokenIDs(ids...)
|
|
}
|
|
|
|
// ClearNotifiers clears all "notifiers" edges to the Notifier entity.
|
|
func (_u *UserUpdateOne) ClearNotifiers() *UserUpdateOne {
|
|
_u.mutation.ClearNotifiers()
|
|
return _u
|
|
}
|
|
|
|
// RemoveNotifierIDs removes the "notifiers" edge to Notifier entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveNotifierIDs(ids ...uuid.UUID) *UserUpdateOne {
|
|
_u.mutation.RemoveNotifierIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveNotifiers removes "notifiers" edges to Notifier entities.
|
|
func (_u *UserUpdateOne) RemoveNotifiers(v ...*Notifier) *UserUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveNotifierIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the UserUpdate builder.
|
|
func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated User entity.
|
|
func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *UserUpdateOne) SaveX(ctx context.Context) *User {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *UserUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *UserUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *UserUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := user.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *UserUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := user.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Email(); ok {
|
|
if err := user.EmailValidator(v); err != nil {
|
|
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Password(); ok {
|
|
if err := user.PasswordValidator(v); err != nil {
|
|
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Role(); ok {
|
|
if err := user.RoleValidator(v); err != nil {
|
|
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "User.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, user.FieldID)
|
|
for _, f := range fields {
|
|
if !user.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != user.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(user.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Email(); ok {
|
|
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Password(); ok {
|
|
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
|
}
|
|
if _u.mutation.PasswordCleared() {
|
|
_spec.ClearField(user.FieldPassword, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.IsSuperuser(); ok {
|
|
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Superuser(); ok {
|
|
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Role(); ok {
|
|
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.ActivatedOn(); ok {
|
|
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.ActivatedOnCleared() {
|
|
_spec.ClearField(user.FieldActivatedOn, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.OidcIssuer(); ok {
|
|
_spec.SetField(user.FieldOidcIssuer, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OidcIssuerCleared() {
|
|
_spec.ClearField(user.FieldOidcIssuer, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.OidcSubject(); ok {
|
|
_spec.SetField(user.FieldOidcSubject, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OidcSubjectCleared() {
|
|
_spec.ClearField(user.FieldOidcSubject, field.TypeString)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: user.GroupTable,
|
|
Columns: []string{user.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: user.GroupTable,
|
|
Columns: []string{user.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.AuthTokensCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AuthTokensTable,
|
|
Columns: []string{user.AuthTokensColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedAuthTokensIDs(); len(nodes) > 0 && !_u.mutation.AuthTokensCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AuthTokensTable,
|
|
Columns: []string{user.AuthTokensColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AuthTokensIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AuthTokensTable,
|
|
Columns: []string{user.AuthTokensColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.NotifiersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.NotifiersTable,
|
|
Columns: []string{user.NotifiersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedNotifiersIDs(); len(nodes) > 0 && !_u.mutation.NotifiersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.NotifiersTable,
|
|
Columns: []string{user.NotifiersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.NotifiersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.NotifiersTable,
|
|
Columns: []string{user.NotifiersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &User{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{user.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|