You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There has been a major change here:
- Recursive saves (even with circular dependencies) are now supported!
And also a bug has been fixed as a result:
- If the virtual column corresponding to a relationship foreign key is empty (because, for example, the relationship has not been retrieved in the query) but exists in the database, now it is ignored. Before it was deleted without checking if it existed in the database. This does not break any expected behavior because relationships should not be removed by just removing them from the object but using the Remove* methods from the store.
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -283,7 +283,8 @@ if err != nil {
283
283
}
284
284
```
285
285
286
-
If our model has relationships, they will be saved (**note:** saved as in insert or update) as well. The relationships of the relationships will not, though. Relationships are only saved with one level of depth.
286
+
If our model has relationships, they will be saved, and so will the relationships of the relationships and so on. TL;DR: inserts are recursive.
287
+
**Note:** the relationships will be saved using `Save`, not `Insert`.
287
288
288
289
```go
289
290
user:=NewUser("foo")
@@ -318,7 +319,8 @@ if err != nil {
318
319
}
319
320
```
320
321
321
-
If our model has relationships, they will be saved (**note:** saved as in insert or update) as well. The relationships of the relationships will not, though. Relationships are only saved with one level of depth.
322
+
If our model has relationships, they will be saved, and so will the relationships of the relationships and so on. TL;DR: updates are recursive.
323
+
**Note:** the relationships will be saved using `Save`, not `Update`.
322
324
323
325
```go
324
326
user:=FindLastPoster()
@@ -345,7 +347,7 @@ if updated {
345
347
}
346
348
```
347
349
348
-
If our model has relationships, they will be saved as well. The relationships of the relationships will not, though. Relationships are only saved with one level of depth.
350
+
If our model has relationships, they will be saved, and so will the relationships of the relationships and so on. TL;DR: saves are recursive.
0 commit comments