diff --git a/named.go b/named.go index 6ac44777..878fa238 100644 --- a/named.go +++ b/named.go @@ -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 diff --git a/named_context.go b/named_context.go index 9ad23f4e..f22d3752 100644 --- a/named_context.go +++ b/named_context.go @@ -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 diff --git a/sqlx.go b/sqlx.go index 8259a4fe..c6a60c2e 100644 --- a/sqlx.go +++ b/sqlx.go @@ -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) diff --git a/sqlx_context.go b/sqlx_context.go index 32621d56..83afb779 100644 --- a/sqlx_context.go +++ b/sqlx_context.go @@ -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,