@@ -173,6 +173,12 @@ var SQLiteTimestampFormats = []string{
173
173
"2006-01-02" ,
174
174
}
175
175
176
+ const (
177
+ columnDate string = "date"
178
+ columnDatetime string = "datetime"
179
+ columnTimestamp string = "timestamp"
180
+ )
181
+
176
182
func init () {
177
183
sql .Register ("sqlite3" , & SQLiteDriver {})
178
184
}
@@ -392,7 +398,7 @@ func (c *SQLiteConn) RegisterCommitHook(callback func() int) {
392
398
if callback == nil {
393
399
C .sqlite3_commit_hook (c .db , nil , nil )
394
400
} else {
395
- C .sqlite3_commit_hook (c .db , (* [0 ]byte )(unsafe . Pointer ( C .commitHookTrampoline ) ), unsafe .Pointer (newHandle (c , callback )))
401
+ C .sqlite3_commit_hook (c .db , (* [0 ]byte )(C .commitHookTrampoline ), unsafe .Pointer (newHandle (c , callback )))
396
402
}
397
403
}
398
404
@@ -405,7 +411,7 @@ func (c *SQLiteConn) RegisterRollbackHook(callback func()) {
405
411
if callback == nil {
406
412
C .sqlite3_rollback_hook (c .db , nil , nil )
407
413
} else {
408
- C .sqlite3_rollback_hook (c .db , (* [0 ]byte )(unsafe . Pointer ( C .rollbackHookTrampoline ) ), unsafe .Pointer (newHandle (c , callback )))
414
+ C .sqlite3_rollback_hook (c .db , (* [0 ]byte )(C .rollbackHookTrampoline ), unsafe .Pointer (newHandle (c , callback )))
409
415
}
410
416
}
411
417
@@ -422,7 +428,7 @@ func (c *SQLiteConn) RegisterUpdateHook(callback func(int, string, string, int64
422
428
if callback == nil {
423
429
C .sqlite3_update_hook (c .db , nil , nil )
424
430
} else {
425
- C .sqlite3_update_hook (c .db , (* [0 ]byte )(unsafe . Pointer ( C .updateHookTrampoline ) ), unsafe .Pointer (newHandle (c , callback )))
431
+ C .sqlite3_update_hook (c .db , (* [0 ]byte )(C .updateHookTrampoline ), unsafe .Pointer (newHandle (c , callback )))
426
432
}
427
433
}
428
434
@@ -504,7 +510,7 @@ func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) erro
504
510
}
505
511
506
512
func sqlite3CreateFunction (db * C.sqlite3 , zFunctionName * C.char , nArg C.int , eTextRep C.int , pApp uintptr , xFunc unsafe.Pointer , xStep unsafe.Pointer , xFinal unsafe.Pointer ) C.int {
507
- return C ._sqlite3_create_function (db , zFunctionName , nArg , eTextRep , C .uintptr_t (pApp ), (* [0 ]byte )(unsafe . Pointer ( xFunc )) , (* [0 ]byte )(unsafe . Pointer ( xStep )) , (* [0 ]byte )(unsafe . Pointer ( xFinal ) ))
513
+ return C ._sqlite3_create_function (db , zFunctionName , nArg , eTextRep , C .uintptr_t (pApp ), (* [0 ]byte )(xFunc ), (* [0 ]byte )(xStep ), (* [0 ]byte )(xFinal ))
508
514
}
509
515
510
516
// RegisterAggregator makes a Go type available as a SQLite aggregation function.
@@ -1073,7 +1079,7 @@ func (s *SQLiteStmt) bind(args []namedValue) error {
1073
1079
case int64 :
1074
1080
rv = C .sqlite3_bind_int64 (s .s , n , C .sqlite3_int64 (v ))
1075
1081
case bool :
1076
- if bool ( v ) {
1082
+ if v {
1077
1083
rv = C .sqlite3_bind_int (s .s , n , 1 )
1078
1084
} else {
1079
1085
rv = C .sqlite3_bind_int (s .s , n , 0 )
@@ -1279,7 +1285,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
1279
1285
case C .SQLITE_INTEGER :
1280
1286
val := int64 (C .sqlite3_column_int64 (rc .s .s , C .int (i )))
1281
1287
switch rc .decltype [i ] {
1282
- case "timestamp" , "datetime" , "date" :
1288
+ case columnTimestamp , columnDatetime , columnDate :
1283
1289
var t time.Time
1284
1290
// Assume a millisecond unix timestamp if it's 13 digits -- too
1285
1291
// large to be a reasonable timestamp in seconds.
@@ -1310,10 +1316,10 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
1310
1316
n := int (C .sqlite3_column_bytes (rc .s .s , C .int (i )))
1311
1317
switch dest [i ].(type ) {
1312
1318
case sql.RawBytes :
1313
- dest [i ] = (* [1 << 30 ]byte )(unsafe . Pointer ( p ) )[0 :n ]
1319
+ dest [i ] = (* [1 << 30 ]byte )(p )[0 :n ]
1314
1320
default :
1315
1321
slice := make ([]byte , n )
1316
- copy (slice [:], (* [1 << 30 ]byte )(unsafe . Pointer ( p ) )[0 :n ])
1322
+ copy (slice [:], (* [1 << 30 ]byte )(p )[0 :n ])
1317
1323
dest [i ] = slice
1318
1324
}
1319
1325
case C .SQLITE_NULL :
@@ -1326,7 +1332,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
1326
1332
s := C .GoStringN ((* C .char )(unsafe .Pointer (C .sqlite3_column_text (rc .s .s , C .int (i )))), C .int (n ))
1327
1333
1328
1334
switch rc .decltype [i ] {
1329
- case "timestamp" , "datetime" , "date" :
1335
+ case columnTimestamp , columnDatetime , columnDate :
1330
1336
var t time.Time
1331
1337
s = strings .TrimSuffix (s , "Z" )
1332
1338
for _ , format := range SQLiteTimestampFormats {
0 commit comments