From cfeb6940fb68805e860b6b6f4005690809764b13 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Mon, 11 Jul 2022 13:28:07 +0200 Subject: [PATCH] fixed errors --- db_test.go | 7 ++----- insert.go | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/db_test.go b/db_test.go index 444bdcd..3372420 100644 --- a/db_test.go +++ b/db_test.go @@ -28,17 +28,14 @@ func UpdateUserByNameEncoder(u *User, encode EncodeFunc) error { } func TestDB(t *testing.T) { - db, err := NewMysqlDatabase("ip", 3306, "username", "password", "database") - if err != nil { - t.Fatal(err) - } + db := NewMysqlDatabase("ip", 3306, "username", "password", "database") defer db.Close() insertUser := Insert(db, "INSERT INTO users VALUES (?, ?, ?)", InsertUserEncoder) updateUser := Update(db, "UPDATE users SET salt = ? WHERE name = ?", UpdateUserByNameEncoder) - getUsers := Query(db, "SELECT * FROM users WHERE name = ?", UserDecoder) + getUsers := QueryMany(db, "SELECT * FROM users WHERE name = ?", UserDecoder) pw := sha512.Sum512([]byte("weiter")) timon := &User{ diff --git a/insert.go b/insert.go index 878a531..5bcf90e 100644 --- a/insert.go +++ b/insert.go @@ -1,10 +1,7 @@ package advsql func Insert[T any](db *Database, query string, encoder func(v *T, encode EncodeFunc) error) InsertFunc[T] { - s, err := db.prepare(query) - if err != nil { - panic(err) - } + s := db.prepare(query) return func(value *T) error { return encoder(value, func(args ...interface{}) error {