func (o *Address) AddUserPersonalInfos(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserPersonalInfo) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.AddressID = o.AddressID
			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\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"address_id"}),
				strmangle.WhereClause("\"", "\"", 2, userPersonalInfoPrimaryKeyColumns),
			)
			values := []interface{}{o.AddressID, rel.UserPersonalInfoID}

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

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userPersonalInfoR{
				Address: o,
			}
		} else {
			rel.R.Address = o
		}
	}
	return nil
}
// AddUserPersonalInfos adds the given related objects to the existing relationships
// of the address, optionally inserting them as new records.
// Appends related to o.R.UserPersonalInfos.
// Sets related.R.Address appropriately.
AddUserPersonalInfos adds the given related objects to the existing relationships
of the address, optionally inserting them as new records.
Appends related to o.R.UserPersonalInfos.
Sets related.R.Address appropriately.
// AddUserPersonalInfos adds the given related objects to the existing relationships // of the address optionally inserting them as new records . // Appends related to o . R . UserPersonalInfos . // Sets related . R . Address appropriately .
func (o *Address) AddUserPersonalInfos(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserPersonalInfo) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.AddressID = o.AddressID
			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\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"address_id"}),
				strmangle.WhereClause("\"", "\"", 2, userPersonalInfoPrimaryKeyColumns),
			)
			values := []interface{}{o.AddressID, rel.UserPersonalInfoID}
			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.AddressID = o.AddressID
		}
	}
	if o.R == nil {
		o.R = &addressR{
			UserPersonalInfos: related,
		}
	} else {
		o.R.UserPersonalInfos = append(o.R.UserPersonalInfos, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userPersonalInfoR{
				Address: o,
			}
		} else {
			rel.R.Address = o
		}
	}
	return nil
}
func ( o * Address ) AddUserPersonalInfos ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * UserPersonalInfo ) error { var err error for _ , rel := range related { if insert { rel . AddressID = o . AddressID 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 , userPersonalInfoPrimaryKeyColumns ) , ) values := [ ] interface { } { o . AddressID , rel . UserPersonalInfoID } 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 . AddressID = o . AddressID } } if o . R == nil { o . R = & addressR { UserPersonalInfos : related , } } else { o . R . UserPersonalInfos = append ( o . R . UserPersonalInfos , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & userPersonalInfoR { Address : o , } } else { rel . R . Address = o } } return nil }
AddUserPersonalInfos adds the given related objects to the existing relationships
of the address, optionally inserting them as new records.
AddUserPersonalInfos adds the given related objects to the existing relationships of the address optionally inserting them as new records .