Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions named.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ func bindNamedMapper(bindType int, query string, arg interface{}, m *reflectx.Ma
}

// NamedQuery binds a named query and then runs Query on the result using the
// provided Ext (sqlx.Tx, sqlx.Db). It works with both structs and with
// provided NamedQueryer (sqlx.Tx, sqlx.Db). It works with both structs and with
// map[string]interface{} types.
func NamedQuery(e Ext, query string, arg interface{}) (*Rows, error) {
func NamedQuery(e NamedQueryer, query string, arg interface{}) (*Rows, error) {
q, args, err := bindNamedMapper(BindType(e.DriverName()), query, arg, mapperFor(e))
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions named_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func (n *NamedStmt) GetContext(ctx context.Context, dest interface{}, arg interf
}

// NamedQueryContext binds a named query and then runs Query on the result using the
// provided Ext (sqlx.Tx, sqlx.Db). It works with both structs and with
// provided NamedQueryerContext (sqlx.Tx, sqlx.Db). It works with both structs and with
// map[string]interface{} types.
func NamedQueryContext(ctx context.Context, e ExtContext, query string, arg interface{}) (*Rows, error) {
func NamedQueryContext(ctx context.Context, e NamedQueryerContext, query string, arg interface{}) (*Rows, error) {
q, args, err := bindNamedMapper(BindType(e.DriverName()), query, arg, mapperFor(e))
if err != nil {
return nil, err
Expand Down
9 changes: 8 additions & 1 deletion sqlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,20 @@ type binder interface {
}

// Ext is a union interface which can bind, query, and exec, used by
// NamedQuery and NamedExec.
// NamedExec.
type Ext interface {
binder
Queryer
Execer
}

// NamedQueryer is a union interface which can bind and query, used by
// NamedQuery.
type NamedQueryer interface {
binder
Queryer
}

// Preparer is an interface used by Preparex.
type Preparer interface {
Prepare(query string) (*sql.Stmt, error)
Expand Down
9 changes: 8 additions & 1 deletion sqlx_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ type ExecerContext interface {
}

// ExtContext is a union interface which can bind, query, and exec, with Context
// used by NamedQueryContext and NamedExecContext.
// used by NamedExecContext.
type ExtContext interface {
binder
QueryerContext
ExecerContext
}

// NamedQueryerContext is a union interface which can bind and query, with Context
// used by NamedQueryContext.
type NamedQueryerContext interface {
binder
QueryerContext
}

// SelectContext executes a query using the provided Queryer, and StructScans
// each row into dest, which must be a slice. If the slice elements are
// scannable, then the result set must have only one column. Otherwise,
Expand Down