@@ -470,9 +470,9 @@ func TestEmbeddedStructs(t *testing.T) {
470470func TestJoinQuery (t * testing.T ) {
471471 type Employee struct {
472472 Name string
473- Id int64
474- // BossId is an id into the employee table
475- BossId sql.NullInt64 `db:"boss_id"`
473+ ID int64
474+ // BossID is an id into the employee table
475+ BossID sql.NullInt64 `db:"boss_id"`
476476 }
477477 type Boss Employee
478478
@@ -496,7 +496,7 @@ func TestJoinQuery(t *testing.T) {
496496 if len (em .Employee .Name ) == 0 {
497497 t .Errorf ("Expected non zero lengthed name." )
498498 }
499- if em .Employee .BossId .Int64 != em .Boss .Id {
499+ if em .Employee .BossID .Int64 != em .Boss .ID {
500500 t .Errorf ("Expected boss ids to match" )
501501 }
502502 }
@@ -506,9 +506,9 @@ func TestJoinQuery(t *testing.T) {
506506func TestJoinQueryNamedPointerStructs (t * testing.T ) {
507507 type Employee struct {
508508 Name string
509- Id int64
510- // BossId is an id into the employee table
511- BossId sql.NullInt64 `db:"boss_id"`
509+ ID int64
510+ // BossID is an id into the employee table
511+ BossID sql.NullInt64 `db:"boss_id"`
512512 }
513513 type Boss Employee
514514
@@ -536,7 +536,7 @@ func TestJoinQueryNamedPointerStructs(t *testing.T) {
536536 if len (em .Emp1 .Name ) == 0 || len (em .Emp2 .Name ) == 0 {
537537 t .Errorf ("Expected non zero lengthed name." )
538538 }
539- if em .Emp1 .BossId .Int64 != em .Boss .Id || em .Emp2 .BossId .Int64 != em .Boss .Id {
539+ if em .Emp1 .BossID .Int64 != em .Boss .ID || em .Emp2 .BossID .Int64 != em .Boss .ID {
540540 t .Errorf ("Expected boss ids to match" )
541541 }
542542 }
@@ -1341,6 +1341,53 @@ func TestEmbeddedMaps(t *testing.T) {
13411341 })
13421342}
13431343
1344+ func TestIssue197 (t * testing.T ) {
1345+ // this test actually tests for a bug in database/sql:
1346+ // https://github.com/golang/go/issues/13905
1347+ // this potentially makes _any_ named type that is an alias for []byte
1348+ // unsafe to use in a lot of different ways (basically, unsafe to hold
1349+ // onto after loading from the database).
1350+ t .Skip ()
1351+
1352+ type mybyte []byte
1353+ type Var struct { Raw json.RawMessage }
1354+ type Var2 struct { Raw []byte }
1355+ type Var3 struct { Raw mybyte }
1356+ RunWithSchema (defaultSchema , t , func (db * DB , t * testing.T ) {
1357+ var err error
1358+ var v , q Var
1359+ if err = db .Get (& v , `SELECT '{"a": "b"}' AS raw` ); err != nil {
1360+ t .Fatal (err )
1361+ }
1362+ fmt .Printf ("%s: v %s\n " , db .DriverName (), v .Raw )
1363+ if err = db .Get (& q , `SELECT 'null' AS raw` ); err != nil {
1364+ t .Fatal (err )
1365+ }
1366+ fmt .Printf ("%s: v %s\n " , db .DriverName (), v .Raw )
1367+
1368+ var v2 , q2 Var2
1369+ if err = db .Get (& v2 , `SELECT '{"a": "b"}' AS raw` ); err != nil {
1370+ t .Fatal (err )
1371+ }
1372+ fmt .Printf ("%s: v2 %s\n " , db .DriverName (), v2 .Raw )
1373+ if err = db .Get (& q2 , `SELECT 'null' AS raw` ); err != nil {
1374+ t .Fatal (err )
1375+ }
1376+ fmt .Printf ("%s: v2 %s\n " , db .DriverName (), v2 .Raw )
1377+
1378+ var v3 , q3 Var3
1379+ if err = db .QueryRow (`SELECT '{"a": "b"}' AS raw` ).Scan (& v3 .Raw ); err != nil {
1380+ t .Fatal (err )
1381+ }
1382+ fmt .Printf ("v3 %s\n " , v3 .Raw )
1383+ if err = db .QueryRow (`SELECT '{"c": "d"}' AS raw` ).Scan (& q3 .Raw ); err != nil {
1384+ t .Fatal (err )
1385+ }
1386+ fmt .Printf ("v3 %s\n " , v3 .Raw )
1387+ t .Fail ()
1388+ })
1389+ }
1390+
13441391func TestIn (t * testing.T ) {
13451392 // some quite normal situations
13461393 type tr struct {
0 commit comments