func (o *Poll) SetParentPollPoll(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Poll) error {
	var err error

	if insert {
		related.ParentPollID = o.PollID

		if err = related.Insert(ctx, exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"polls\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"parent_poll_id"}),
			strmangle.WhereClause("\"", "\"", 2, pollPrimaryKeyColumns),
		)
		values := []interface{}{o.PollID, related.PollID}

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

		related.ParentPollID = o.PollID

	}

	if o.R == nil {
		o.R = &pollR{
			ParentPollPoll: related,
		}
	} else {
		o.R.ParentPollPoll = related
	}

	if related.R == nil {
		related.R = &pollR{
			ParentPoll: o,
		}
	} else {
		related.R.ParentPoll = o
	}
	return nil
}
// SetParentPollPoll of the poll to the related item.
// Sets o.R.ParentPollPoll to related.
// Adds o to related.R.ParentPoll.
SetParentPollPoll of the poll to the related item.
Sets o.R.ParentPollPoll to related.
Adds o to related.R.ParentPoll.
// SetParentPollPoll of the poll to the related item . // Sets o . R . ParentPollPoll to related . // Adds o to related . R . ParentPoll .
func (o *Poll) SetParentPollPoll(ctx context.Context, exec boil.ContextExecutor, insert bool, related *Poll) error {
	var err error
	if insert {
		related.ParentPollID = o.PollID
		if err = related.Insert(ctx, exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"polls\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"parent_poll_id"}),
			strmangle.WhereClause("\"", "\"", 2, pollPrimaryKeyColumns),
		)
		values := []interface{}{o.PollID, related.PollID}
		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")
		}
		related.ParentPollID = o.PollID
	}
	if o.R == nil {
		o.R = &pollR{
			ParentPollPoll: related,
		}
	} else {
		o.R.ParentPollPoll = related
	}
	if related.R == nil {
		related.R = &pollR{
			ParentPoll: o,
		}
	} else {
		related.R.ParentPoll = o
	}
	return nil
}
func ( o * Poll ) SetParentPollPoll ( ctx context . Context , exec boil . ContextExecutor , insert bool , related * Poll ) error { var err error if insert { related . ParentPollID = o . PollID if err = related . Insert ( ctx , exec , boil . Infer ( ) ) ; err != nil { return errors . Wrap ( err , " " ) } } else { updateQuery := fmt . Sprintf ( " \" \" " , strmangle . SetParamNames ( " \" " , " \" " , 1 , [ ] string { " " } ) , strmangle . WhereClause ( " \" " , " \" " , 2 , pollPrimaryKeyColumns ) , ) values := [ ] interface { } { o . PollID , related . PollID } 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 , " " ) } related . ParentPollID = o . PollID } if o . R == nil { o . R = & pollR { ParentPollPoll : related , } } else { o . R . ParentPollPoll = related } if related . R == nil { related . R = & pollR { ParentPoll : o , } } else { related . R . ParentPoll = o } return nil }
SetParentPollPoll of the poll to the related item.
SetParentPollPoll of the poll to the related item .