-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add missing methods #941
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ func ConnectContext(ctx context.Context, driverName, dataSourceName string) (*DB | |
type QueryerContext interface { | ||
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) | ||
QueryxContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) | ||
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note Adding a missing method to this interface. We have |
||
QueryRowxContext(ctx context.Context, query string, args ...interface{}) *Row | ||
} | ||
|
||
|
@@ -353,6 +354,12 @@ func (tx *Tx) QueryRowxContext(ctx context.Context, query string, args ...interf | |
return &Row{rows: rows, err: err, unsafe: tx.unsafe, Mapper: tx.Mapper} | ||
} | ||
|
||
// NamedQueryContext using this DB. | ||
// Any named placeholder parameters are replaced with fields from arg. | ||
func (tx *Tx) NamedQueryContext(ctx context.Context, query string, arg interface{}) (*Rows, error) { | ||
return NamedQueryContext(ctx, tx, query, arg) | ||
} | ||
Comment on lines
+359
to
+361
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note This method exists on This is the only query-related method I found that is needed to allow these two types to be used interchangeably. |
||
|
||
// NamedExecContext using this Tx. | ||
// Any named placeholder parameters are replaced with fields from arg. | ||
func (tx *Tx) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error) { | ||
|
@@ -405,6 +412,10 @@ func (q *qStmt) QueryxContext(ctx context.Context, query string, args ...interfa | |
return &Rows{Rows: r, unsafe: q.Stmt.unsafe, Mapper: q.Stmt.Mapper}, err | ||
} | ||
|
||
func (q *Stmt) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row { | ||
return q.Stmt.QueryRowContext(ctx, args...) | ||
} | ||
|
||
func (q *qStmt) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *Row { | ||
rows, err := q.Stmt.QueryContext(ctx, args...) | ||
return &Row{rows: rows, err: err, unsafe: q.Stmt.unsafe, Mapper: q.Stmt.Mapper} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Adding a missing method to this interface.
We have
Query
/Queryx
, andQueryRowx
, but this method was missing.