mirror of https://github.com/VinGarcia/ksql.git
Add feature of escaping params to Find function
This change was made based on a suggestion from Raí Tamarindo (raitamarindo@gmail.com)pull/2/head
parent
387c2cdd74
commit
25e00fdad6
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue