func (o *Label) AddPollsLabels(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsLabel) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.LabelID = o.LabelID
			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_labels\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"label_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsLabelPrimaryKeyColumns),
			)
			values := []interface{}{o.LabelID, rel.PollLabelID}

			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.LabelID = o.LabelID
		}
	}

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsLabelR{
				Label: o,
			}
		} else {
			rel.R.Label = o
		}
	}
	return nil
}
// AddPollsLabels adds the given related objects to the existing relationships
// of the label, optionally inserting them as new records.
// Appends related to o.R.PollsLabels.
// Sets related.R.Label appropriately.
AddPollsLabels adds the given related objects to the existing relationships
of the label, optionally inserting them as new records.
Appends related to o.R.PollsLabels.
Sets related.R.Label appropriately.
// AddPollsLabels adds the given related objects to the existing relationships // of the label optionally inserting them as new records . // Appends related to o . R . PollsLabels . // Sets related . R . Label appropriately .
func (o *Label) AddPollsLabels(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsLabel) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.LabelID = o.LabelID
			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_labels\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"label_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsLabelPrimaryKeyColumns),
			)
			values := []interface{}{o.LabelID, rel.PollLabelID}
			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.LabelID = o.LabelID
		}
	}
	if o.R == nil {
		o.R = &labelR{
			PollsLabels: related,
		}
	} else {
		o.R.PollsLabels = append(o.R.PollsLabels, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsLabelR{
				Label: o,
			}
		} else {
			rel.R.Label = o
		}
	}
	return nil
}
func ( o * Label ) AddPollsLabels ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * PollsLabel ) error { var err error for _ , rel := range related { if insert { rel . LabelID = o . LabelID 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 , pollsLabelPrimaryKeyColumns ) , ) values := [ ] interface { } { o . LabelID , rel . PollLabelID } 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 . LabelID = o . LabelID } } if o . R == nil { o . R = & labelR { PollsLabels : related , } } else { o . R . PollsLabels = append ( o . R . PollsLabels , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & pollsLabelR { Label : o , } } else { rel . R . Label = o } } return nil }
AddPollsLabels adds the given related objects to the existing relationships
of the label, optionally inserting them as new records.
AddPollsLabels adds the given related objects to the existing relationships of the label optionally inserting them as new records .