MCPcopy
hub / github.com/jmoiron/sqlx / TestIssue197

Function TestIssue197

sqlx_test.go:1466–1505  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1464}
1465
1466func TestIssue197(t *testing.T) {
1467 // this test actually tests for a bug in database/sql:
1468 // https://github.com/golang/go/issues/13905
1469 // this potentially makes _any_ named type that is an alias for []byte
1470 // unsafe to use in a lot of different ways (basically, unsafe to hold
1471 // onto after loading from the database).
1472 t.Skip()
1473
1474 type mybyte []byte
1475 type Var struct{ Raw json.RawMessage }
1476 type Var2 struct{ Raw []byte }
1477 type Var3 struct{ Raw mybyte }
1478 RunWithSchema(defaultSchema, t, func(db *DB, t *testing.T, now string) {
1479 var err error
1480 var v, q Var
1481 if err = db.Get(&v, `SELECT '{"a": "b"}' AS raw`); err != nil {
1482 t.Fatal(err)
1483 }
1484 if err = db.Get(&q, `SELECT 'null' AS raw`); err != nil {
1485 t.Fatal(err)
1486 }
1487
1488 var v2, q2 Var2
1489 if err = db.Get(&v2, `SELECT '{"a": "b"}' AS raw`); err != nil {
1490 t.Fatal(err)
1491 }
1492 if err = db.Get(&q2, `SELECT 'null' AS raw`); err != nil {
1493 t.Fatal(err)
1494 }
1495
1496 var v3, q3 Var3
1497 if err = db.QueryRow(`SELECT '{"a": "b"}' AS raw`).Scan(&v3.Raw); err != nil {
1498 t.Fatal(err)
1499 }
1500 if err = db.QueryRow(`SELECT '{"c": "d"}' AS raw`).Scan(&q3.Raw); err != nil {
1501 t.Fatal(err)
1502 }
1503 t.Fail()
1504 })
1505}
1506
1507func TestIn(t *testing.T) {
1508 // some quite normal situations

Callers

nothing calls this directly

Calls 4

RunWithSchemaFunction · 0.85
QueryRowMethod · 0.80
ScanMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected