aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosiah Kiehl (formerly @bluepojo) <josiah@capoferro.net>2014-11-29 14:08:02 -0800
committerJosiah Kiehl (formerly @bluepojo) <josiah@capoferro.net>2014-11-29 14:08:02 -0800
commit3dc340b45f32ab9ef7cfd1febad7aafb7f323898 (patch)
tree31b53f50ba054d4a8013e191309f846490a82ff0
parentReset statement. Fixes #150 (diff)
downloadgolite-3dc340b45f32ab9ef7cfd1febad7aafb7f323898.tar.gz
golite-3dc340b45f32ab9ef7cfd1febad7aafb7f323898.tar.xz
Catch missing arguments for Query()
Also improved error message on Exec() for consistency.
-rw-r--r--sqlite3.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/sqlite3.go b/sqlite3.go
index d446fb6..cef2048 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -60,6 +60,7 @@ import (
"database/sql"
"database/sql/driver"
"errors"
+ "fmt"
"io"
"runtime"
"strings"
@@ -174,7 +175,7 @@ func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, err
if s.(*SQLiteStmt).s != nil {
na := s.NumInput()
if len(args) < na {
- return nil, errors.New("args is not enough to execute query")
+ return nil, fmt.Errorf("Not enough args to execute query. Expected %d, got %d.", na, len(args))
}
res, err = s.Exec(args[:na])
if err != nil && err != driver.ErrSkip {
@@ -201,6 +202,9 @@ func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, erro
}
s.(*SQLiteStmt).cls = true
na := s.NumInput()
+ if len(args) < na {
+ return nil, fmt.Errorf("Not enough args to execute query. Expected %d, got %d.", na, len(args))
+ }
rows, err := s.Query(args[:na])
if err != nil && err != driver.ErrSkip {
s.Close()