MCPcopy
hub / github.com/Wei-Shaw/sub2api / sqlSave

Method sqlSave

backend/ent/account_update.go:1946–2337  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1944}
1945
1946func (_u *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err error) {
1947 if err := _u.check(); err != nil {
1948 return _node, err
1949 }
1950 _spec := sqlgraph.NewUpdateSpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
1951 id, ok := _u.mutation.ID()
1952 if !ok {
1953 return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Account.id" for update`)}
1954 }
1955 _spec.Node.ID.Value = id
1956 if fields := _u.fields; len(fields) > 0 {
1957 _spec.Node.Columns = make([]string, 0, len(fields))
1958 _spec.Node.Columns = append(_spec.Node.Columns, account.FieldID)
1959 for _, f := range fields {
1960 if !account.ValidColumn(f) {
1961 return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
1962 }
1963 if f != account.FieldID {
1964 _spec.Node.Columns = append(_spec.Node.Columns, f)
1965 }
1966 }
1967 }
1968 if ps := _u.mutation.predicates; len(ps) > 0 {
1969 _spec.Predicate = func(selector *sql.Selector) {
1970 for i := range ps {
1971 ps[i](selector)
1972 }
1973 }
1974 }
1975 if value, ok := _u.mutation.UpdatedAt(); ok {
1976 _spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
1977 }
1978 if value, ok := _u.mutation.DeletedAt(); ok {
1979 _spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
1980 }
1981 if _u.mutation.DeletedAtCleared() {
1982 _spec.ClearField(account.FieldDeletedAt, field.TypeTime)
1983 }
1984 if value, ok := _u.mutation.Name(); ok {
1985 _spec.SetField(account.FieldName, field.TypeString, value)
1986 }
1987 if value, ok := _u.mutation.Notes(); ok {
1988 _spec.SetField(account.FieldNotes, field.TypeString, value)
1989 }
1990 if _u.mutation.NotesCleared() {
1991 _spec.ClearField(account.FieldNotes, field.TypeString)
1992 }
1993 if value, ok := _u.mutation.Platform(); ok {
1994 _spec.SetField(account.FieldPlatform, field.TypeString, value)
1995 }
1996 if value, ok := _u.mutation.GetType(); ok {
1997 _spec.SetField(account.FieldType, field.TypeString, value)
1998 }
1999 if value, ok := _u.mutation.Credentials(); ok {
2000 _spec.SetField(account.FieldCredentials, field.TypeJSON, value)
2001 }
2002 if value, ok := _u.mutation.Extra(); ok {
2003 _spec.SetField(account.FieldExtra, field.TypeJSON, value)

Callers

nothing calls this directly

Calls 15

checkMethod · 0.95
defaultsMethod · 0.95
createSpecMethod · 0.95
newAccountGroupMutationFunction · 0.85
CredentialsMethod · 0.80
ExtraMethod · 0.80
ProxyFallbackOriginIDMethod · 0.80
LoadFactorMethod · 0.80
AddedLoadFactorMethod · 0.80
LoadFactorClearedMethod · 0.80

Tested by

no test coverage detected