Skip to content

Commit

Permalink
Merge pull request #42 from smallstep/areed/prepare
Browse files Browse the repository at this point in the history
Add db.Prepare and tx.Prepare
  • Loading branch information
areed authored Nov 15, 2024
2 parents 98c4c4d + f67f652 commit e67287a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sequel.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ func (d *DB) HardDelete(ctx context.Context, arg ModelWithHardDelete) error {
return RowsAffected(r, 1)
}

// Prepare creates a prepared statement.
func (d *DB) Prepare(ctx context.Context, query string) (*sql.Stmt, error) {
return d.db.PrepareContext(ctx, query)
}

// Tx is an wrapper around sqlx.Tx with extra functionality.
type Tx struct {
tx *sqlx.Tx
Expand Down Expand Up @@ -586,3 +591,8 @@ func (t *Tx) HardDelete(arg ModelWithHardDelete) error {
}
return RowsAffected(r, 1)
}

// Prepare creates a prepared statement
func (t *Tx) Prepare(query string) (*sql.Stmt, error) {
return t.tx.Prepare(query)
}

0 comments on commit e67287a

Please sign in to comment.