Created
November 12, 2016 06:23
-
-
Save murphybytes/e562a3d07af1d6d5a7b471fe022a1fa8 to your computer and use it in GitHub Desktop.
Bug in sqlx.In
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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