entc/gen: skip executing sub-query for empty set of edges (#3212)

This commit is contained in:
Ariel Mashraki
2023-01-07 08:54:18 +02:00
committed by GitHub
parent b7da6253b6
commit b88f45aa78
64 changed files with 251 additions and 2 deletions

View File

@@ -1435,8 +1435,8 @@ func (g *graph) addFKEdges(ctx context.Context, ids []driver.Value, edges []*Edg
if err != nil {
return err
}
// Setting the FK value of the "other" table
// without clearing it before, is not allowed.
// Setting the FK value of the "other" table without clearing it before, is not allowed.
// Including no-op (same id), because we rely on "affected" to determine if the FK set.
if ids := edge.Target.Nodes; int(affected) < len(ids) {
return &ConstraintError{msg: fmt.Sprintf("one of %v is already connected to a different %s", ids, edge.Columns[0])}
}