// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/safedep/vet/ent/codesignaturematch"
"github.com/safedep/vet/ent/codesourcefile"
"github.com/safedep/vet/ent/predicate"
)
// CodeSignatureMatchUpdate is the builder for updating CodeSignatureMatch entities.
type CodeSignatureMatchUpdate struct {
config
hooks []Hook
mutation *CodeSignatureMatchMutation
}
// Where appends a list predicates to the CodeSignatureMatchUpdate builder.
func (csmu *CodeSignatureMatchUpdate) Where(ps ...predicate.CodeSignatureMatch) *CodeSignatureMatchUpdate {
csmu.mutation.Where(ps...)
return csmu
}
// SetSignatureID sets the "signature_id" field.
func (csmu *CodeSignatureMatchUpdate) SetSignatureID(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetSignatureID(s)
return csmu
}
// SetNillableSignatureID sets the "signature_id" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableSignatureID(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetSignatureID(*s)
}
return csmu
}
// SetSignatureVendor sets the "signature_vendor" field.
func (csmu *CodeSignatureMatchUpdate) SetSignatureVendor(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetSignatureVendor(s)
return csmu
}
// SetNillableSignatureVendor sets the "signature_vendor" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableSignatureVendor(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetSignatureVendor(*s)
}
return csmu
}
// ClearSignatureVendor clears the value of the "signature_vendor" field.
func (csmu *CodeSignatureMatchUpdate) ClearSignatureVendor() *CodeSignatureMatchUpdate {
csmu.mutation.ClearSignatureVendor()
return csmu
}
// SetSignatureProduct sets the "signature_product" field.
func (csmu *CodeSignatureMatchUpdate) SetSignatureProduct(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetSignatureProduct(s)
return csmu
}
// SetNillableSignatureProduct sets the "signature_product" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableSignatureProduct(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetSignatureProduct(*s)
}
return csmu
}
// ClearSignatureProduct clears the value of the "signature_product" field.
func (csmu *CodeSignatureMatchUpdate) ClearSignatureProduct() *CodeSignatureMatchUpdate {
csmu.mutation.ClearSignatureProduct()
return csmu
}
// SetSignatureService sets the "signature_service" field.
func (csmu *CodeSignatureMatchUpdate) SetSignatureService(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetSignatureService(s)
return csmu
}
// SetNillableSignatureService sets the "signature_service" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableSignatureService(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetSignatureService(*s)
}
return csmu
}
// ClearSignatureService clears the value of the "signature_service" field.
func (csmu *CodeSignatureMatchUpdate) ClearSignatureService() *CodeSignatureMatchUpdate {
csmu.mutation.ClearSignatureService()
return csmu
}
// SetSignatureDescription sets the "signature_description" field.
func (csmu *CodeSignatureMatchUpdate) SetSignatureDescription(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetSignatureDescription(s)
return csmu
}
// SetNillableSignatureDescription sets the "signature_description" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableSignatureDescription(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetSignatureDescription(*s)
}
return csmu
}
// ClearSignatureDescription clears the value of the "signature_description" field.
func (csmu *CodeSignatureMatchUpdate) ClearSignatureDescription() *CodeSignatureMatchUpdate {
csmu.mutation.ClearSignatureDescription()
return csmu
}
// SetTags sets the "tags" field.
func (csmu *CodeSignatureMatchUpdate) SetTags(s []string) *CodeSignatureMatchUpdate {
csmu.mutation.SetTags(s)
return csmu
}
// AppendTags appends s to the "tags" field.
func (csmu *CodeSignatureMatchUpdate) AppendTags(s []string) *CodeSignatureMatchUpdate {
csmu.mutation.AppendTags(s)
return csmu
}
// ClearTags clears the value of the "tags" field.
func (csmu *CodeSignatureMatchUpdate) ClearTags() *CodeSignatureMatchUpdate {
csmu.mutation.ClearTags()
return csmu
}
// SetFilePath sets the "file_path" field.
func (csmu *CodeSignatureMatchUpdate) SetFilePath(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetFilePath(s)
return csmu
}
// SetNillableFilePath sets the "file_path" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableFilePath(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetFilePath(*s)
}
return csmu
}
// SetLanguage sets the "language" field.
func (csmu *CodeSignatureMatchUpdate) SetLanguage(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetLanguage(s)
return csmu
}
// SetNillableLanguage sets the "language" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableLanguage(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetLanguage(*s)
}
return csmu
}
// SetLine sets the "line" field.
func (csmu *CodeSignatureMatchUpdate) SetLine(u uint) *CodeSignatureMatchUpdate {
csmu.mutation.ResetLine()
csmu.mutation.SetLine(u)
return csmu
}
// SetNillableLine sets the "line" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableLine(u *uint) *CodeSignatureMatchUpdate {
if u != nil {
csmu.SetLine(*u)
}
return csmu
}
// AddLine adds u to the "line" field.
func (csmu *CodeSignatureMatchUpdate) AddLine(u int) *CodeSignatureMatchUpdate {
csmu.mutation.AddLine(u)
return csmu
}
// ClearLine clears the value of the "line" field.
func (csmu *CodeSignatureMatchUpdate) ClearLine() *CodeSignatureMatchUpdate {
csmu.mutation.ClearLine()
return csmu
}
// SetColumn sets the "column" field.
func (csmu *CodeSignatureMatchUpdate) SetColumn(u uint) *CodeSignatureMatchUpdate {
csmu.mutation.ResetColumn()
csmu.mutation.SetColumn(u)
return csmu
}
// SetNillableColumn sets the "column" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableColumn(u *uint) *CodeSignatureMatchUpdate {
if u != nil {
csmu.SetColumn(*u)
}
return csmu
}
// AddColumn adds u to the "column" field.
func (csmu *CodeSignatureMatchUpdate) AddColumn(u int) *CodeSignatureMatchUpdate {
csmu.mutation.AddColumn(u)
return csmu
}
// ClearColumn clears the value of the "column" field.
func (csmu *CodeSignatureMatchUpdate) ClearColumn() *CodeSignatureMatchUpdate {
csmu.mutation.ClearColumn()
return csmu
}
// SetCalleeNamespace sets the "callee_namespace" field.
func (csmu *CodeSignatureMatchUpdate) SetCalleeNamespace(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetCalleeNamespace(s)
return csmu
}
// SetNillableCalleeNamespace sets the "callee_namespace" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableCalleeNamespace(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetCalleeNamespace(*s)
}
return csmu
}
// ClearCalleeNamespace clears the value of the "callee_namespace" field.
func (csmu *CodeSignatureMatchUpdate) ClearCalleeNamespace() *CodeSignatureMatchUpdate {
csmu.mutation.ClearCalleeNamespace()
return csmu
}
// SetMatchedCall sets the "matched_call" field.
func (csmu *CodeSignatureMatchUpdate) SetMatchedCall(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetMatchedCall(s)
return csmu
}
// SetNillableMatchedCall sets the "matched_call" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillableMatchedCall(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetMatchedCall(*s)
}
return csmu
}
// ClearMatchedCall clears the value of the "matched_call" field.
func (csmu *CodeSignatureMatchUpdate) ClearMatchedCall() *CodeSignatureMatchUpdate {
csmu.mutation.ClearMatchedCall()
return csmu
}
// SetPackageHint sets the "package_hint" field.
func (csmu *CodeSignatureMatchUpdate) SetPackageHint(s string) *CodeSignatureMatchUpdate {
csmu.mutation.SetPackageHint(s)
return csmu
}
// SetNillablePackageHint sets the "package_hint" field if the given value is not nil.
func (csmu *CodeSignatureMatchUpdate) SetNillablePackageHint(s *string) *CodeSignatureMatchUpdate {
if s != nil {
csmu.SetPackageHint(*s)
}
return csmu
}
// ClearPackageHint clears the value of the "package_hint" field.
func (csmu *CodeSignatureMatchUpdate) ClearPackageHint() *CodeSignatureMatchUpdate {
csmu.mutation.ClearPackageHint()
return csmu
}
// SetSourceFileID sets the "source_file" edge to the CodeSourceFile entity by ID.
func (csmu *CodeSignatureMatchUpdate) SetSourceFileID(id int) *CodeSignatureMatchUpdate {
csmu.mutation.SetSourceFileID(id)
return csmu
}
// SetSourceFile sets the "source_file" edge to the CodeSourceFile entity.
func (csmu *CodeSignatureMatchUpdate) SetSourceFile(c *CodeSourceFile) *CodeSignatureMatchUpdate {
return csmu.SetSourceFileID(c.ID)
}
// Mutation returns the CodeSignatureMatchMutation object of the builder.
func (csmu *CodeSignatureMatchUpdate) Mutation() *CodeSignatureMatchMutation {
return csmu.mutation
}
// ClearSourceFile clears the "source_file" edge to the CodeSourceFile entity.
func (csmu *CodeSignatureMatchUpdate) ClearSourceFile() *CodeSignatureMatchUpdate {
csmu.mutation.ClearSourceFile()
return csmu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (csmu *CodeSignatureMatchUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, csmu.sqlSave, csmu.mutation, csmu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (csmu *CodeSignatureMatchUpdate) SaveX(ctx context.Context) int {
affected, err := csmu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (csmu *CodeSignatureMatchUpdate) Exec(ctx context.Context) error {
_, err := csmu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (csmu *CodeSignatureMatchUpdate) ExecX(ctx context.Context) {
if err := csmu.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (csmu *CodeSignatureMatchUpdate) check() error {
if v, ok := csmu.mutation.SignatureID(); ok {
if err := codesignaturematch.SignatureIDValidator(v); err != nil {
return &ValidationError{Name: "signature_id", err: fmt.Errorf(`ent: validator failed for field "CodeSignatureMatch.signature_id": %w`, err)}
}
}
if v, ok := csmu.mutation.FilePath(); ok {
if err := codesignaturematch.FilePathValidator(v); err != nil {
return &ValidationError{Name: "file_path", err: fmt.Errorf(`ent: validator failed for field "CodeSignatureMatch.file_path": %w`, err)}
}
}
if v, ok := csmu.mutation.Language(); ok {
if err := codesignaturematch.LanguageValidator(v); err != nil {
return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "CodeSignatureMatch.language": %w`, err)}
}
}
if csmu.mutation.SourceFileCleared() && len(csmu.mutation.SourceFileIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CodeSignatureMatch.source_file"`)
}
return nil
}
func (csmu *CodeSignatureMatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := csmu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(codesignaturematch.Table, codesignaturematch.Columns, sqlgraph.NewFieldSpec(codesignaturematch.FieldID, field.TypeInt))
if ps := csmu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := csmu.mutation.SignatureID(); ok {
_spec.SetField(codesignaturematch.FieldSignatureID, field.TypeString, value)
}
if value, ok := csmu.mutation.SignatureVendor(); ok {
_spec.SetField(codesignaturematch.FieldSignatureVendor, field.TypeString, value)
}
if csmu.mutation.SignatureVendorCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureVendor, field.TypeString)
}
if value, ok := csmu.mutation.SignatureProduct(); ok {
_spec.SetField(codesignaturematch.FieldSignatureProduct, field.TypeString, value)
}
if csmu.mutation.SignatureProductCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureProduct, field.TypeString)
}
if value, ok := csmu.mutation.SignatureService(); ok {
_spec.SetField(codesignaturematch.FieldSignatureService, field.TypeString, value)
}
if csmu.mutation.SignatureServiceCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureService, field.TypeString)
}
if value, ok := csmu.mutation.SignatureDescription(); ok {
_spec.SetField(codesignaturematch.FieldSignatureDescription, field.TypeString, value)
}
if csmu.mutation.SignatureDescriptionCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureDescription, field.TypeString)
}
if value, ok := csmu.mutation.Tags(); ok {
_spec.SetField(codesignaturematch.FieldTags, field.TypeJSON, value)
}
if value, ok := csmu.mutation.AppendedTags(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, codesignaturematch.FieldTags, value)
})
}
if csmu.mutation.TagsCleared() {
_spec.ClearField(codesignaturematch.FieldTags, field.TypeJSON)
}
if value, ok := csmu.mutation.FilePath(); ok {
_spec.SetField(codesignaturematch.FieldFilePath, field.TypeString, value)
}
if value, ok := csmu.mutation.Language(); ok {
_spec.SetField(codesignaturematch.FieldLanguage, field.TypeString, value)
}
if value, ok := csmu.mutation.Line(); ok {
_spec.SetField(codesignaturematch.FieldLine, field.TypeUint, value)
}
if value, ok := csmu.mutation.AddedLine(); ok {
_spec.AddField(codesignaturematch.FieldLine, field.TypeUint, value)
}
if csmu.mutation.LineCleared() {
_spec.ClearField(codesignaturematch.FieldLine, field.TypeUint)
}
if value, ok := csmu.mutation.Column(); ok {
_spec.SetField(codesignaturematch.FieldColumn, field.TypeUint, value)
}
if value, ok := csmu.mutation.AddedColumn(); ok {
_spec.AddField(codesignaturematch.FieldColumn, field.TypeUint, value)
}
if csmu.mutation.ColumnCleared() {
_spec.ClearField(codesignaturematch.FieldColumn, field.TypeUint)
}
if value, ok := csmu.mutation.CalleeNamespace(); ok {
_spec.SetField(codesignaturematch.FieldCalleeNamespace, field.TypeString, value)
}
if csmu.mutation.CalleeNamespaceCleared() {
_spec.ClearField(codesignaturematch.FieldCalleeNamespace, field.TypeString)
}
if value, ok := csmu.mutation.MatchedCall(); ok {
_spec.SetField(codesignaturematch.FieldMatchedCall, field.TypeString, value)
}
if csmu.mutation.MatchedCallCleared() {
_spec.ClearField(codesignaturematch.FieldMatchedCall, field.TypeString)
}
if value, ok := csmu.mutation.PackageHint(); ok {
_spec.SetField(codesignaturematch.FieldPackageHint, field.TypeString, value)
}
if csmu.mutation.PackageHintCleared() {
_spec.ClearField(codesignaturematch.FieldPackageHint, field.TypeString)
}
if csmu.mutation.SourceFileCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: codesignaturematch.SourceFileTable,
Columns: []string{codesignaturematch.SourceFileColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := csmu.mutation.SourceFileIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: codesignaturematch.SourceFileTable,
Columns: []string{codesignaturematch.SourceFileColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, csmu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{codesignaturematch.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
csmu.mutation.done = true
return n, nil
}
// CodeSignatureMatchUpdateOne is the builder for updating a single CodeSignatureMatch entity.
type CodeSignatureMatchUpdateOne struct {
config
fields []string
hooks []Hook
mutation *CodeSignatureMatchMutation
}
// SetSignatureID sets the "signature_id" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetSignatureID(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetSignatureID(s)
return csmuo
}
// SetNillableSignatureID sets the "signature_id" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableSignatureID(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetSignatureID(*s)
}
return csmuo
}
// SetSignatureVendor sets the "signature_vendor" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetSignatureVendor(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetSignatureVendor(s)
return csmuo
}
// SetNillableSignatureVendor sets the "signature_vendor" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableSignatureVendor(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetSignatureVendor(*s)
}
return csmuo
}
// ClearSignatureVendor clears the value of the "signature_vendor" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearSignatureVendor() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearSignatureVendor()
return csmuo
}
// SetSignatureProduct sets the "signature_product" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetSignatureProduct(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetSignatureProduct(s)
return csmuo
}
// SetNillableSignatureProduct sets the "signature_product" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableSignatureProduct(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetSignatureProduct(*s)
}
return csmuo
}
// ClearSignatureProduct clears the value of the "signature_product" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearSignatureProduct() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearSignatureProduct()
return csmuo
}
// SetSignatureService sets the "signature_service" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetSignatureService(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetSignatureService(s)
return csmuo
}
// SetNillableSignatureService sets the "signature_service" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableSignatureService(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetSignatureService(*s)
}
return csmuo
}
// ClearSignatureService clears the value of the "signature_service" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearSignatureService() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearSignatureService()
return csmuo
}
// SetSignatureDescription sets the "signature_description" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetSignatureDescription(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetSignatureDescription(s)
return csmuo
}
// SetNillableSignatureDescription sets the "signature_description" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableSignatureDescription(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetSignatureDescription(*s)
}
return csmuo
}
// ClearSignatureDescription clears the value of the "signature_description" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearSignatureDescription() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearSignatureDescription()
return csmuo
}
// SetTags sets the "tags" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetTags(s []string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetTags(s)
return csmuo
}
// AppendTags appends s to the "tags" field.
func (csmuo *CodeSignatureMatchUpdateOne) AppendTags(s []string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.AppendTags(s)
return csmuo
}
// ClearTags clears the value of the "tags" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearTags() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearTags()
return csmuo
}
// SetFilePath sets the "file_path" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetFilePath(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetFilePath(s)
return csmuo
}
// SetNillableFilePath sets the "file_path" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableFilePath(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetFilePath(*s)
}
return csmuo
}
// SetLanguage sets the "language" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetLanguage(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetLanguage(s)
return csmuo
}
// SetNillableLanguage sets the "language" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableLanguage(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetLanguage(*s)
}
return csmuo
}
// SetLine sets the "line" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetLine(u uint) *CodeSignatureMatchUpdateOne {
csmuo.mutation.ResetLine()
csmuo.mutation.SetLine(u)
return csmuo
}
// SetNillableLine sets the "line" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableLine(u *uint) *CodeSignatureMatchUpdateOne {
if u != nil {
csmuo.SetLine(*u)
}
return csmuo
}
// AddLine adds u to the "line" field.
func (csmuo *CodeSignatureMatchUpdateOne) AddLine(u int) *CodeSignatureMatchUpdateOne {
csmuo.mutation.AddLine(u)
return csmuo
}
// ClearLine clears the value of the "line" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearLine() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearLine()
return csmuo
}
// SetColumn sets the "column" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetColumn(u uint) *CodeSignatureMatchUpdateOne {
csmuo.mutation.ResetColumn()
csmuo.mutation.SetColumn(u)
return csmuo
}
// SetNillableColumn sets the "column" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableColumn(u *uint) *CodeSignatureMatchUpdateOne {
if u != nil {
csmuo.SetColumn(*u)
}
return csmuo
}
// AddColumn adds u to the "column" field.
func (csmuo *CodeSignatureMatchUpdateOne) AddColumn(u int) *CodeSignatureMatchUpdateOne {
csmuo.mutation.AddColumn(u)
return csmuo
}
// ClearColumn clears the value of the "column" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearColumn() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearColumn()
return csmuo
}
// SetCalleeNamespace sets the "callee_namespace" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetCalleeNamespace(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetCalleeNamespace(s)
return csmuo
}
// SetNillableCalleeNamespace sets the "callee_namespace" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableCalleeNamespace(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetCalleeNamespace(*s)
}
return csmuo
}
// ClearCalleeNamespace clears the value of the "callee_namespace" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearCalleeNamespace() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearCalleeNamespace()
return csmuo
}
// SetMatchedCall sets the "matched_call" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetMatchedCall(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetMatchedCall(s)
return csmuo
}
// SetNillableMatchedCall sets the "matched_call" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillableMatchedCall(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetMatchedCall(*s)
}
return csmuo
}
// ClearMatchedCall clears the value of the "matched_call" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearMatchedCall() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearMatchedCall()
return csmuo
}
// SetPackageHint sets the "package_hint" field.
func (csmuo *CodeSignatureMatchUpdateOne) SetPackageHint(s string) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetPackageHint(s)
return csmuo
}
// SetNillablePackageHint sets the "package_hint" field if the given value is not nil.
func (csmuo *CodeSignatureMatchUpdateOne) SetNillablePackageHint(s *string) *CodeSignatureMatchUpdateOne {
if s != nil {
csmuo.SetPackageHint(*s)
}
return csmuo
}
// ClearPackageHint clears the value of the "package_hint" field.
func (csmuo *CodeSignatureMatchUpdateOne) ClearPackageHint() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearPackageHint()
return csmuo
}
// SetSourceFileID sets the "source_file" edge to the CodeSourceFile entity by ID.
func (csmuo *CodeSignatureMatchUpdateOne) SetSourceFileID(id int) *CodeSignatureMatchUpdateOne {
csmuo.mutation.SetSourceFileID(id)
return csmuo
}
// SetSourceFile sets the "source_file" edge to the CodeSourceFile entity.
func (csmuo *CodeSignatureMatchUpdateOne) SetSourceFile(c *CodeSourceFile) *CodeSignatureMatchUpdateOne {
return csmuo.SetSourceFileID(c.ID)
}
// Mutation returns the CodeSignatureMatchMutation object of the builder.
func (csmuo *CodeSignatureMatchUpdateOne) Mutation() *CodeSignatureMatchMutation {
return csmuo.mutation
}
// ClearSourceFile clears the "source_file" edge to the CodeSourceFile entity.
func (csmuo *CodeSignatureMatchUpdateOne) ClearSourceFile() *CodeSignatureMatchUpdateOne {
csmuo.mutation.ClearSourceFile()
return csmuo
}
// Where appends a list predicates to the CodeSignatureMatchUpdate builder.
func (csmuo *CodeSignatureMatchUpdateOne) Where(ps ...predicate.CodeSignatureMatch) *CodeSignatureMatchUpdateOne {
csmuo.mutation.Where(ps...)
return csmuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (csmuo *CodeSignatureMatchUpdateOne) Select(field string, fields ...string) *CodeSignatureMatchUpdateOne {
csmuo.fields = append([]string{field}, fields...)
return csmuo
}
// Save executes the query and returns the updated CodeSignatureMatch entity.
func (csmuo *CodeSignatureMatchUpdateOne) Save(ctx context.Context) (*CodeSignatureMatch, error) {
return withHooks(ctx, csmuo.sqlSave, csmuo.mutation, csmuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (csmuo *CodeSignatureMatchUpdateOne) SaveX(ctx context.Context) *CodeSignatureMatch {
node, err := csmuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (csmuo *CodeSignatureMatchUpdateOne) Exec(ctx context.Context) error {
_, err := csmuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (csmuo *CodeSignatureMatchUpdateOne) ExecX(ctx context.Context) {
if err := csmuo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (csmuo *CodeSignatureMatchUpdateOne) check() error {
if v, ok := csmuo.mutation.SignatureID(); ok {
if err := codesignaturematch.SignatureIDValidator(v); err != nil {
return &ValidationError{Name: "signature_id", err: fmt.Errorf(`ent: validator failed for field "CodeSignatureMatch.signature_id": %w`, err)}
}
}
if v, ok := csmuo.mutation.FilePath(); ok {
if err := codesignaturematch.FilePathValidator(v); err != nil {
return &ValidationError{Name: "file_path", err: fmt.Errorf(`ent: validator failed for field "CodeSignatureMatch.file_path": %w`, err)}
}
}
if v, ok := csmuo.mutation.Language(); ok {
if err := codesignaturematch.LanguageValidator(v); err != nil {
return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "CodeSignatureMatch.language": %w`, err)}
}
}
if csmuo.mutation.SourceFileCleared() && len(csmuo.mutation.SourceFileIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "CodeSignatureMatch.source_file"`)
}
return nil
}
func (csmuo *CodeSignatureMatchUpdateOne) sqlSave(ctx context.Context) (_node *CodeSignatureMatch, err error) {
if err := csmuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(codesignaturematch.Table, codesignaturematch.Columns, sqlgraph.NewFieldSpec(codesignaturematch.FieldID, field.TypeInt))
id, ok := csmuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CodeSignatureMatch.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := csmuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, codesignaturematch.FieldID)
for _, f := range fields {
if !codesignaturematch.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != codesignaturematch.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := csmuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := csmuo.mutation.SignatureID(); ok {
_spec.SetField(codesignaturematch.FieldSignatureID, field.TypeString, value)
}
if value, ok := csmuo.mutation.SignatureVendor(); ok {
_spec.SetField(codesignaturematch.FieldSignatureVendor, field.TypeString, value)
}
if csmuo.mutation.SignatureVendorCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureVendor, field.TypeString)
}
if value, ok := csmuo.mutation.SignatureProduct(); ok {
_spec.SetField(codesignaturematch.FieldSignatureProduct, field.TypeString, value)
}
if csmuo.mutation.SignatureProductCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureProduct, field.TypeString)
}
if value, ok := csmuo.mutation.SignatureService(); ok {
_spec.SetField(codesignaturematch.FieldSignatureService, field.TypeString, value)
}
if csmuo.mutation.SignatureServiceCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureService, field.TypeString)
}
if value, ok := csmuo.mutation.SignatureDescription(); ok {
_spec.SetField(codesignaturematch.FieldSignatureDescription, field.TypeString, value)
}
if csmuo.mutation.SignatureDescriptionCleared() {
_spec.ClearField(codesignaturematch.FieldSignatureDescription, field.TypeString)
}
if value, ok := csmuo.mutation.Tags(); ok {
_spec.SetField(codesignaturematch.FieldTags, field.TypeJSON, value)
}
if value, ok := csmuo.mutation.AppendedTags(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, codesignaturematch.FieldTags, value)
})
}
if csmuo.mutation.TagsCleared() {
_spec.ClearField(codesignaturematch.FieldTags, field.TypeJSON)
}
if value, ok := csmuo.mutation.FilePath(); ok {
_spec.SetField(codesignaturematch.FieldFilePath, field.TypeString, value)
}
if value, ok := csmuo.mutation.Language(); ok {
_spec.SetField(codesignaturematch.FieldLanguage, field.TypeString, value)
}
if value, ok := csmuo.mutation.Line(); ok {
_spec.SetField(codesignaturematch.FieldLine, field.TypeUint, value)
}
if value, ok := csmuo.mutation.AddedLine(); ok {
_spec.AddField(codesignaturematch.FieldLine, field.TypeUint, value)
}
if csmuo.mutation.LineCleared() {
_spec.ClearField(codesignaturematch.FieldLine, field.TypeUint)
}
if value, ok := csmuo.mutation.Column(); ok {
_spec.SetField(codesignaturematch.FieldColumn, field.TypeUint, value)
}
if value, ok := csmuo.mutation.AddedColumn(); ok {
_spec.AddField(codesignaturematch.FieldColumn, field.TypeUint, value)
}
if csmuo.mutation.ColumnCleared() {
_spec.ClearField(codesignaturematch.FieldColumn, field.TypeUint)
}
if value, ok := csmuo.mutation.CalleeNamespace(); ok {
_spec.SetField(codesignaturematch.FieldCalleeNamespace, field.TypeString, value)
}
if csmuo.mutation.CalleeNamespaceCleared() {
_spec.ClearField(codesignaturematch.FieldCalleeNamespace, field.TypeString)
}
if value, ok := csmuo.mutation.MatchedCall(); ok {
_spec.SetField(codesignaturematch.FieldMatchedCall, field.TypeString, value)
}
if csmuo.mutation.MatchedCallCleared() {
_spec.ClearField(codesignaturematch.FieldMatchedCall, field.TypeString)
}
if value, ok := csmuo.mutation.PackageHint(); ok {
_spec.SetField(codesignaturematch.FieldPackageHint, field.TypeString, value)
}
if csmuo.mutation.PackageHintCleared() {
_spec.ClearField(codesignaturematch.FieldPackageHint, field.TypeString)
}
if csmuo.mutation.SourceFileCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: codesignaturematch.SourceFileTable,
Columns: []string{codesignaturematch.SourceFileColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := csmuo.mutation.SourceFileIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: codesignaturematch.SourceFileTable,
Columns: []string{codesignaturematch.SourceFileColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &CodeSignatureMatch{config: csmuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, csmuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{codesignaturematch.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
csmuo.mutation.done = true
return _node, nil
}