mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
database/sql: Add an optional Queryer-Interface (like Execer)
Completly the same like the Execer-Interface, just for Queries. This allows Drivers to execute Queries without preparing them first R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/7085056
This commit is contained in:
parent
8c30b3f038
commit
2968e239b0
3 changed files with 114 additions and 26 deletions
|
|
@ -266,6 +266,18 @@ func (c *fakeConn) Exec(query string, args []driver.Value) (driver.Result, error
|
|||
return nil, driver.ErrSkip
|
||||
}
|
||||
|
||||
func (c *fakeConn) Query(query string, args []driver.Value) (driver.Rows, error) {
|
||||
// This is an optional interface, but it's implemented here
|
||||
// just to check that all the args are of the proper types.
|
||||
// ErrSkip is returned so the caller acts as if we didn't
|
||||
// implement this at all.
|
||||
err := checkSubsetTypes(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, driver.ErrSkip
|
||||
}
|
||||
|
||||
func errf(msg string, args ...interface{}) error {
|
||||
return errors.New("fakedb: " + fmt.Sprintf(msg, args...))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue