func (o *Color) AddPollsFactorsPositions(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsFactorsPosition) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.ColorID = o.ColorID
			if err = rel.Insert(ctx, exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"polls_factors_positions\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"color_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsFactorsPositionPrimaryKeyColumns),
			)
			values := []interface{}{o.ColorID, rel.PollFactorPositionID}

			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 foreign table")
			}

			rel.ColorID = o.ColorID
		}
	}

	if o.R == nil {
		o.R = &colorR{
			PollsFactorsPositions: related,
		}
	} else {
		o.R.PollsFactorsPositions = append(o.R.PollsFactorsPositions, related...)
	}

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsFactorsPositionR{
				Color: o,
			}
		} else {
			rel.R.Color = o
		}
	}
	return nil
}
// AddPollsFactorsPositions adds the given related objects to the existing relationships
// of the color, optionally inserting them as new records.
// Appends related to o.R.PollsFactorsPositions.
// Sets related.R.Color appropriately.
AddPollsFactorsPositions adds the given related objects to the existing relationships
of the color, optionally inserting them as new records.
Appends related to o.R.PollsFactorsPositions.
Sets related.R.Color appropriately.
// AddPollsFactorsPositions adds the given related objects to the existing relationships // of the color optionally inserting them as new records . // Appends related to o . R . PollsFactorsPositions . // Sets related . R . Color appropriately .
func (o *Color) AddPollsFactorsPositions(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsFactorsPosition) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.ColorID = o.ColorID
			if err = rel.Insert(ctx, exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"polls_factors_positions\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"color_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsFactorsPositionPrimaryKeyColumns),
			)
			values := []interface{}{o.ColorID, rel.PollFactorPositionID}
			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 foreign table")
			}
			rel.ColorID = o.ColorID
		}
	}
	if o.R == nil {
		o.R = &colorR{
			PollsFactorsPositions: related,
		}
	} else {
		o.R.PollsFactorsPositions = append(o.R.PollsFactorsPositions, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsFactorsPositionR{
				Color: o,
			}
		} else {
			rel.R.Color = o
		}
	}
	return nil
}
func ( o * Color ) AddPollsFactorsPositions ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * PollsFactorsPosition ) error { var err error for _ , rel := range related { if insert { rel . ColorID = o . ColorID if err = rel . Insert ( ctx , exec , boil . Infer ( ) ) ; err != nil { return errors . Wrap ( err , " " ) } } else { updateQuery := fmt . Sprintf ( " \" \" " , strmangle . SetParamNames ( " \" " , " \" " , 1 , [ ] string { " " } ) , strmangle . WhereClause ( " \" " , " \" " , 2 , pollsFactorsPositionPrimaryKeyColumns ) , ) values := [ ] interface { } { o . ColorID , rel . PollFactorPositionID } 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 , " " ) } rel . ColorID = o . ColorID } } if o . R == nil { o . R = & colorR { PollsFactorsPositions : related , } } else { o . R . PollsFactorsPositions = append ( o . R . PollsFactorsPositions , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & pollsFactorsPositionR { Color : o , } } else { rel . R . Color = o } } return nil }
AddPollsFactorsPositions adds the given related objects to the existing relationships
of the color, optionally inserting them as new records.
AddPollsFactorsPositions adds the given related objects to the existing relationships of the color optionally inserting them as new records .