diff --git a/README.md b/README.md index 70e4dbd..5372ae6 100644 --- a/README.md +++ b/README.md @@ -84,10 +84,10 @@ one of them is illustrated above (`kpgx.New()`), the other ones have the exact same signature but work on different databases, they are: -- `kpgx.New(ctx, os.Getenv("POSTGRES_URL"), ksql.Config{})` for Postgres, it works on top of `pgxpool` -- `kmysql.New(ctx, os.Getenv("POSTGRES_URL"), ksql.Config{})` for MySQL, it works on top of `database/sql` -- `ksqlserver.New(ctx, os.Getenv("POSTGRES_URL"), ksql.Config{})` for SQLServer, it works on top of `database/sql` -- `ksqlite3.New(ctx, os.Getenv("POSTGRES_URL"), ksql.Config{})` for SQLite3, it works on top of `database/sql` +- `kpgx.New(ctx, os.Getenv("DATABASE_URL"), ksql.Config{})` for Postgres, it works on top of `pgxpool` +- `kmysql.New(ctx, os.Getenv("DATABASE_URL"), ksql.Config{})` for MySQL, it works on top of `database/sql` +- `ksqlserver.New(ctx, os.Getenv("DATABASE_URL"), ksql.Config{})` for SQLServer, it works on top of `database/sql` +- `ksqlite3.New(ctx, os.Getenv("DATABASE_URL"), ksql.Config{})` for SQLite3, it works on top of `database/sql` ## The KSQL Interface @@ -114,7 +114,7 @@ type Provider interface { QueryOne(ctx context.Context, record interface{}, query string, params ...interface{}) error QueryChunks(ctx context.Context, parser ChunkParser) error - Exec(ctx context.Context, query string, params ...interface{}) (rowsAffected int64, _ error) + Exec(ctx context.Context, query string, params ...interface{}) (Result, error) Transaction(ctx context.Context, fn func(Provider) error) error } ``` @@ -292,6 +292,8 @@ func main() { panic(err.Error()) } + fmt.Printf("Users: %#v\n", users) + // Making transactions: err = db.Transaction(ctx, func(db ksql.Provider) error { var cris2 User @@ -307,7 +309,7 @@ func main() { }) if err != nil { // This will also cause an automatic rollback and then panic again - // so that we don't hide the panic inside the KissSQL library + // so that we don't hide the panic inside the KSQL library panic(err.Error()) } @@ -317,8 +319,6 @@ func main() { if err != nil { panic(err.Error()) } - - fmt.Printf("Users: %#v\n", users) } ``` @@ -370,40 +370,43 @@ goos: linux goarch: amd64 pkg: github.com/vingarcia/ksql/benchmarks cpu: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz -BenchmarkInsert/ksql/sql-adapter/insert-one-12 9513 625637 ns/op -BenchmarkInsert/ksql/pgx-adapter/insert-one-12 10000 541374 ns/op -BenchmarkInsert/sql/insert-one-12 9369 618969 ns/op -BenchmarkInsert/sql/prep-stmt/insert-one-12 10000 551131 ns/op -BenchmarkInsert/sqlx/insert-one-12 9328 629889 ns/op -BenchmarkInsert/pgxpool/insert-one-12 10000 542283 ns/op -BenchmarkInsert/gorm/insert-one-12 8716 675421 ns/op -BenchmarkInsert/sqlc/insert-one-12 9446 629378 ns/op -BenchmarkInsert/sqlc/prep-stmt/insert-one-12 10000 553632 ns/op -BenchmarkInsert/sqlboiler/insert-one-12 9595 633391 ns/op -BenchmarkQuery/ksql/sql-adapter/single-row-12 40746 146739 ns/op -BenchmarkQuery/ksql/sql-adapter/multiple-rows-12 37886 156191 ns/op -BenchmarkQuery/ksql/pgx-adapter/single-row-12 79155 71939 ns/op -BenchmarkQuery/ksql/pgx-adapter/multiple-rows-12 73729 83560 ns/op -BenchmarkQuery/sql/single-row-12 42253 143241 ns/op -BenchmarkQuery/sql/multiple-rows-12 40456 149423 ns/op -BenchmarkQuery/sql/prep-stmt/single-row-12 83389 72348 ns/op -BenchmarkQuery/sql/prep-stmt/multiple-rows-12 77712 76644 ns/op -BenchmarkQuery/sqlx/single-row-12 41792 145506 ns/op -BenchmarkQuery/sqlx/multiple-rows-12 39500 151435 ns/op -BenchmarkQuery/pgxpool/single-row-12 85870 69418 ns/op -BenchmarkQuery/pgxpool/multiple-rows-12 79922 73978 ns/op -BenchmarkQuery/gorm/single-row-12 77432 78407 ns/op -BenchmarkQuery/gorm/multiple-rows-12 61074 96030 ns/op -BenchmarkQuery/sqlc/single-row-12 42672 145121 ns/op -BenchmarkQuery/sqlc/multiple-rows-12 40122 149068 ns/op -BenchmarkQuery/sqlc/prep-stmt/single-row-12 81829 73210 ns/op -BenchmarkQuery/sqlc/prep-stmt/multiple-rows-12 74799 78834 ns/op -BenchmarkQuery/sqlboiler/single-row-12 64158 93305 ns/op -BenchmarkQuery/sqlboiler/multiple-rows-12 64686 92270 ns/op +BenchmarkInsert/ksql/sql-adapter/insert-one-12 9358 630699 ns/op +BenchmarkInsert/ksql/pgx-adapter/insert-one-12 10000 548489 ns/op +BenchmarkInsert/sql/insert-one-12 9601 631485 ns/op +BenchmarkInsert/sql/prep-stmt/insert-one-12 10000 558009 ns/op +BenchmarkInsert/sqlx/insert-one-12 9688 637395 ns/op +BenchmarkInsert/sqlx/prep-stmt/insert-one-12 10000 555805 ns/op +BenchmarkInsert/pgxpool/insert-one-12 10000 558187 ns/op +BenchmarkInsert/gorm/insert-one-12 8671 690290 ns/op +BenchmarkInsert/sqlc/insert-one-12 9710 636395 ns/op +BenchmarkInsert/sqlc/prep-stmt/insert-one-12 10000 572243 ns/op +BenchmarkInsert/sqlboiler/insert-one-12 9693 645475 ns/op +BenchmarkQuery/ksql/sql-adapter/single-row-12 42440 139913 ns/op +BenchmarkQuery/ksql/sql-adapter/multiple-rows-12 39391 152663 ns/op +BenchmarkQuery/ksql/pgx-adapter/single-row-12 81457 70102 ns/op +BenchmarkQuery/ksql/pgx-adapter/multiple-rows-12 74710 81578 ns/op +BenchmarkQuery/sql/single-row-12 43040 139945 ns/op +BenchmarkQuery/sql/multiple-rows-12 41533 143923 ns/op +BenchmarkQuery/sql/prep-stmt/single-row-12 89296 69676 ns/op +BenchmarkQuery/sql/prep-stmt/multiple-rows-12 78828 75760 ns/op +BenchmarkQuery/sqlx/single-row-12 41727 141424 ns/op +BenchmarkQuery/sqlx/multiple-rows-12 41360 148159 ns/op +BenchmarkQuery/sqlx/prep-stmt/single-row-12 81553 68347 ns/op +BenchmarkQuery/sqlx/prep-stmt/multiple-rows-12 77161 77070 ns/op +BenchmarkQuery/pgxpool/single-row-12 85140 68628 ns/op +BenchmarkQuery/pgxpool/multiple-rows-12 76016 73659 ns/op +BenchmarkQuery/gorm/single-row-12 79791 74779 ns/op +BenchmarkQuery/gorm/multiple-rows-12 63621 94351 ns/op +BenchmarkQuery/sqlc/single-row-12 41904 142480 ns/op +BenchmarkQuery/sqlc/multiple-rows-12 39877 147798 ns/op +BenchmarkQuery/sqlc/prep-stmt/single-row-12 84484 68351 ns/op +BenchmarkQuery/sqlc/prep-stmt/multiple-rows-12 81837 76040 ns/op +BenchmarkQuery/sqlboiler/single-row-12 67383 90907 ns/op +BenchmarkQuery/sqlboiler/multiple-rows-12 64791 91555 ns/op PASS -ok github.com/vingarcia/ksql/benchmarks 200.547s -Benchmark executed at: 2022-07-26 -Benchmark executed on commit: 3d34bae47e90ff84d87ba47a2fad81d21390c5ec +ok github.com/vingarcia/ksql/benchmarks 228.871s +Benchmark executed at: 2022-09-29 +Benchmark executed on commit: fc2b32d91965404c2479aa3d1be904b5a4c217f4 ``` ## Running the KSQL tests (for contributors) diff --git a/adapters/kmysql/kmysql.go b/adapters/kmysql/kmysql.go index 1419411..8241d19 100644 --- a/adapters/kmysql/kmysql.go +++ b/adapters/kmysql/kmysql.go @@ -16,7 +16,7 @@ func NewFromSQLDB(db *sql.DB) (ksql.DB, error) { return ksql.NewWithAdapter(NewSQLAdapter(db), "mysql") } -// New instantiates a new KissSQL client using the "mysql" driver +// New instantiates a new KSQL client using the "mysql" driver func New( _ context.Context, connectionString string, diff --git a/adapters/ksqlite3/ksqlite3.go b/adapters/ksqlite3/ksqlite3.go index a545e2a..4850654 100644 --- a/adapters/ksqlite3/ksqlite3.go +++ b/adapters/ksqlite3/ksqlite3.go @@ -16,7 +16,7 @@ func NewFromSQLDB(db *sql.DB) (ksql.DB, error) { return ksql.NewWithAdapter(NewSQLAdapter(db), "sqlite3") } -// New instantiates a new KissSQL client using the "sqlite3" driver +// New instantiates a new KSQL client using the "sqlite3" driver func New( _ context.Context, connectionString string, diff --git a/adapters/ksqlserver/ksqlserver.go b/adapters/ksqlserver/ksqlserver.go index 6999df2..94dd775 100644 --- a/adapters/ksqlserver/ksqlserver.go +++ b/adapters/ksqlserver/ksqlserver.go @@ -16,7 +16,7 @@ func NewFromSQLDB(db *sql.DB) (ksql.DB, error) { return ksql.NewWithAdapter(NewSQLAdapter(db), "sqlserver") } -// New instantiates a new KissSQL client using the "sqlserver" driver +// New instantiates a new KSQL client using the "sqlserver" driver func New( _ context.Context, connectionString string, diff --git a/benchmarks/benchmarks_test.go b/benchmarks/benchmarks_test.go index fedfb81..8b15f51 100644 --- a/benchmarks/benchmarks_test.go +++ b/benchmarks/benchmarks_test.go @@ -213,6 +213,48 @@ func BenchmarkInsert(b *testing.B) { }) }) + b.Run("sqlx/prep-stmt", func(b *testing.B) { + sqlxDB, err := sqlx.Open(driver, connStr) + if err != nil { + b.Fatalf("error creating sqlx client: %s", err) + } + sqlxDB.SetMaxOpenConns(1) + + err = recreateTable(connStr) + if err != nil { + b.Fatalf("error creating table: %s", err.Error()) + } + + insertOne, err := sqlxDB.Prepare(`INSERT INTO users(name, age) VALUES ($1, $2) RETURNING id`) + if err != nil { + b.Fatalf("could not prepare sql insert query: %s", err.Error()) + } + + b.Run("insert-one", func(b *testing.B) { + for i := 0; i < b.N; i++ { + user := User{ + Name: strconv.Itoa(i), + Age: i, + } + rows, err := insertOne.QueryContext(ctx, user.Name, user.Age) + if err != nil { + b.Fatalf("insert error: %s", err.Error()) + } + if !rows.Next() { + b.Fatalf("missing id from inserted record") + } + err = rows.Scan(&user.ID) + if err != nil { + b.Fatalf("error scanning rows") + } + err = rows.Close() + if err != nil { + b.Fatalf("error closing rows") + } + } + }) + }) + b.Run("pgxpool", func(b *testing.B) { pgxConf, err := pgxpool.ParseConfig(connStr) if err != nil { @@ -678,6 +720,84 @@ func BenchmarkQuery(b *testing.B) { }) }) + b.Run("sqlx/prep-stmt", func(b *testing.B) { + sqlxDB, err := sqlx.Open(driver, connStr) + if err != nil { + b.Fatalf("error creating sqlx client: %s", err) + } + sqlxDB.SetMaxOpenConns(1) + + err = recreateTable(connStr) + if err != nil { + b.Fatalf("error creating table: %s", err.Error()) + } + + err = insertUsers(connStr, 100) + if err != nil { + b.Fatalf("error inserting users: %s", err.Error()) + } + + singleRow, err := sqlxDB.Preparex(`SELECT id, name, age FROM users OFFSET $1 LIMIT 1`) + if err != nil { + b.Fatalf("error preparing sql statement for single row: %s", err.Error()) + } + + multipleRows, err := sqlxDB.Preparex(`SELECT id, name, age FROM users OFFSET $1 LIMIT 10`) + if err != nil { + b.Fatalf("error preparing sql statement for multiple rows: %s", err.Error()) + } + + b.Run("single-row", func(b *testing.B) { + for i := 0; i < b.N; i++ { + var user User + rows, err := singleRow.QueryxContext(ctx, i%100) + if err != nil { + b.Fatalf("query error: %s", err.Error()) + } + if !rows.Next() { + b.Fatalf("missing user from inserted record, offset: %d", i%100) + } + err = rows.StructScan(&user) + if err != nil { + b.Fatalf("error scanning rows") + } + err = rows.Close() + if err != nil { + b.Fatalf("error closing rows") + } + } + }) + + b.Run("multiple-rows", func(b *testing.B) { + for i := 0; i < b.N; i++ { + var users []User + rows, err := multipleRows.QueryxContext(ctx, i%90) + if err != nil { + b.Fatalf("query error: %s", err.Error()) + } + for j := 0; j < 10; j++ { + if !rows.Next() { + b.Fatalf("missing user from inserted record, offset: %d", i%90) + } + var user User + rows.StructScan(&user) + if err != nil { + b.Fatalf("error scanning rows") + } + users = append(users, user) + } + if len(users) < 10 { + b.Fatalf("expected 10 scanned users, but got: %d", len(users)) + } + + err = rows.Close() + if err != nil { + b.Fatalf("error closing rows") + } + } + }) + }) + b.Run("pgxpool", func(b *testing.B) { pgxConf, err := pgxpool.ParseConfig(connStr) if err != nil { diff --git a/contracts.go b/contracts.go index 5ed26d5..3de2e8e 100644 --- a/contracts.go +++ b/contracts.go @@ -4,12 +4,10 @@ import ( "context" "database/sql" "fmt" - - "github.com/pkg/errors" ) // ErrRecordNotFound ... -var ErrRecordNotFound error = errors.Wrap(sql.ErrNoRows, "ksql: the query returned no results") +var ErrRecordNotFound error = fmt.Errorf("ksql: the query returned no results: %w", sql.ErrNoRows) // ErrAbortIteration ... var ErrAbortIteration error = fmt.Errorf("ksql: abort iteration, should only be used inside QueryChunks function") diff --git a/examples/crud/crud.go b/examples/crud/crud.go index d6bd271..ab84fbe 100644 --- a/examples/crud/crud.go +++ b/examples/crud/crud.go @@ -149,6 +149,8 @@ func main() { panic(err.Error()) } + fmt.Printf("Users: %#v\n", users) + // Making transactions: err = db.Transaction(ctx, func(db ksql.Provider) error { var cris2 User @@ -164,7 +166,7 @@ func main() { }) if err != nil { // This will also cause an automatic rollback and then panic again - // so that we don't hide the panic inside the KissSQL library + // so that we don't hide the panic inside the KSQL library panic(err.Error()) } @@ -174,6 +176,4 @@ func main() { if err != nil { panic(err.Error()) } - - fmt.Printf("Users: %#v\n", users) } diff --git a/go.mod b/go.mod index de82d8f..8e28016 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.14 require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/kr/pretty v0.2.1 // indirect - github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect ) diff --git a/go.sum b/go.sum index d13690f..7413aff 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,6 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/kbuilder/query.go b/kbuilder/query.go index f6d0a9e..c88e01c 100644 --- a/kbuilder/query.go +++ b/kbuilder/query.go @@ -7,7 +7,6 @@ import ( "strings" "sync" - "github.com/pkg/errors" "github.com/vingarcia/ksql" "github.com/vingarcia/ksql/internal/structs" ) @@ -52,7 +51,7 @@ func (q Query) BuildQuery(dialect ksql.Dialect) (sqlQuery string, params []inter default: selectQuery, err := buildSelectQuery(v, dialect) if err != nil { - return "", nil, errors.Wrap(err, "error reading the Select field") + return "", nil, fmt.Errorf("error reading the Select field: %w", err) } b.WriteString("SELECT " + selectQuery) } diff --git a/ksql.go b/ksql.go index 22ba52f..4a9c4f0 100644 --- a/ksql.go +++ b/ksql.go @@ -10,7 +10,6 @@ import ( "sync" "unicode" - "github.com/pkg/errors" "github.com/vingarcia/ksql/internal/modifiers" "github.com/vingarcia/ksql/internal/structs" "github.com/vingarcia/ksql/ksqltest" @@ -605,7 +604,7 @@ func normalizeIDsAsMap(idNames []string, idOrMap interface{}) (idMap map[string] case reflect.Struct: idMap, err = ksqltest.StructToMap(idOrMap) if err != nil { - return nil, errors.Wrapf(err, "could not get ID(s) from input record") + return nil, fmt.Errorf("could not get ID(s) from input record: %w", err) } case reflect.Map: var ok bool @@ -900,8 +899,9 @@ func (c DB) Transaction(ctx context.Context, fn func(Provider) error) error { if r := recover(); r != nil { rollbackErr := tx.Rollback(ctx) if rollbackErr != nil { - r = errors.Wrap(rollbackErr, - fmt.Sprintf("KSQL: unable to rollback after panic with value: %v", r), + r = fmt.Errorf( + "KSQL: unable to rollback after panic with value: %v, rollback error: %w", + r, rollbackErr, ) } panic(r) @@ -915,8 +915,9 @@ func (c DB) Transaction(ctx context.Context, fn func(Provider) error) error { if err != nil { rollbackErr := tx.Rollback(ctx) if rollbackErr != nil { - err = errors.Wrap(rollbackErr, - fmt.Sprintf("KSQL: unable to rollback after error: %s", err.Error()), + err = fmt.Errorf( + "KSQL: unable to rollback after error: %s, rollback error: %w", + err.Error(), rollbackErr, ) } return err diff --git a/ksqltest/testhelpers.go b/ksqltest/testhelpers.go index c9f0099..25504bc 100644 --- a/ksqltest/testhelpers.go +++ b/ksqltest/testhelpers.go @@ -4,8 +4,6 @@ import ( "fmt" "reflect" - "github.com/pkg/errors" - "github.com/vingarcia/ksql/internal/structs" ) @@ -67,7 +65,7 @@ func FillStructWith(record interface{}, dbRow map[string]interface{}) error { destValue, err := src.Convert(destType) if err != nil { - return errors.Wrap(err, fmt.Sprintf("FillStructWith: error on field `%s`", colName)) + return fmt.Errorf("FillStructWith: error on field `%s`: %w", colName, err) } dest.Set(destValue) @@ -94,7 +92,7 @@ func FillSliceWith(entities interface{}, dbRows []map[string]interface{}) error structType, isSliceOfPtrs, err := structs.DecodeAsSliceOfStructs(sliceType.Elem()) if err != nil { - return errors.Wrap(err, "FillSliceWith") + return fmt.Errorf("FillSliceWith: %w", err) } slice := sliceRef.Elem() @@ -110,7 +108,7 @@ func FillSliceWith(entities interface{}, dbRows []map[string]interface{}) error err := FillStructWith(slice.Index(idx).Addr().Interface(), row) if err != nil { - return errors.Wrap(err, "FillSliceWith") + return fmt.Errorf("FillSliceWith: %w", err) } } diff --git a/kstructs/testhelpers.go b/kstructs/testhelpers.go index d4c8baf..a888614 100644 --- a/kstructs/testhelpers.go +++ b/kstructs/testhelpers.go @@ -5,8 +5,6 @@ import ( "fmt" "reflect" - "github.com/pkg/errors" - "github.com/vingarcia/ksql/internal/structs" ) @@ -72,7 +70,7 @@ func FillStructWith(record interface{}, dbRow map[string]interface{}) error { destValue, err := src.Convert(destType) if err != nil { - return errors.Wrap(err, fmt.Sprintf("FillStructWith: error on field `%s`", colName)) + return fmt.Errorf("FillStructWith: error on field `%s`: %w", colName, err) } dest.Set(destValue) @@ -101,7 +99,7 @@ func FillSliceWith(entities interface{}, dbRows []map[string]interface{}) error structType, isSliceOfPtrs, err := structs.DecodeAsSliceOfStructs(sliceType.Elem()) if err != nil { - return errors.Wrap(err, "FillSliceWith") + return fmt.Errorf("FillSliceWith: %w", err) } slice := sliceRef.Elem() @@ -117,7 +115,7 @@ func FillSliceWith(entities interface{}, dbRows []map[string]interface{}) error err := FillStructWith(slice.Index(idx).Addr().Interface(), row) if err != nil { - return errors.Wrap(err, "FillSliceWith") + return fmt.Errorf("FillSliceWith: %w", err) } } diff --git a/test_adapters.go b/test_adapters.go index 30474ad..6cee443 100644 --- a/test_adapters.go +++ b/test_adapters.go @@ -8,7 +8,6 @@ import ( "io" "testing" - "github.com/pkg/errors" "github.com/vingarcia/ksql/internal/modifiers" tt "github.com/vingarcia/ksql/internal/testtools" "github.com/vingarcia/ksql/nullable" @@ -498,7 +497,7 @@ func QueryTest( }, NextFn: func() bool { return true }, ScanFn: func(values ...interface{}) error { - return errors.New("fakeScanErr") + return fmt.Errorf("fakeScanErr") }, }, nil }, @@ -524,7 +523,7 @@ func QueryTest( return nil }, ErrFn: func() error { - return errors.New("fakeErrMsg") + return fmt.Errorf("fakeErrMsg") }, }, nil }, @@ -550,7 +549,7 @@ func QueryTest( return nil }, CloseFn: func() error { - return errors.New("fakeCloseErr") + return fmt.Errorf("fakeCloseErr") }, }, nil }, @@ -2115,7 +2114,7 @@ func QueryChunksTest( ForEachChunk: func(buffer []user) error { lengths = append(lengths, len(buffer)) users = append(users, buffer...) - return errors.New("fake error msg") + return fmt.Errorf("fake error msg") }, }) @@ -2144,7 +2143,7 @@ func QueryChunksTest( _ = c.Insert(ctx, usersTable, &user{Name: "User2"}) _ = c.Insert(ctx, usersTable, &user{Name: "User3"}) - returnVals := []error{nil, errors.New("fake error msg")} + returnVals := []error{nil, fmt.Errorf("fake error msg")} var lengths []int var users []user err = c.QueryChunks(ctx, ChunkParser{ @@ -2358,7 +2357,7 @@ func TransactionTest( _, err = db.Exec(ctx, "UPDATE users SET age = 22") tt.AssertNoErr(t, err) - return errors.New("fake-error") + return fmt.Errorf("fake-error") }) tt.AssertNotEqual(t, err, nil) tt.AssertEqual(t, err.Error(), "fake-error")