MCPcopy
hub / github.com/go-sql-driver/mysql / TestFoundRows1

Function TestFoundRows1

driver_test.go:1433–1455  ·  driver_test.go::TestFoundRows1
(t *testing.T)

Source from the content-addressed store, hash-verified

1431}
1432
1433func TestFoundRows1(t *testing.T) {
1434 runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
1435 dbt.mustExec("CREATE TABLE " + tbl + " (id INT NOT NULL ,data INT NOT NULL)")
1436 dbt.mustExec("INSERT INTO " + tbl + " (id, data) VALUES (0, 0),(0, 0),(1, 0),(1, 0),(1, 1)")
1437
1438 res := dbt.mustExec("UPDATE " + tbl + " SET data = 1 WHERE id = 0")
1439 count, err := res.RowsAffected()
1440 if err != nil {
1441 dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
1442 }
1443 if count != 2 {
1444 dbt.Fatalf("Expected 2 affected rows, got %d", count)
1445 }
1446 res = dbt.mustExec("UPDATE " + tbl + " SET data = 1 WHERE id = 1")
1447 count, err = res.RowsAffected()
1448 if err != nil {
1449 dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
1450 }
1451 if count != 2 {
1452 dbt.Fatalf("Expected 2 affected rows, got %d", count)
1453 }
1454 })
1455}
1456
1457func TestFoundRows2(t *testing.T) {
1458 runTestsParallel(t, dsn+"&clientFoundRows=true", func(dbt *DBTest, tbl string) {

Callers

nothing calls this directly

Calls 4

runTestsParallelFunction · 0.85
mustExecMethod · 0.80
RowsAffectedMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected