From 15ed05d39f1f7319130ebdc5547434831dbc0d55 Mon Sep 17 00:00:00 2001 From: nisakov Date: Wed, 27 Feb 2019 02:40:23 +0300 Subject: [PATCH] Fix query for getting task from database. --- db/tasks.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/tasks.go b/db/tasks.go index 09bd506..bb3bb1e 100644 --- a/db/tasks.go +++ b/db/tasks.go @@ -167,9 +167,9 @@ func GetTaskByID(username string, id int) (types.Context, error) { var tasks []types.Task var task types.Task - getTaskSQL := "select t.id, t.title, t.content, t.priority, t.hide, c.name from task t join user u left outer join category c where c.id = t.cat_id and t.user_id=u.id and t.id=? and u.username=? union select t.id, t.title, t.content, t.priority, t.hide, 'UNCATEGORIZED' from task t join user u where t.user_id=u.id and t.cat_id=0 ;" + getTaskSQL := "select t.id, t.title, t.content, t.priority, t.hide, c.name from task t join user u left outer join category c where c.id = t.cat_id and t.user_id=u.id and t.id=? and u.username=? union select t.id, t.title, t.content, t.priority, t.hide, 'UNCATEGORIZED' from task t join user u where t.user_id=u.id and t.cat_id=0 and t.id=? and u.username=?;" - rows := database.query(getTaskSQL, id, username) + rows := database.query(getTaskSQL, id, username, id, username) defer rows.Close() if rows.Next() { err := rows.Scan(&task.Id, &task.Title, &task.Content, &task.Priority, &task.IsHidden, &task.Category)