Skip to content

Commit

Permalink
stop making a copy of the stmt for qstmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoiron committed Aug 28, 2015
1 parent ae682dc commit 3a92b1f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sqlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,35 +473,35 @@ func (s *Stmt) Unsafe() *Stmt {

// Select using the prepared statement.
func (s *Stmt) Select(dest interface{}, args ...interface{}) error {
return Select(&qStmt{*s}, dest, "", args...)
return Select(&qStmt{s}, dest, "", args...)
}

// Get using the prepared statement.
func (s *Stmt) Get(dest interface{}, args ...interface{}) error {
return Get(&qStmt{*s}, dest, "", args...)
return Get(&qStmt{s}, dest, "", args...)
}

// MustExec (panic) using this statement. Note that the query portion of the error
// output will be blank, as Stmt does not expose its query.
func (s *Stmt) MustExec(args ...interface{}) sql.Result {
return MustExec(&qStmt{*s}, "", args...)
return MustExec(&qStmt{s}, "", args...)
}

// QueryRowx using this statement.
func (s *Stmt) QueryRowx(args ...interface{}) *Row {
qs := &qStmt{*s}
qs := &qStmt{s}
return qs.QueryRowx("", args...)
}

// Queryx using this statement.
func (s *Stmt) Queryx(args ...interface{}) (*Rows, error) {
qs := &qStmt{*s}
qs := &qStmt{s}
return qs.Queryx("", args...)
}

// qStmt is an unexposed wrapper which lets you use a Stmt as a Queryer & Execer by
// implementing those interfaces and ignoring the `query` argument.
type qStmt struct{ Stmt }
type qStmt struct{ *Stmt }

func (q *qStmt) Query(query string, args ...interface{}) (*sql.Rows, error) {
return q.Stmt.Query(args...)
Expand Down

0 comments on commit 3a92b1f

Please sign in to comment.