Skip to content

Commit 5c90aa6

Browse files
committed
Merge branch 'santalla/devel'
2 parents b3d7e90 + 9076624 commit 5c90aa6

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

generator/templates/model.tgo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (s *{{.StoreName}}) inverseRecords(record *{{.Name}}) []modelSaveFunc {
155155
if {{if .IsPtr}}record.{{.Name}} != nil{{else}}!record.{{.Name}}.GetID().IsEmpty(){{end}} && !record.{{.Name}}.IsSaving() {
156156
record.AddVirtualColumn("{{.ForeignKey}}", record.{{.Name}}.GetID())
157157
result = append(result, func(store *kallax.Store) error {
158-
_, err := (&{{.TypeSchemaName}}Store{store}).Save(record.{{.Name}})
158+
_, err := (&{{.TypeSchemaName}}Store{store}).Save({{if not .IsPtr}}&{{end}}record.{{.Name}})
159159
return err
160160
})
161161
}

tests/kallax.go

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/relationships.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type Car struct {
77
ID kallax.ULID `pk:""`
88
Owner *Person `fk:"owner_id,inverse"`
99
ModelName string
10-
Brand *Brand `fk:"brand_id,inverse"`
10+
Brand Brand `fk:"brand_id,inverse"`
1111
events map[string]int
1212
}
1313

@@ -142,7 +142,7 @@ func newCar(model string, owner *Person) *Car {
142142
return car
143143
}
144144

145-
func newBrandedCar(model string, owner *Person, brand *Brand) *Car {
145+
func newBrandedCar(model string, owner *Person, brand Brand) *Car {
146146
car := &Car{ID: kallax.NewULID(), ModelName: model, Owner: owner, Brand: brand}
147147
owner.Car = car
148148
return car
@@ -151,3 +151,7 @@ func newBrandedCar(model string, owner *Person, brand *Brand) *Car {
151151
func newBrand(name string) *Brand {
152152
return &Brand{Name: name, ID: kallax.NewULID()}
153153
}
154+
155+
func makeBrand(name string) Brand {
156+
return Brand{Name: name, ID: kallax.NewULID()}
157+
}

tests/relationships_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (s *RelationshipsSuite) TestSaveWithInverse() {
134134

135135
func (s *RelationshipsSuite) TestSaveRelations() {
136136
p := NewPerson("Musk")
137-
brand := newBrand("Tesla")
137+
brand := makeBrand("Tesla")
138138
car := newBrandedCar("Model S", p, brand)
139139

140140
store := NewCarStore(s.db).Debug()

0 commit comments

Comments
 (0)