func (o *EthnicGroupCountry) SetEthnicGroup(ctx context.Context, exec boil.ContextExecutor, insert bool, related *EthnicGroup) error {
	var err error
	if insert {
		if err = related.Insert(ctx, exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}

	updateQuery := fmt.Sprintf(
		"UPDATE \"ethnic_group_country\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"ethnic_group_id"}),
		strmangle.WhereClause("\"", "\"", 2, ethnicGroupCountryPrimaryKeyColumns),
	)
	values := []interface{}{related.EthnicGroupID, o.EthnicGroupCountryID}

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

	o.EthnicGroupID = related.EthnicGroupID
	if o.R == nil {
		o.R = &ethnicGroupCountryR{
			EthnicGroup: related,
		}
	} else {
		o.R.EthnicGroup = related
	}

	if related.R == nil {
		related.R = &ethnicGroupR{
			EthnicGroupCountries: EthnicGroupCountrySlice{o},
		}
	} else {
		related.R.EthnicGroupCountries = append(related.R.EthnicGroupCountries, o)
	}

	return nil
}
// SetEthnicGroup of the ethnicGroupCountry to the related item.
// Sets o.R.EthnicGroup to related.
// Adds o to related.R.EthnicGroupCountries.
SetEthnicGroup of the ethnicGroupCountry to the related item.
Sets o.R.EthnicGroup to related.
Adds o to related.R.EthnicGroupCountries.
// SetEthnicGroup of the ethnicGroupCountry to the related item . // Sets o . R . EthnicGroup to related . // Adds o to related . R . EthnicGroupCountries .
func (o *EthnicGroupCountry) SetEthnicGroup(ctx context.Context, exec boil.ContextExecutor, insert bool, related *EthnicGroup) error {
	var err error
	if insert {
		if err = related.Insert(ctx, exec, boil.Infer()); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}
	updateQuery := fmt.Sprintf(
		"UPDATE \"ethnic_group_country\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"ethnic_group_id"}),
		strmangle.WhereClause("\"", "\"", 2, ethnicGroupCountryPrimaryKeyColumns),
	)
	values := []interface{}{related.EthnicGroupID, o.EthnicGroupCountryID}
	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 local table")
	}
	o.EthnicGroupID = related.EthnicGroupID
	if o.R == nil {
		o.R = &ethnicGroupCountryR{
			EthnicGroup: related,
		}
	} else {
		o.R.EthnicGroup = related
	}
	if related.R == nil {
		related.R = &ethnicGroupR{
			EthnicGroupCountries: EthnicGroupCountrySlice{o},
		}
	} else {
		related.R.EthnicGroupCountries = append(related.R.EthnicGroupCountries, o)
	}
	return nil
}
func ( o * EthnicGroupCountry ) SetEthnicGroup ( ctx context . Context , exec boil . ContextExecutor , insert bool , related * EthnicGroup ) error { var err error if insert { if err = related . Insert ( ctx , exec , boil . Infer ( ) ) ; err != nil { return errors . Wrap ( err , " " ) } } updateQuery := fmt . Sprintf ( " \" \" " , strmangle . SetParamNames ( " \" " , " \" " , 1 , [ ] string { " " } ) , strmangle . WhereClause ( " \" " , " \" " , 2 , ethnicGroupCountryPrimaryKeyColumns ) , ) values := [ ] interface { } { related . EthnicGroupID , o . EthnicGroupCountryID } 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 , " " ) } o . EthnicGroupID = related . EthnicGroupID if o . R == nil { o . R = & ethnicGroupCountryR { EthnicGroup : related , } } else { o . R . EthnicGroup = related } if related . R == nil { related . R = & ethnicGroupR { EthnicGroupCountries : EthnicGroupCountrySlice { o } , } } else { related . R . EthnicGroupCountries = append ( related . R . EthnicGroupCountries , o ) } return nil }
SetEthnicGroup of the ethnicGroupCountry to the related item.
SetEthnicGroup of the ethnicGroupCountry to the related item .