Skip to content

Instantly share code, notes, and snippets.

@murphybytes
Created November 12, 2016 06:23
Show Gist options
  • Save murphybytes/e562a3d07af1d6d5a7b471fe022a1fa8 to your computer and use it in GitHub Desktop.
Save murphybytes/e562a3d07af1d6d5a7b471fe022a1fa8 to your computer and use it in GitHub Desktop.
Bug in sqlx.In
func (d *Datastore) searchLabelsWithOmits(query string, omit ...uint) ([]kolide.Label, error) {
sqlStatement := `
SELECT *
FROM labels
WHERE MATCH(name)
AGAINST(? IN BOOLEAN MODE)
AND NOT deleted
AND id NOT IN (?)
LIMIT 10
`
sql, inArgs, err := sqlx.In(sqlStatement, omit)
if err != nil {
return nil, errors.DatabaseError(err)
}
sql = d.db.Rebind(sql)
args := []interface{}{
query + "*",
}
args = append(args, inArgs...)
matches := []kolide.Label{}
err = d.db.Select(&matches, sql, args...)
if err != nil {
return nil, errors.DatabaseError(err)
}
return nil, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment