@@ -875,7 +875,7 @@ func (c *SQLiteConn) exec(ctx context.Context, query string, args []driver.Named
875875 // consume the number of arguments used in the current
876876 // statement and append all named arguments not
877877 // contained therein
878- if len ( args [ start : start + na ]) > 0 {
878+ if na > 0 {
879879 stmtArgs = append (stmtArgs , args [start :start + na ]... )
880880 for i := range args {
881881 if (i < start || i >= na ) && args [i ].Name != "" {
@@ -1968,7 +1968,7 @@ func (s *SQLiteStmt) bind(args []driver.NamedValue) error {
19681968 bindIndices := make ([][3 ]int , len (args ))
19691969 prefixes := []string {":" , "@" , "$" }
19701970 for i , v := range args {
1971- bindIndices [i ][0 ] = args [ i ] .Ordinal
1971+ bindIndices [i ][0 ] = v .Ordinal
19721972 if v .Name != "" {
19731973 for j := range prefixes {
19741974 cname := C .CString (prefixes [j ] + v .Name )
@@ -2179,7 +2179,7 @@ func (rc *SQLiteRows) Columns() []string {
21792179 defer rc .s .mu .Unlock ()
21802180 if rc .s .s != nil && int (rc .nc ) != len (rc .cols ) {
21812181 rc .cols = make ([]string , rc .nc )
2182- for i := 0 ; i < int ( rc .nc ); i ++ {
2182+ for i := range rc .cols {
21832183 rc .cols [i ] = C .GoString (C .sqlite3_column_name (rc .s .s , C .int (i )))
21842184 }
21852185 }
@@ -2189,7 +2189,7 @@ func (rc *SQLiteRows) Columns() []string {
21892189func (rc * SQLiteRows ) declTypes () []string {
21902190 if rc .s .s != nil && rc .decltype == nil {
21912191 rc .decltype = make ([]string , rc .nc )
2192- for i := 0 ; i < int ( rc .nc ); i ++ {
2192+ for i := range rc .decltype {
21932193 rc .decltype [i ] = strings .ToLower (C .GoString (C .sqlite3_column_decltype (rc .s .s , C .int (i ))))
21942194 }
21952195 }
@@ -2251,11 +2251,13 @@ func (rc *SQLiteRows) nextSyncLocked(dest []driver.Value) error {
22512251
22522252 rc .declTypes ()
22532253
2254+ decltype := rc .decltype
2255+ _ = decltype [len (dest )- 1 ]
22542256 for i := range dest {
22552257 switch C .sqlite3_column_type (rc .s .s , C .int (i )) {
22562258 case C .SQLITE_INTEGER :
22572259 val := int64 (C .sqlite3_column_int64 (rc .s .s , C .int (i )))
2258- switch rc . decltype [i ] {
2260+ switch decltype [i ] {
22592261 case columnTimestamp , columnDatetime , columnDate :
22602262 var t time.Time
22612263 // Assume a millisecond unix timestamp if it's 13 digits -- too
@@ -2295,7 +2297,7 @@ func (rc *SQLiteRows) nextSyncLocked(dest []driver.Value) error {
22952297 n := int (C .sqlite3_column_bytes (rc .s .s , C .int (i )))
22962298 s := C .GoStringN ((* C .char )(unsafe .Pointer (C .sqlite3_column_text (rc .s .s , C .int (i )))), C .int (n ))
22972299
2298- switch rc . decltype [i ] {
2300+ switch decltype [i ] {
22992301 case columnTimestamp , columnDatetime , columnDate :
23002302 var t time.Time
23012303 s = strings .TrimSuffix (s , "Z" )
0 commit comments