@@ -128,7 +128,7 @@ type TestRows struct {
128
128
129
129
func (t * TestRows ) Columns () []string {
130
130
if t .firstTime {
131
- return []string {"name" , "age" , "is_god" , "point" }
131
+ return []string {"name" , "age" , "is_god" , "point" , "power" , "created_at" }
132
132
}
133
133
return []string {}
134
134
}
@@ -143,6 +143,8 @@ func (t *TestRows) Next(dest []driver.Value) error {
143
143
dest [1 ] = 10
144
144
dest [2 ] = true
145
145
dest [3 ] = 3.14
146
+ dest [4 ] = 100
147
+ dest [5 ] = time .Date (2020 , 01 , 01 , 12 , 0 , 0 , 0 , time .Local )
146
148
t .firstTime = false
147
149
} else {
148
150
return io .EOF
@@ -221,7 +223,7 @@ func testColumnType(t *testing.T, rows *Rows) {
221
223
t .Run ("validate column type" , func (t * testing.T ) {
222
224
types , err := rows .ColumnTypes ()
223
225
checkErr (t , err )
224
- if len (types ) != 4 {
226
+ if len (types ) != 6 {
225
227
t .Fatal ("cannot get columnTypes" )
226
228
}
227
229
columnType := types [0 ]
@@ -250,12 +252,14 @@ func testRows(t *testing.T, rows *Rows) {
250
252
for {
251
253
for rows .Next () {
252
254
var (
253
- name string
254
- age int
255
- isGod bool
256
- point float32
255
+ name string
256
+ age int
257
+ isGod bool
258
+ point float32
259
+ power int32
260
+ createdAt time.Time
257
261
)
258
- checkErr (t , rows .Scan (& name , & age , & isGod , & point ))
262
+ checkErr (t , rows .Scan (& name , & age , & isGod , & point , & power , & createdAt ))
259
263
if name != "alice" {
260
264
t .Fatal ("cannot scan" )
261
265
}
@@ -268,6 +272,12 @@ func testRows(t *testing.T, rows *Rows) {
268
272
if int (point ) != 3 {
269
273
t .Fatal ("cannot scan" )
270
274
}
275
+ if power != 100 {
276
+ t .Fatal ("cannot scan" )
277
+ }
278
+ if ! createdAt .Equal (time .Date (2020 , 01 , 01 , 12 , 00 , 00 , 00 , time .Local )) {
279
+ t .Fatal ("cannot scan" )
280
+ }
271
281
}
272
282
if ! rows .NextResultSet () {
273
283
break
@@ -286,7 +296,7 @@ func testPrepareWithNotShardingTable(ctx context.Context, t *testing.T, db *DB)
286
296
t .Run ("validate columns" , func (t * testing.T ) {
287
297
columns , err := rows .Columns ()
288
298
checkErr (t , err )
289
- if len (columns ) != 4 {
299
+ if len (columns ) != 6 {
290
300
t .Fatal ("cannot get columns" )
291
301
}
292
302
testColumnType (t , rows )
@@ -300,12 +310,14 @@ func testPrepareWithNotShardingTable(ctx context.Context, t *testing.T, db *DB)
300
310
defer rows .Close ()
301
311
for rows .Next () {
302
312
var (
303
- name string
304
- age int
305
- isGod bool
306
- point float32
313
+ name string
314
+ age int
315
+ isGod bool
316
+ point float32
317
+ power int32
318
+ createdAt time.Time
307
319
)
308
- checkErr (t , rows .Scan (& name , & age , & isGod , & point ))
320
+ checkErr (t , rows .Scan (& name , & age , & isGod , & point , & power , & createdAt ))
309
321
if name != "alice" {
310
322
t .Fatal ("cannot scan" )
311
323
}
@@ -321,24 +333,28 @@ func testPrepareContextWithNotShardingTable(ctx context.Context, t *testing.T, d
321
333
defer stmt .Close ()
322
334
t .Run ("query row without context" , func (t * testing.T ) {
323
335
var (
324
- name string
325
- age int
326
- isGod bool
327
- point float32
336
+ name string
337
+ age int
338
+ isGod bool
339
+ point float32
340
+ power int32
341
+ createdAt time.Time
328
342
)
329
- stmt .QueryRow (1 ).Scan (& name , & age , & isGod , & point )
343
+ stmt .QueryRow (1 ).Scan (& name , & age , & isGod , & point , & power , & createdAt )
330
344
if name != "alice" {
331
345
t .Fatal ("cannot scan" )
332
346
}
333
347
})
334
348
t .Run ("query row with context" , func (t * testing.T ) {
335
349
var (
336
- name string
337
- age int
338
- isGod bool
339
- point float32
350
+ name string
351
+ age int
352
+ isGod bool
353
+ point float32
354
+ power int32
355
+ createdAt time.Time
340
356
)
341
- stmt .QueryRowContext (ctx , 1 ).Scan (& name , & age , & isGod , & point )
357
+ stmt .QueryRowContext (ctx , 1 ).Scan (& name , & age , & isGod , & point , & power , & createdAt )
342
358
if name != "alice" {
343
359
t .Fatal ("cannot scan" )
344
360
}
@@ -454,12 +470,14 @@ func testTransactionStmtError(t *testing.T, tx *Tx, stmt *Stmt) {
454
470
func testTransactionQueryRowWithoutContext (t * testing.T , stmt * Stmt ) {
455
471
t .Run ("query row without context" , func (t * testing.T ) {
456
472
var (
457
- name NullString
458
- age NullInt64
459
- isGod NullBool
460
- point NullFloat64
473
+ name NullString
474
+ age NullInt64
475
+ isGod NullBool
476
+ point NullFloat64
477
+ power NullInt32
478
+ createdAt NullTime
461
479
)
462
- checkErr (t , stmt .QueryRow (1 ).Scan (& name , & age , & isGod , & point ))
480
+ checkErr (t , stmt .QueryRow (1 ).Scan (& name , & age , & isGod , & point , & power , & createdAt ))
463
481
nameValue , err := name .Value ()
464
482
checkErr (t , err )
465
483
if nameValue .(string ) != "alice" {
@@ -490,13 +508,15 @@ func testTransactionQueryRowWithoutContext(t *testing.T, stmt *Stmt) {
490
508
491
509
func testTransactionQueryWithContext (ctx context.Context , t * testing.T , stmt * Stmt ) {
492
510
var (
493
- name NullString
494
- age NullInt64
495
- isGod NullBool
496
- point NullFloat64
511
+ name NullString
512
+ age NullInt64
513
+ isGod NullBool
514
+ point NullFloat64
515
+ power NullInt32
516
+ createdAt NullTime
497
517
)
498
518
t .Run ("query row with context" , func (t * testing.T ) {
499
- stmt .QueryRowContext (ctx , 1 ).Scan (& name , & age , & isGod , & point )
519
+ stmt .QueryRowContext (ctx , 1 ).Scan (& name , & age , & isGod , & point , & power , & createdAt )
500
520
nameValue , err := name .Value ()
501
521
checkErr (t , err )
502
522
if nameValue .(string ) != "alice" {
0 commit comments