func (o *Suffix) AddUserAccountSuffixes(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserAccountSuffix) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.SuffixID = o.SuffixID
			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 \"user_account_suffix\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"suffix_id"}),
				strmangle.WhereClause("\"", "\"", 2, userAccountSuffixPrimaryKeyColumns),
			)
			values := []interface{}{o.SuffixID, rel.UserAccountSuffixID}

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

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userAccountSuffixR{
				Suffix: o,
			}
		} else {
			rel.R.Suffix = o
		}
	}
	return nil
}
// AddUserAccountSuffixes adds the given related objects to the existing relationships
// of the suffix, optionally inserting them as new records.
// Appends related to o.R.UserAccountSuffixes.
// Sets related.R.Suffix appropriately.
AddUserAccountSuffixes adds the given related objects to the existing relationships
of the suffix, optionally inserting them as new records.
Appends related to o.R.UserAccountSuffixes.
Sets related.R.Suffix appropriately.
// AddUserAccountSuffixes adds the given related objects to the existing relationships // of the suffix optionally inserting them as new records . // Appends related to o . R . UserAccountSuffixes . // Sets related . R . Suffix appropriately .
func (o *Suffix) AddUserAccountSuffixes(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserAccountSuffix) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.SuffixID = o.SuffixID
			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 \"user_account_suffix\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"suffix_id"}),
				strmangle.WhereClause("\"", "\"", 2, userAccountSuffixPrimaryKeyColumns),
			)
			values := []interface{}{o.SuffixID, rel.UserAccountSuffixID}
			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.SuffixID = o.SuffixID
		}
	}
	if o.R == nil {
		o.R = &suffixR{
			UserAccountSuffixes: related,
		}
	} else {
		o.R.UserAccountSuffixes = append(o.R.UserAccountSuffixes, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userAccountSuffixR{
				Suffix: o,
			}
		} else {
			rel.R.Suffix = o
		}
	}
	return nil
}
func ( o * Suffix ) AddUserAccountSuffixes ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * UserAccountSuffix ) error { var err error for _ , rel := range related { if insert { rel . SuffixID = o . SuffixID 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 , userAccountSuffixPrimaryKeyColumns ) , ) values := [ ] interface { } { o . SuffixID , rel . UserAccountSuffixID } 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 . SuffixID = o . SuffixID } } if o . R == nil { o . R = & suffixR { UserAccountSuffixes : related , } } else { o . R . UserAccountSuffixes = append ( o . R . UserAccountSuffixes , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & userAccountSuffixR { Suffix : o , } } else { rel . R . Suffix = o } } return nil }
AddUserAccountSuffixes adds the given related objects to the existing relationships
of the suffix, optionally inserting them as new records.
AddUserAccountSuffixes adds the given related objects to the existing relationships of the suffix optionally inserting them as new records .