diff --git a/postgres.go b/postgres.go index 42c3e43..65bd5ab 100644 --- a/postgres.go +++ b/postgres.go @@ -26,8 +26,9 @@ func (c Client) Find( ctx context.Context, item interface{}, query string, + params ...interface{}, ) error { - it := c.db.Raw(query) + it := c.db.Raw(query, params...) it.Scan(item) return it.Error } diff --git a/postgres_test.go b/postgres_test.go index ef022bc..cc31d78 100644 --- a/postgres_test.go +++ b/postgres_test.go @@ -51,7 +51,7 @@ func TestFind(t *testing.T) { tableName: "users", } u := User{} - err = c.Find(ctx, &u, `SELECT * FROM users WHERE name='Bia';`) + err = c.Find(ctx, &u, `SELECT * FROM users WHERE name=?;`, "Bia") assert.Equal(t, err, nil) assert.Equal(t, "Bia", u.Name)