@@ -37,7 +37,7 @@ func Test_Conn_ExecAndScan(t *testing.T) {
3737
3838 now := time .Now ()
3939 mustExec (db , `
40- insert into test (cint, creal, ctext, cblob, time )
40+ insert into test (cint, creal, ctext, cblob, ctime )
4141 values (?1, ?2, ?3, ?4, ?5)
4242 ` , 1 , 2.2 , "three" , []byte ("four" ), now )
4343 assert .Equal (t , db .Changes (), 1 )
@@ -289,6 +289,34 @@ func Test_Rows_ScanError(t *testing.T) {
289289 assert .Equal (t , rows .Error ().Error (), "sqlite: cannot scan into *os.File (index: 0) (code: 21)" )
290290}
291291
292+ func Test_Row_Map (t * testing.T ) {
293+ db := testDB ()
294+ defer db .Close ()
295+
296+ now := time .Now ()
297+
298+ mustExec (db , `
299+ insert into test (id, cint, creal, ctext, cblob, ctime)
300+ values (?1, ?2, ?3, ?4, ?5, ?6)
301+ ` , 99 , 2 , 3.3 , "four" , []byte ("five" ), now )
302+
303+ m , err := db .Row ("select * from test" ).Map ()
304+ assert .Nil (t , err )
305+ assert .Equal (t , len (m ), 11 )
306+
307+ assert .Equal (t , m ["id" ].(int ), 99 )
308+ assert .Equal (t , m ["cint" ].(int ), 2 )
309+ assert .Nil (t , m ["cintn" ])
310+ assert .Equal (t , m ["creal" ].(float64 ), 3.3 )
311+ assert .Nil (t , m ["crealn" ])
312+ assert .Equal (t , m ["ctext" ].(string ), "four" )
313+ assert .Nil (t , m ["ctextn" ])
314+ assert .Equal (t , string (m ["cblob" ].([]byte )), "five" )
315+ assert .Nil (t , m ["cblobn" ])
316+ assert .Equal (t , m ["ctime" ].(int ), int (now .Unix ()))
317+ assert .Nil (t , m ["ctimen" ])
318+ }
319+
292320func testDB () sqlite.Conn {
293321 db , err := sqlite .Open (":memory:" , true )
294322 if err != nil {
@@ -305,8 +333,8 @@ func testDB() sqlite.Conn {
305333 ctextn text null,
306334 cblob blob not null default(''),
307335 cblobn blob null,
308- time int not null default(0),
309- timen int null
336+ ctime int not null default(0),
337+ ctimen int null
310338 )
311339 ` )
312340 return db
0 commit comments