| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447 |
- // 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/Wei-Shaw/sub2api/ent/errorpassthroughrule"
- )
- // ErrorPassthroughRuleCreate is the builder for creating a ErrorPassthroughRule entity.
- type ErrorPassthroughRuleCreate struct {
- config
- mutation *ErrorPassthroughRuleMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *ErrorPassthroughRuleCreate) SetCreatedAt(v time.Time) *ErrorPassthroughRuleCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableCreatedAt(v *time.Time) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_c *ErrorPassthroughRuleCreate) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleCreate {
- _c.mutation.SetUpdatedAt(v)
- return _c
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableUpdatedAt(v *time.Time) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetUpdatedAt(*v)
- }
- return _c
- }
- // SetName sets the "name" field.
- func (_c *ErrorPassthroughRuleCreate) SetName(v string) *ErrorPassthroughRuleCreate {
- _c.mutation.SetName(v)
- return _c
- }
- // SetEnabled sets the "enabled" field.
- func (_c *ErrorPassthroughRuleCreate) SetEnabled(v bool) *ErrorPassthroughRuleCreate {
- _c.mutation.SetEnabled(v)
- return _c
- }
- // SetNillableEnabled sets the "enabled" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableEnabled(v *bool) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetEnabled(*v)
- }
- return _c
- }
- // SetPriority sets the "priority" field.
- func (_c *ErrorPassthroughRuleCreate) SetPriority(v int) *ErrorPassthroughRuleCreate {
- _c.mutation.SetPriority(v)
- return _c
- }
- // SetNillablePriority sets the "priority" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillablePriority(v *int) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetPriority(*v)
- }
- return _c
- }
- // SetErrorCodes sets the "error_codes" field.
- func (_c *ErrorPassthroughRuleCreate) SetErrorCodes(v []int) *ErrorPassthroughRuleCreate {
- _c.mutation.SetErrorCodes(v)
- return _c
- }
- // SetKeywords sets the "keywords" field.
- func (_c *ErrorPassthroughRuleCreate) SetKeywords(v []string) *ErrorPassthroughRuleCreate {
- _c.mutation.SetKeywords(v)
- return _c
- }
- // SetMatchMode sets the "match_mode" field.
- func (_c *ErrorPassthroughRuleCreate) SetMatchMode(v string) *ErrorPassthroughRuleCreate {
- _c.mutation.SetMatchMode(v)
- return _c
- }
- // SetNillableMatchMode sets the "match_mode" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableMatchMode(v *string) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetMatchMode(*v)
- }
- return _c
- }
- // SetPlatforms sets the "platforms" field.
- func (_c *ErrorPassthroughRuleCreate) SetPlatforms(v []string) *ErrorPassthroughRuleCreate {
- _c.mutation.SetPlatforms(v)
- return _c
- }
- // SetPassthroughCode sets the "passthrough_code" field.
- func (_c *ErrorPassthroughRuleCreate) SetPassthroughCode(v bool) *ErrorPassthroughRuleCreate {
- _c.mutation.SetPassthroughCode(v)
- return _c
- }
- // SetNillablePassthroughCode sets the "passthrough_code" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillablePassthroughCode(v *bool) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetPassthroughCode(*v)
- }
- return _c
- }
- // SetResponseCode sets the "response_code" field.
- func (_c *ErrorPassthroughRuleCreate) SetResponseCode(v int) *ErrorPassthroughRuleCreate {
- _c.mutation.SetResponseCode(v)
- return _c
- }
- // SetNillableResponseCode sets the "response_code" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableResponseCode(v *int) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetResponseCode(*v)
- }
- return _c
- }
- // SetPassthroughBody sets the "passthrough_body" field.
- func (_c *ErrorPassthroughRuleCreate) SetPassthroughBody(v bool) *ErrorPassthroughRuleCreate {
- _c.mutation.SetPassthroughBody(v)
- return _c
- }
- // SetNillablePassthroughBody sets the "passthrough_body" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillablePassthroughBody(v *bool) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetPassthroughBody(*v)
- }
- return _c
- }
- // SetCustomMessage sets the "custom_message" field.
- func (_c *ErrorPassthroughRuleCreate) SetCustomMessage(v string) *ErrorPassthroughRuleCreate {
- _c.mutation.SetCustomMessage(v)
- return _c
- }
- // SetNillableCustomMessage sets the "custom_message" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableCustomMessage(v *string) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetCustomMessage(*v)
- }
- return _c
- }
- // SetSkipMonitoring sets the "skip_monitoring" field.
- func (_c *ErrorPassthroughRuleCreate) SetSkipMonitoring(v bool) *ErrorPassthroughRuleCreate {
- _c.mutation.SetSkipMonitoring(v)
- return _c
- }
- // SetNillableSkipMonitoring sets the "skip_monitoring" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableSkipMonitoring(v *bool) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetSkipMonitoring(*v)
- }
- return _c
- }
- // SetDescription sets the "description" field.
- func (_c *ErrorPassthroughRuleCreate) SetDescription(v string) *ErrorPassthroughRuleCreate {
- _c.mutation.SetDescription(v)
- return _c
- }
- // SetNillableDescription sets the "description" field if the given value is not nil.
- func (_c *ErrorPassthroughRuleCreate) SetNillableDescription(v *string) *ErrorPassthroughRuleCreate {
- if v != nil {
- _c.SetDescription(*v)
- }
- return _c
- }
- // Mutation returns the ErrorPassthroughRuleMutation object of the builder.
- func (_c *ErrorPassthroughRuleCreate) Mutation() *ErrorPassthroughRuleMutation {
- return _c.mutation
- }
- // Save creates the ErrorPassthroughRule in the database.
- func (_c *ErrorPassthroughRuleCreate) Save(ctx context.Context) (*ErrorPassthroughRule, error) {
- _c.defaults()
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *ErrorPassthroughRuleCreate) SaveX(ctx context.Context) *ErrorPassthroughRule {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ErrorPassthroughRuleCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ErrorPassthroughRuleCreate) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_c *ErrorPassthroughRuleCreate) defaults() {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- v := errorpassthroughrule.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- v := errorpassthroughrule.DefaultUpdatedAt()
- _c.mutation.SetUpdatedAt(v)
- }
- if _, ok := _c.mutation.Enabled(); !ok {
- v := errorpassthroughrule.DefaultEnabled
- _c.mutation.SetEnabled(v)
- }
- if _, ok := _c.mutation.Priority(); !ok {
- v := errorpassthroughrule.DefaultPriority
- _c.mutation.SetPriority(v)
- }
- if _, ok := _c.mutation.MatchMode(); !ok {
- v := errorpassthroughrule.DefaultMatchMode
- _c.mutation.SetMatchMode(v)
- }
- if _, ok := _c.mutation.PassthroughCode(); !ok {
- v := errorpassthroughrule.DefaultPassthroughCode
- _c.mutation.SetPassthroughCode(v)
- }
- if _, ok := _c.mutation.PassthroughBody(); !ok {
- v := errorpassthroughrule.DefaultPassthroughBody
- _c.mutation.SetPassthroughBody(v)
- }
- if _, ok := _c.mutation.SkipMonitoring(); !ok {
- v := errorpassthroughrule.DefaultSkipMonitoring
- _c.mutation.SetSkipMonitoring(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *ErrorPassthroughRuleCreate) check() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ErrorPassthroughRule.created_at"`)}
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ErrorPassthroughRule.updated_at"`)}
- }
- if _, ok := _c.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ErrorPassthroughRule.name"`)}
- }
- if v, ok := _c.mutation.Name(); ok {
- if err := errorpassthroughrule.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ErrorPassthroughRule.name": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Enabled(); !ok {
- return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "ErrorPassthroughRule.enabled"`)}
- }
- if _, ok := _c.mutation.Priority(); !ok {
- return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "ErrorPassthroughRule.priority"`)}
- }
- if _, ok := _c.mutation.MatchMode(); !ok {
- return &ValidationError{Name: "match_mode", err: errors.New(`ent: missing required field "ErrorPassthroughRule.match_mode"`)}
- }
- if v, ok := _c.mutation.MatchMode(); ok {
- if err := errorpassthroughrule.MatchModeValidator(v); err != nil {
- return &ValidationError{Name: "match_mode", err: fmt.Errorf(`ent: validator failed for field "ErrorPassthroughRule.match_mode": %w`, err)}
- }
- }
- if _, ok := _c.mutation.PassthroughCode(); !ok {
- return &ValidationError{Name: "passthrough_code", err: errors.New(`ent: missing required field "ErrorPassthroughRule.passthrough_code"`)}
- }
- if _, ok := _c.mutation.PassthroughBody(); !ok {
- return &ValidationError{Name: "passthrough_body", err: errors.New(`ent: missing required field "ErrorPassthroughRule.passthrough_body"`)}
- }
- if _, ok := _c.mutation.SkipMonitoring(); !ok {
- return &ValidationError{Name: "skip_monitoring", err: errors.New(`ent: missing required field "ErrorPassthroughRule.skip_monitoring"`)}
- }
- return nil
- }
- func (_c *ErrorPassthroughRuleCreate) sqlSave(ctx context.Context) (*ErrorPassthroughRule, error) {
- if err := _c.check(); err != nil {
- return nil, err
- }
- _node, _spec := _c.createSpec()
- if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- id := _spec.ID.Value.(int64)
- _node.ID = int64(id)
- _c.mutation.id = &_node.ID
- _c.mutation.done = true
- return _node, nil
- }
- func (_c *ErrorPassthroughRuleCreate) createSpec() (*ErrorPassthroughRule, *sqlgraph.CreateSpec) {
- var (
- _node = &ErrorPassthroughRule{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(errorpassthroughrule.Table, sqlgraph.NewFieldSpec(errorpassthroughrule.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(errorpassthroughrule.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := _c.mutation.UpdatedAt(); ok {
- _spec.SetField(errorpassthroughrule.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := _c.mutation.Name(); ok {
- _spec.SetField(errorpassthroughrule.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := _c.mutation.Enabled(); ok {
- _spec.SetField(errorpassthroughrule.FieldEnabled, field.TypeBool, value)
- _node.Enabled = value
- }
- if value, ok := _c.mutation.Priority(); ok {
- _spec.SetField(errorpassthroughrule.FieldPriority, field.TypeInt, value)
- _node.Priority = value
- }
- if value, ok := _c.mutation.ErrorCodes(); ok {
- _spec.SetField(errorpassthroughrule.FieldErrorCodes, field.TypeJSON, value)
- _node.ErrorCodes = value
- }
- if value, ok := _c.mutation.Keywords(); ok {
- _spec.SetField(errorpassthroughrule.FieldKeywords, field.TypeJSON, value)
- _node.Keywords = value
- }
- if value, ok := _c.mutation.MatchMode(); ok {
- _spec.SetField(errorpassthroughrule.FieldMatchMode, field.TypeString, value)
- _node.MatchMode = value
- }
- if value, ok := _c.mutation.Platforms(); ok {
- _spec.SetField(errorpassthroughrule.FieldPlatforms, field.TypeJSON, value)
- _node.Platforms = value
- }
- if value, ok := _c.mutation.PassthroughCode(); ok {
- _spec.SetField(errorpassthroughrule.FieldPassthroughCode, field.TypeBool, value)
- _node.PassthroughCode = value
- }
- if value, ok := _c.mutation.ResponseCode(); ok {
- _spec.SetField(errorpassthroughrule.FieldResponseCode, field.TypeInt, value)
- _node.ResponseCode = &value
- }
- if value, ok := _c.mutation.PassthroughBody(); ok {
- _spec.SetField(errorpassthroughrule.FieldPassthroughBody, field.TypeBool, value)
- _node.PassthroughBody = value
- }
- if value, ok := _c.mutation.CustomMessage(); ok {
- _spec.SetField(errorpassthroughrule.FieldCustomMessage, field.TypeString, value)
- _node.CustomMessage = &value
- }
- if value, ok := _c.mutation.SkipMonitoring(); ok {
- _spec.SetField(errorpassthroughrule.FieldSkipMonitoring, field.TypeBool, value)
- _node.SkipMonitoring = value
- }
- if value, ok := _c.mutation.Description(); ok {
- _spec.SetField(errorpassthroughrule.FieldDescription, field.TypeString, value)
- _node.Description = &value
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.ErrorPassthroughRule.Create().
- // SetCreatedAt(v).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.ErrorPassthroughRuleUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *ErrorPassthroughRuleCreate) OnConflict(opts ...sql.ConflictOption) *ErrorPassthroughRuleUpsertOne {
- _c.conflict = opts
- return &ErrorPassthroughRuleUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ErrorPassthroughRule.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ErrorPassthroughRuleCreate) OnConflictColumns(columns ...string) *ErrorPassthroughRuleUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ErrorPassthroughRuleUpsertOne{
- create: _c,
- }
- }
- type (
- // ErrorPassthroughRuleUpsertOne is the builder for "upsert"-ing
- // one ErrorPassthroughRule node.
- ErrorPassthroughRuleUpsertOne struct {
- create *ErrorPassthroughRuleCreate
- }
- // ErrorPassthroughRuleUpsert is the "OnConflict" setter.
- ErrorPassthroughRuleUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ErrorPassthroughRuleUpsert) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateUpdatedAt() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldUpdatedAt)
- return u
- }
- // SetName sets the "name" field.
- func (u *ErrorPassthroughRuleUpsert) SetName(v string) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateName() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldName)
- return u
- }
- // SetEnabled sets the "enabled" field.
- func (u *ErrorPassthroughRuleUpsert) SetEnabled(v bool) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldEnabled, v)
- return u
- }
- // UpdateEnabled sets the "enabled" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateEnabled() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldEnabled)
- return u
- }
- // SetPriority sets the "priority" field.
- func (u *ErrorPassthroughRuleUpsert) SetPriority(v int) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldPriority, v)
- return u
- }
- // UpdatePriority sets the "priority" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdatePriority() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldPriority)
- return u
- }
- // AddPriority adds v to the "priority" field.
- func (u *ErrorPassthroughRuleUpsert) AddPriority(v int) *ErrorPassthroughRuleUpsert {
- u.Add(errorpassthroughrule.FieldPriority, v)
- return u
- }
- // SetErrorCodes sets the "error_codes" field.
- func (u *ErrorPassthroughRuleUpsert) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldErrorCodes, v)
- return u
- }
- // UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateErrorCodes() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldErrorCodes)
- return u
- }
- // ClearErrorCodes clears the value of the "error_codes" field.
- func (u *ErrorPassthroughRuleUpsert) ClearErrorCodes() *ErrorPassthroughRuleUpsert {
- u.SetNull(errorpassthroughrule.FieldErrorCodes)
- return u
- }
- // SetKeywords sets the "keywords" field.
- func (u *ErrorPassthroughRuleUpsert) SetKeywords(v []string) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldKeywords, v)
- return u
- }
- // UpdateKeywords sets the "keywords" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateKeywords() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldKeywords)
- return u
- }
- // ClearKeywords clears the value of the "keywords" field.
- func (u *ErrorPassthroughRuleUpsert) ClearKeywords() *ErrorPassthroughRuleUpsert {
- u.SetNull(errorpassthroughrule.FieldKeywords)
- return u
- }
- // SetMatchMode sets the "match_mode" field.
- func (u *ErrorPassthroughRuleUpsert) SetMatchMode(v string) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldMatchMode, v)
- return u
- }
- // UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateMatchMode() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldMatchMode)
- return u
- }
- // SetPlatforms sets the "platforms" field.
- func (u *ErrorPassthroughRuleUpsert) SetPlatforms(v []string) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldPlatforms, v)
- return u
- }
- // UpdatePlatforms sets the "platforms" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdatePlatforms() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldPlatforms)
- return u
- }
- // ClearPlatforms clears the value of the "platforms" field.
- func (u *ErrorPassthroughRuleUpsert) ClearPlatforms() *ErrorPassthroughRuleUpsert {
- u.SetNull(errorpassthroughrule.FieldPlatforms)
- return u
- }
- // SetPassthroughCode sets the "passthrough_code" field.
- func (u *ErrorPassthroughRuleUpsert) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldPassthroughCode, v)
- return u
- }
- // UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdatePassthroughCode() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldPassthroughCode)
- return u
- }
- // SetResponseCode sets the "response_code" field.
- func (u *ErrorPassthroughRuleUpsert) SetResponseCode(v int) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldResponseCode, v)
- return u
- }
- // UpdateResponseCode sets the "response_code" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateResponseCode() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldResponseCode)
- return u
- }
- // AddResponseCode adds v to the "response_code" field.
- func (u *ErrorPassthroughRuleUpsert) AddResponseCode(v int) *ErrorPassthroughRuleUpsert {
- u.Add(errorpassthroughrule.FieldResponseCode, v)
- return u
- }
- // ClearResponseCode clears the value of the "response_code" field.
- func (u *ErrorPassthroughRuleUpsert) ClearResponseCode() *ErrorPassthroughRuleUpsert {
- u.SetNull(errorpassthroughrule.FieldResponseCode)
- return u
- }
- // SetPassthroughBody sets the "passthrough_body" field.
- func (u *ErrorPassthroughRuleUpsert) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldPassthroughBody, v)
- return u
- }
- // UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdatePassthroughBody() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldPassthroughBody)
- return u
- }
- // SetCustomMessage sets the "custom_message" field.
- func (u *ErrorPassthroughRuleUpsert) SetCustomMessage(v string) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldCustomMessage, v)
- return u
- }
- // UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateCustomMessage() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldCustomMessage)
- return u
- }
- // ClearCustomMessage clears the value of the "custom_message" field.
- func (u *ErrorPassthroughRuleUpsert) ClearCustomMessage() *ErrorPassthroughRuleUpsert {
- u.SetNull(errorpassthroughrule.FieldCustomMessage)
- return u
- }
- // SetSkipMonitoring sets the "skip_monitoring" field.
- func (u *ErrorPassthroughRuleUpsert) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldSkipMonitoring, v)
- return u
- }
- // UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldSkipMonitoring)
- return u
- }
- // SetDescription sets the "description" field.
- func (u *ErrorPassthroughRuleUpsert) SetDescription(v string) *ErrorPassthroughRuleUpsert {
- u.Set(errorpassthroughrule.FieldDescription, v)
- return u
- }
- // UpdateDescription sets the "description" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsert) UpdateDescription() *ErrorPassthroughRuleUpsert {
- u.SetExcluded(errorpassthroughrule.FieldDescription)
- return u
- }
- // ClearDescription clears the value of the "description" field.
- func (u *ErrorPassthroughRuleUpsert) ClearDescription() *ErrorPassthroughRuleUpsert {
- u.SetNull(errorpassthroughrule.FieldDescription)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.ErrorPassthroughRule.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ErrorPassthroughRuleUpsertOne) UpdateNewValues() *ErrorPassthroughRuleUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(errorpassthroughrule.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ErrorPassthroughRule.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ErrorPassthroughRuleUpsertOne) Ignore() *ErrorPassthroughRuleUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *ErrorPassthroughRuleUpsertOne) DoNothing() *ErrorPassthroughRuleUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreate.OnConflict
- // documentation for more info.
- func (u *ErrorPassthroughRuleUpsertOne) Update(set func(*ErrorPassthroughRuleUpsert)) *ErrorPassthroughRuleUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ErrorPassthroughRuleUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateUpdatedAt() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetName(v string) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateName() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateName()
- })
- }
- // SetEnabled sets the "enabled" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetEnabled(v bool) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetEnabled(v)
- })
- }
- // UpdateEnabled sets the "enabled" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateEnabled() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateEnabled()
- })
- }
- // SetPriority sets the "priority" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetPriority(v int) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPriority(v)
- })
- }
- // AddPriority adds v to the "priority" field.
- func (u *ErrorPassthroughRuleUpsertOne) AddPriority(v int) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.AddPriority(v)
- })
- }
- // UpdatePriority sets the "priority" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdatePriority() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePriority()
- })
- }
- // SetErrorCodes sets the "error_codes" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetErrorCodes(v)
- })
- }
- // UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateErrorCodes() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateErrorCodes()
- })
- }
- // ClearErrorCodes clears the value of the "error_codes" field.
- func (u *ErrorPassthroughRuleUpsertOne) ClearErrorCodes() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearErrorCodes()
- })
- }
- // SetKeywords sets the "keywords" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetKeywords(v []string) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetKeywords(v)
- })
- }
- // UpdateKeywords sets the "keywords" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateKeywords() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateKeywords()
- })
- }
- // ClearKeywords clears the value of the "keywords" field.
- func (u *ErrorPassthroughRuleUpsertOne) ClearKeywords() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearKeywords()
- })
- }
- // SetMatchMode sets the "match_mode" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetMatchMode(v string) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetMatchMode(v)
- })
- }
- // UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateMatchMode() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateMatchMode()
- })
- }
- // SetPlatforms sets the "platforms" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetPlatforms(v []string) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPlatforms(v)
- })
- }
- // UpdatePlatforms sets the "platforms" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdatePlatforms() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePlatforms()
- })
- }
- // ClearPlatforms clears the value of the "platforms" field.
- func (u *ErrorPassthroughRuleUpsertOne) ClearPlatforms() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearPlatforms()
- })
- }
- // SetPassthroughCode sets the "passthrough_code" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPassthroughCode(v)
- })
- }
- // UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdatePassthroughCode() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePassthroughCode()
- })
- }
- // SetResponseCode sets the "response_code" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetResponseCode(v int) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetResponseCode(v)
- })
- }
- // AddResponseCode adds v to the "response_code" field.
- func (u *ErrorPassthroughRuleUpsertOne) AddResponseCode(v int) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.AddResponseCode(v)
- })
- }
- // UpdateResponseCode sets the "response_code" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateResponseCode() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateResponseCode()
- })
- }
- // ClearResponseCode clears the value of the "response_code" field.
- func (u *ErrorPassthroughRuleUpsertOne) ClearResponseCode() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearResponseCode()
- })
- }
- // SetPassthroughBody sets the "passthrough_body" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPassthroughBody(v)
- })
- }
- // UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdatePassthroughBody() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePassthroughBody()
- })
- }
- // SetCustomMessage sets the "custom_message" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetCustomMessage(v string) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetCustomMessage(v)
- })
- }
- // UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateCustomMessage() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateCustomMessage()
- })
- }
- // ClearCustomMessage clears the value of the "custom_message" field.
- func (u *ErrorPassthroughRuleUpsertOne) ClearCustomMessage() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearCustomMessage()
- })
- }
- // SetSkipMonitoring sets the "skip_monitoring" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetSkipMonitoring(v)
- })
- }
- // UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateSkipMonitoring()
- })
- }
- // SetDescription sets the "description" field.
- func (u *ErrorPassthroughRuleUpsertOne) SetDescription(v string) *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetDescription(v)
- })
- }
- // UpdateDescription sets the "description" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertOne) UpdateDescription() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateDescription()
- })
- }
- // ClearDescription clears the value of the "description" field.
- func (u *ErrorPassthroughRuleUpsertOne) ClearDescription() *ErrorPassthroughRuleUpsertOne {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearDescription()
- })
- }
- // Exec executes the query.
- func (u *ErrorPassthroughRuleUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ErrorPassthroughRuleCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ErrorPassthroughRuleUpsertOne) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // Exec executes the UPSERT query and returns the inserted/updated ID.
- func (u *ErrorPassthroughRuleUpsertOne) ID(ctx context.Context) (id int64, err error) {
- node, err := u.create.Save(ctx)
- if err != nil {
- return id, err
- }
- return node.ID, nil
- }
- // IDX is like ID, but panics if an error occurs.
- func (u *ErrorPassthroughRuleUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // ErrorPassthroughRuleCreateBulk is the builder for creating many ErrorPassthroughRule entities in bulk.
- type ErrorPassthroughRuleCreateBulk struct {
- config
- err error
- builders []*ErrorPassthroughRuleCreate
- conflict []sql.ConflictOption
- }
- // Save creates the ErrorPassthroughRule entities in the database.
- func (_c *ErrorPassthroughRuleCreateBulk) Save(ctx context.Context) ([]*ErrorPassthroughRule, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*ErrorPassthroughRule, len(_c.builders))
- mutators := make([]Mutator, len(_c.builders))
- for i := range _c.builders {
- func(i int, root context.Context) {
- builder := _c.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*ErrorPassthroughRuleMutation)
- if !ok {
- return nil, fmt.Errorf("unexpected mutation type %T", m)
- }
- if err := builder.check(); err != nil {
- return nil, err
- }
- builder.mutation = mutation
- var err error
- nodes[i], specs[i] = builder.createSpec()
- if i < len(mutators)-1 {
- _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = _c.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- }
- }
- if err != nil {
- return nil, err
- }
- mutation.id = &nodes[i].ID
- if specs[i].ID.Value != nil {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = int64(id)
- }
- mutation.done = true
- return nodes[i], nil
- })
- for i := len(builder.hooks) - 1; i >= 0; i-- {
- mut = builder.hooks[i](mut)
- }
- mutators[i] = mut
- }(i, ctx)
- }
- if len(mutators) > 0 {
- if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_c *ErrorPassthroughRuleCreateBulk) SaveX(ctx context.Context) []*ErrorPassthroughRule {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ErrorPassthroughRuleCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ErrorPassthroughRuleCreateBulk) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.ErrorPassthroughRule.CreateBulk(builders...).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.ErrorPassthroughRuleUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *ErrorPassthroughRuleCreateBulk) OnConflict(opts ...sql.ConflictOption) *ErrorPassthroughRuleUpsertBulk {
- _c.conflict = opts
- return &ErrorPassthroughRuleUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ErrorPassthroughRule.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ErrorPassthroughRuleCreateBulk) OnConflictColumns(columns ...string) *ErrorPassthroughRuleUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ErrorPassthroughRuleUpsertBulk{
- create: _c,
- }
- }
- // ErrorPassthroughRuleUpsertBulk is the builder for "upsert"-ing
- // a bulk of ErrorPassthroughRule nodes.
- type ErrorPassthroughRuleUpsertBulk struct {
- create *ErrorPassthroughRuleCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.ErrorPassthroughRule.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateNewValues() *ErrorPassthroughRuleUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- for _, b := range u.create.builders {
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(errorpassthroughrule.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ErrorPassthroughRule.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ErrorPassthroughRuleUpsertBulk) Ignore() *ErrorPassthroughRuleUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *ErrorPassthroughRuleUpsertBulk) DoNothing() *ErrorPassthroughRuleUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreateBulk.OnConflict
- // documentation for more info.
- func (u *ErrorPassthroughRuleUpsertBulk) Update(set func(*ErrorPassthroughRuleUpsert)) *ErrorPassthroughRuleUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ErrorPassthroughRuleUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateUpdatedAt() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetName(v string) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateName() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateName()
- })
- }
- // SetEnabled sets the "enabled" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetEnabled(v bool) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetEnabled(v)
- })
- }
- // UpdateEnabled sets the "enabled" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateEnabled() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateEnabled()
- })
- }
- // SetPriority sets the "priority" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetPriority(v int) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPriority(v)
- })
- }
- // AddPriority adds v to the "priority" field.
- func (u *ErrorPassthroughRuleUpsertBulk) AddPriority(v int) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.AddPriority(v)
- })
- }
- // UpdatePriority sets the "priority" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdatePriority() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePriority()
- })
- }
- // SetErrorCodes sets the "error_codes" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetErrorCodes(v)
- })
- }
- // UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateErrorCodes() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateErrorCodes()
- })
- }
- // ClearErrorCodes clears the value of the "error_codes" field.
- func (u *ErrorPassthroughRuleUpsertBulk) ClearErrorCodes() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearErrorCodes()
- })
- }
- // SetKeywords sets the "keywords" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetKeywords(v []string) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetKeywords(v)
- })
- }
- // UpdateKeywords sets the "keywords" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateKeywords() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateKeywords()
- })
- }
- // ClearKeywords clears the value of the "keywords" field.
- func (u *ErrorPassthroughRuleUpsertBulk) ClearKeywords() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearKeywords()
- })
- }
- // SetMatchMode sets the "match_mode" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetMatchMode(v string) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetMatchMode(v)
- })
- }
- // UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateMatchMode() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateMatchMode()
- })
- }
- // SetPlatforms sets the "platforms" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetPlatforms(v []string) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPlatforms(v)
- })
- }
- // UpdatePlatforms sets the "platforms" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdatePlatforms() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePlatforms()
- })
- }
- // ClearPlatforms clears the value of the "platforms" field.
- func (u *ErrorPassthroughRuleUpsertBulk) ClearPlatforms() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearPlatforms()
- })
- }
- // SetPassthroughCode sets the "passthrough_code" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPassthroughCode(v)
- })
- }
- // UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdatePassthroughCode() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePassthroughCode()
- })
- }
- // SetResponseCode sets the "response_code" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetResponseCode(v int) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetResponseCode(v)
- })
- }
- // AddResponseCode adds v to the "response_code" field.
- func (u *ErrorPassthroughRuleUpsertBulk) AddResponseCode(v int) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.AddResponseCode(v)
- })
- }
- // UpdateResponseCode sets the "response_code" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateResponseCode() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateResponseCode()
- })
- }
- // ClearResponseCode clears the value of the "response_code" field.
- func (u *ErrorPassthroughRuleUpsertBulk) ClearResponseCode() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearResponseCode()
- })
- }
- // SetPassthroughBody sets the "passthrough_body" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetPassthroughBody(v)
- })
- }
- // UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdatePassthroughBody() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdatePassthroughBody()
- })
- }
- // SetCustomMessage sets the "custom_message" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetCustomMessage(v string) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetCustomMessage(v)
- })
- }
- // UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateCustomMessage() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateCustomMessage()
- })
- }
- // ClearCustomMessage clears the value of the "custom_message" field.
- func (u *ErrorPassthroughRuleUpsertBulk) ClearCustomMessage() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearCustomMessage()
- })
- }
- // SetSkipMonitoring sets the "skip_monitoring" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetSkipMonitoring(v)
- })
- }
- // UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateSkipMonitoring()
- })
- }
- // SetDescription sets the "description" field.
- func (u *ErrorPassthroughRuleUpsertBulk) SetDescription(v string) *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.SetDescription(v)
- })
- }
- // UpdateDescription sets the "description" field to the value that was provided on create.
- func (u *ErrorPassthroughRuleUpsertBulk) UpdateDescription() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.UpdateDescription()
- })
- }
- // ClearDescription clears the value of the "description" field.
- func (u *ErrorPassthroughRuleUpsertBulk) ClearDescription() *ErrorPassthroughRuleUpsertBulk {
- return u.Update(func(s *ErrorPassthroughRuleUpsert) {
- s.ClearDescription()
- })
- }
- // Exec executes the query.
- func (u *ErrorPassthroughRuleUpsertBulk) Exec(ctx context.Context) error {
- if u.create.err != nil {
- return u.create.err
- }
- for i, b := range u.create.builders {
- if len(b.conflict) != 0 {
- return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ErrorPassthroughRuleCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ErrorPassthroughRuleCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ErrorPassthroughRuleUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|