fixed errors

This commit is contained in:
Timon Ringwald 2022-07-11 13:28:07 +02:00
parent a1e118f200
commit cfeb6940fb
2 changed files with 3 additions and 9 deletions

View File

@ -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{

View File

@ -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 {