sqlx
sqlx copied to clipboard
Add sqlx.Conn to correspond to sql.Conn
Requires version: go ≥ 1.9
Pull Request Test Coverage Report for Build 30
- 0 of 58 (0.0%) changed or added relevant lines in 1 file are covered.
- 80 unchanged lines in 1 file lost coverage.
- Overall coverage decreased (-2.7%) to 69.147%
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
---|---|---|---|
sqlx_conn.go | 0 | 58 | 0.0% |
<!-- | Total: | 0 | 58 |
Files with Coverage Reduction | New Missed Lines | % |
---|---|---|
reflectx/reflect.go | 80 | 97.67% |
<!-- | Total: | 80 |
Totals | |
---|---|
Change from base Build 17: | -2.7% |
Covered Lines: | 1078 |
Relevant Lines: | 1559 |
💛 - Coveralls
Nice contribution. I'd like to add some testing and perhaps get vgo integration going before I leave some verisons of Go behind.
The test just like this:
type Stat struct {
Uri string `db:"uri"`
Total int64 `db:"total"`
CreatedAt int64 `db:"created_at"`
}
func TestDBConn(t *testing.T) {
conn, err := db.Conn(context.Background())
if err != nil {
t.Fatal(err)
}
defer conn.Close()
var total int64 = 1
r, err := conn.ExecContext(
context.Background(),
`INSERT INTO stat VALUE ('/j',?,1528996897)
ON DUPLICATE KEY UPDATE total=@total_tmp:=total+?;`,
total, 1,
)
if err != nil {
t.Fatal(err)
}
rowsAffected, err := r.RowsAffected()
if err != nil {
t.Fatal(err)
}
if rowsAffected == 2 {
err = conn.GetContext(context.Background(), &total, "SELECT @total_tmp as total;")
if err != nil {
t.Fatal(err)
}
}
t.Log(total)
}
@henrylee2cn how about adding your test to the PR?