func (o *Honor) AddUserPersonalInfoHonors(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserPersonalInfoHonor) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.HonorID = o.HonorID
			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_personal_info_honors\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"honor_id"}),
				strmangle.WhereClause("\"", "\"", 2, userPersonalInfoHonorPrimaryKeyColumns),
			)
			values := []interface{}{o.HonorID, rel.UserPersonalInfoHonorID}

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

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userPersonalInfoHonorR{
				Honor: o,
			}
		} else {
			rel.R.Honor = o
		}
	}
	return nil
}
// AddUserPersonalInfoHonors adds the given related objects to the existing relationships
// of the honor, optionally inserting them as new records.
// Appends related to o.R.UserPersonalInfoHonors.
// Sets related.R.Honor appropriately.
AddUserPersonalInfoHonors adds the given related objects to the existing relationships
of the honor, optionally inserting them as new records.
Appends related to o.R.UserPersonalInfoHonors.
Sets related.R.Honor appropriately.
// AddUserPersonalInfoHonors adds the given related objects to the existing relationships // of the honor optionally inserting them as new records . // Appends related to o . R . UserPersonalInfoHonors . // Sets related . R . Honor appropriately .
func (o *Honor) AddUserPersonalInfoHonors(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserPersonalInfoHonor) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.HonorID = o.HonorID
			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_personal_info_honors\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"honor_id"}),
				strmangle.WhereClause("\"", "\"", 2, userPersonalInfoHonorPrimaryKeyColumns),
			)
			values := []interface{}{o.HonorID, rel.UserPersonalInfoHonorID}
			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.HonorID = o.HonorID
		}
	}
	if o.R == nil {
		o.R = &honorR{
			UserPersonalInfoHonors: related,
		}
	} else {
		o.R.UserPersonalInfoHonors = append(o.R.UserPersonalInfoHonors, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userPersonalInfoHonorR{
				Honor: o,
			}
		} else {
			rel.R.Honor = o
		}
	}
	return nil
}
func ( o * Honor ) AddUserPersonalInfoHonors ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * UserPersonalInfoHonor ) error { var err error for _ , rel := range related { if insert { rel . HonorID = o . HonorID 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 , userPersonalInfoHonorPrimaryKeyColumns ) , ) values := [ ] interface { } { o . HonorID , rel . UserPersonalInfoHonorID } 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 . HonorID = o . HonorID } } if o . R == nil { o . R = & honorR { UserPersonalInfoHonors : related , } } else { o . R . UserPersonalInfoHonors = append ( o . R . UserPersonalInfoHonors , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & userPersonalInfoHonorR { Honor : o , } } else { rel . R . Honor = o } } return nil }
AddUserPersonalInfoHonors adds the given related objects to the existing relationships
of the honor, optionally inserting them as new records.
AddUserPersonalInfoHonors adds the given related objects to the existing relationships of the honor optionally inserting them as new records .