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:
Julien Schmidt 2013-02-13 15:25:39 -08:00 committed by Brad Fitzpatrick
parent 8c30b3f038
commit 2968e239b0
3 changed files with 114 additions and 26 deletions

View file

@ -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...))
}