entc/gen: nillable update setters for non-optional fields (#3788)

This commit is contained in:
Ariel Mashraki
2023-10-12 21:26:07 +03:00
committed by GitHub
parent 5368e5c54e
commit 8a848a6475
78 changed files with 1831 additions and 2 deletions

View File

@@ -38,6 +38,14 @@ func (cu *CityUpdate) SetName(s string) *CityUpdate {
return cu
}
// SetNillableName sets the "name" field if the given value is not nil.
func (cu *CityUpdate) SetNillableName(s *string) *CityUpdate {
if s != nil {
cu.SetName(*s)
}
return cu
}
// AddStreetIDs adds the "streets" edge to the Street entity by IDs.
func (cu *CityUpdate) AddStreetIDs(ids ...int) *CityUpdate {
cu.mutation.AddStreetIDs(ids...)
@@ -189,6 +197,14 @@ func (cuo *CityUpdateOne) SetName(s string) *CityUpdateOne {
return cuo
}
// SetNillableName sets the "name" field if the given value is not nil.
func (cuo *CityUpdateOne) SetNillableName(s *string) *CityUpdateOne {
if s != nil {
cuo.SetName(*s)
}
return cuo
}
// AddStreetIDs adds the "streets" edge to the Street entity by IDs.
func (cuo *CityUpdateOne) AddStreetIDs(ids ...int) *CityUpdateOne {
cuo.mutation.AddStreetIDs(ids...)

View File

@@ -38,6 +38,14 @@ func (su *StreetUpdate) SetName(s string) *StreetUpdate {
return su
}
// SetNillableName sets the "name" field if the given value is not nil.
func (su *StreetUpdate) SetNillableName(s *string) *StreetUpdate {
if s != nil {
su.SetName(*s)
}
return su
}
// SetCityID sets the "city" edge to the City entity by ID.
func (su *StreetUpdate) SetCityID(id int) *StreetUpdate {
su.mutation.SetCityID(id)
@@ -162,6 +170,14 @@ func (suo *StreetUpdateOne) SetName(s string) *StreetUpdateOne {
return suo
}
// SetNillableName sets the "name" field if the given value is not nil.
func (suo *StreetUpdateOne) SetNillableName(s *string) *StreetUpdateOne {
if s != nil {
suo.SetName(*s)
}
return suo
}
// SetCityID sets the "city" edge to the City entity by ID.
func (suo *StreetUpdateOne) SetCityID(id int) *StreetUpdateOne {
suo.mutation.SetCityID(id)