HTTP API: fix for POST /api/dashboards/db returned 200 ok when dashboard was not found, Fixes #1929

This commit is contained in:
Torkel Ödegaard
2015-05-04 07:46:53 +02:00
parent 697529d0e8
commit 73ee8a5985
4 changed files with 28 additions and 3 deletions
+8 -2
View File
@@ -48,13 +48,19 @@ func SaveDashboard(cmd *m.SaveDashboardCommand) error {
}
}
affectedRows := int64(0)
if dash.Id == 0 {
metrics.M_Models_Dashboard_Insert.Inc(1)
_, err = sess.Insert(dash)
affectedRows, err = sess.Insert(dash)
} else {
dash.Version += 1
dash.Data["version"] = dash.Version
_, err = sess.Id(dash.Id).Update(dash)
affectedRows, err = sess.Id(dash.Id).Update(dash)
}
if affectedRows == 0 {
return m.ErrDashboardNotFound
}
// delete existing tabs