func (o *FactorsLink) SetFactor(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Factor) error {
	var err error
	if insert {
		if err = related.Insert(ctx, exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}

	updateQuery := fmt.Sprintf(
		"UPDATE \"factors_links\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"factors_id"}),
		strmangle.WhereClause("\"", "\"", 2, factorsLinkPrimaryKeyColumns),
	)
	values := []interface{}{related.FactorID, o.FactorsLinkID}

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, updateQuery)
		fmt.Fprintln(boil.DebugWriter, values)
	}

	if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {
		return errors.Wrap(err, "failed to update local table")
	}

	o.FactorsID = related.FactorID
	if o.R == nil {
		o.R = &factorsLinkR{
			Factor: related,
		}
	} else {
		o.R.Factor = related
	}

	if related.R == nil {
		related.R = &factorR{
			FactorsLinks: FactorsLinkSlice{o},
		}
	} else {
		related.R.FactorsLinks = append(related.R.FactorsLinks, o)
	}

	return nil
}
// SetFactor of the factorsLink to the related item.
// Sets o.R.Factor to related.
// Adds o to related.R.FactorsLinks.
SetFactor of the factorsLink to the related item.
Sets o.R.Factor to related.
Adds o to related.R.FactorsLinks.
// SetFactor of the factorsLink to the related item . // Sets o . R . Factor to related . // Adds o to related . R . FactorsLinks .
func (o *FactorsLink) SetFactor(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Factor) error {
	var err error
	if insert {
		if err = related.Insert(ctx, exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}
	updateQuery := fmt.Sprintf(
		"UPDATE \"factors_links\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"factors_id"}),
		strmangle.WhereClause("\"", "\"", 2, factorsLinkPrimaryKeyColumns),
	)
	values := []interface{}{related.FactorID, o.FactorsLinkID}
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, updateQuery)
		fmt.Fprintln(boil.DebugWriter, values)
	}
	if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {
		return errors.Wrap(err, "failed to update local table")
	}
	o.FactorsID = related.FactorID
	if o.R == nil {
		o.R = &factorsLinkR{
			Factor: related,
		}
	} else {
		o.R.Factor = related
	}
	if related.R == nil {
		related.R = &factorR{
			FactorsLinks: FactorsLinkSlice{o},
		}
	} else {
		related.R.FactorsLinks = append(related.R.FactorsLinks, o)
	}
	return nil
}
func ( o * FactorsLink ) SetFactor ( ctx context . Context , exec boil . ContextExecutor , insert bool , related * Factor ) error { var err error if insert { if err = related . Insert ( ctx , exec , boil . Infer ( ) ) ; err != nil { return errors . Wrap ( err , " " ) } } updateQuery := fmt . Sprintf ( " \" \" " , strmangle . SetParamNames ( " \" " , " \" " , 1 , [ ] string { " " } ) , strmangle . WhereClause ( " \" " , " \" " , 2 , factorsLinkPrimaryKeyColumns ) , ) values := [ ] interface { } { related . FactorID , o . FactorsLinkID } if boil . DebugMode { fmt . Fprintln ( boil . DebugWriter , updateQuery ) fmt . Fprintln ( boil . DebugWriter , values ) } if _ , err = exec . ExecContext ( ctx , updateQuery , values ... ) ; err != nil { return errors . Wrap ( err , " " ) } o . FactorsID = related . FactorID if o . R == nil { o . R = & factorsLinkR { Factor : related , } } else { o . R . Factor = related } if related . R == nil { related . R = & factorR { FactorsLinks : FactorsLinkSlice { o } , } } else { related . R . FactorsLinks = append ( related . R . FactorsLinks , o ) } return nil }
SetFactor of the factorsLink to the related item.
SetFactor of the factorsLink to the related item .