Skip to content

Commit

Permalink
feat: return begin err
Browse files Browse the repository at this point in the history
  • Loading branch information
qqxhb authored and tr1v3r committed Feb 13, 2023
1 parent c5b4756 commit 7eed555
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
8 changes: 6 additions & 2 deletions internal/template/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) er
}
func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
return &QueryTx{q.clone(q.db.Begin(opts...))}
tx := q.db.Begin(opts...)
return &QueryTx{Query: q.clone(tx), Error: tx.Error}
}
type QueryTx struct{ *Query }
type QueryTx struct {
*Query
Error error
}
func (q *QueryTx) Commit() error {
return q.db.Commit().Error
Expand Down
8 changes: 6 additions & 2 deletions tests/.expect/dal_1/query/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tests/.expect/dal_2/query/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tests/.expect/dal_3/query/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tests/.expect/dal_4/query/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7eed555

Please sign in to comment.