Do not record duplicate queries into history

This commit is contained in:
Dan Sosedoff
2016-01-07 20:55:23 -06:00
parent 1bc824e39b
commit 9b5764d4fb
2 changed files with 26 additions and 3 deletions

View File

@@ -150,7 +150,7 @@ func (client *Client) Query(query string) (*Result, error) {
res, err := client.query(query)
// Save history records only if query did not fail
if err == nil {
if err == nil && !client.hasHistoryRecord(query) {
client.History = append(client.History, history.NewRecord(query))
}
@@ -223,3 +223,16 @@ func (client *Client) fetchRows(q string) ([]string, error) {
return results, nil
}
func (client *Client) hasHistoryRecord(query string) bool {
result := false
for _, record := range client.History {
if record.Query == query {
result = true
break
}
}
return result
}