entc/gen: remove internal rollback function from templates (#1602)

This commit is contained in:
Ciaran Liedeman
2021-05-26 19:17:12 +02:00
committed by GitHub
parent 0e5635941f
commit 844f63015d
30 changed files with 2 additions and 348 deletions

View File

@@ -11,7 +11,6 @@ import (
"fmt"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/examples/privacyadmin/ent/user"
@@ -270,14 +269,3 @@ func isSQLConstraintError(err error) (*ConstraintError, bool) {
}
return nil, false
}
// rollback calls tx.Rollback and wraps the given error with the rollback error if present.
func rollback(tx dialect.Tx, err error) error {
if rerr := tx.Rollback(); rerr != nil {
err = fmt.Errorf("%w: %v", err, rerr)
}
if err, ok := isSQLConstraintError(err); ok {
return err
}
return err
}