Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Fix duplicate query insert error message
Browse files Browse the repository at this point in the history
* Return appropriate error message when attempting to insert a query by
ID that already exists in the DB.
  • Loading branch information
nyanshak committed Oct 19, 2020
1 parent 6b576ad commit 102ea1b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/datastore/mysql/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ func (d *Datastore) NewQuery(query *kolide.Query, opts ...kolide.OptionalArg) (*
) VALUES ( ?, ?, ?, ?, ? )
`
result, err := db.Exec(sqlStatement, query.Name, query.Description, query.Query, query.Saved, query.AuthorID)
if err != nil {

if err != nil && isDuplicate(err) {
return nil, alreadyExists("Query", 0)
} else if err != nil {
return nil, errors.Wrap(err, "creating new Query")
}

Expand Down

0 comments on commit 102ea1b

Please sign in to comment.