entc/gen: add feature-flag to set unique backref when their inverse is loaded (#3953)

This commit is contained in:
Ariel Mashraki
2024-02-24 22:57:17 +02:00
committed by GitHub
parent d4560fae62
commit 7284481be5
87 changed files with 463 additions and 579 deletions

View File

@@ -45,12 +45,10 @@ type CarEdges struct {
// OwnerOrErr returns the Owner value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e CarEdges) OwnerOrErr() (*User, error) {
if e.loadedTypes[0] {
if e.Owner == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: user.Label}
}
if e.Owner != nil {
return e.Owner, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: user.Label}
}
return nil, &NotLoadedError{edge: "owner"}
}