Fix error on Execer. Close #124

This commit is contained in:
mattn 2014-06-26 03:54:09 +09:00
parent d56eb93ecb
commit d9e7576acf
2 changed files with 66 additions and 65 deletions

View File

@ -153,13 +153,16 @@ func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, err
if err != nil { if err != nil {
return nil, err return nil, err
} }
var res driver.Result
if s.(*SQLiteStmt).s != nil {
na := s.NumInput() na := s.NumInput()
res, err := s.Exec(args[:na]) res, err = s.Exec(args[:na])
if err != nil && err != driver.ErrSkip { if err != nil && err != driver.ErrSkip {
s.Close() s.Close()
return nil, err return nil, err
} }
args = args[na:] args = args[na:]
}
tail := s.(*SQLiteStmt).t tail := s.(*SQLiteStmt).t
if tail == "" { if tail == "" {
return res, nil return res, nil

View File

@ -1,7 +1,6 @@
package sqlite3 package sqlite3
import ( import (
"./sqltest"
"crypto/rand" "crypto/rand"
"database/sql" "database/sql"
"encoding/hex" "encoding/hex"
@ -9,6 +8,8 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"time" "time"
"./sqltest"
) )
func TempFilename() string { func TempFilename() string {
@ -639,29 +640,26 @@ func TestSuite(t *testing.T) {
// TODO: Execer & Queryer currently disabled // TODO: Execer & Queryer currently disabled
// https://github.com/mattn/go-sqlite3/issues/82 // https://github.com/mattn/go-sqlite3/issues/82
//func TestExecer(t *testing.T) { func TestExecer(t *testing.T) {
// tempFilename := TempFilename() tempFilename := TempFilename()
// db, err := sql.Open("sqlite3", tempFilename) db, err := sql.Open("sqlite3", tempFilename)
// if err != nil { if err != nil {
// t.Fatal("Failed to open database:", err) t.Fatal("Failed to open database:", err)
// } }
// defer os.Remove(tempFilename) defer os.Remove(tempFilename)
// defer db.Close() defer db.Close()
//
// _, err = db.Exec(` _, err = db.Exec(`
// create table foo (id integer); create table foo (id integer); -- one comment
// insert into foo(id) values(?); insert into foo(id) values(?);
// insert into foo(id) values(?); insert into foo(id) values(?);
// insert into foo(id) values(?); insert into foo(id) values(?); -- another comment
// `, 1, 2, 3) `, 1, 2, 3)
// if err != nil { if err != nil {
// t.Error("Failed to call db.Exec:", err) t.Error("Failed to call db.Exec:", err)
// } }
// if err != nil { }
// t.Error("Failed to call res.RowsAffected:", err)
// }
//}
//
//func TestQueryer(t *testing.T) { //func TestQueryer(t *testing.T) {
// tempFilename := TempFilename() // tempFilename := TempFilename()
// db, err := sql.Open("sqlite3", tempFilename) // db, err := sql.Open("sqlite3", tempFilename)