Fixed bug in finish_task()
Due to an error on a column name, finish_task() was broken. It has been fixed.
This commit is contained in:
parent
2051303262
commit
bca6b99068
2 changed files with 42 additions and 1 deletions
|
@ -72,7 +72,7 @@ CREATE FUNCTION finish_task( t_id INT , u_id INT , n_text TEXT )
|
||||||
AS $finish_task$
|
AS $finish_task$
|
||||||
BEGIN
|
BEGIN
|
||||||
PERFORM 1 FROM tasks_single_view t
|
PERFORM 1 FROM tasks_single_view t
|
||||||
WHERE task_id = t_id AND badness = 0;
|
WHERE id = t_id AND badness = 0;
|
||||||
IF NOT FOUND THEN
|
IF NOT FOUND THEN
|
||||||
RETURN 2;
|
RETURN 2;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
--
|
||||||
|
-- Upgrade the database from commit ID 205130326245fa8175bc390ce58b387b92d568a7
|
||||||
|
--
|
||||||
|
-- Run this from the top-level directory
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
\i database/config.sql
|
||||||
|
\c :db_name
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
DROP FUNCTION finish_task( INT , INT , TEXT );
|
||||||
|
CREATE FUNCTION finish_task( t_id INT , u_id INT , n_text TEXT )
|
||||||
|
RETURNS INT
|
||||||
|
STRICT VOLATILE
|
||||||
|
SECURITY INVOKER
|
||||||
|
AS $finish_task$
|
||||||
|
BEGIN
|
||||||
|
PERFORM 1 FROM tasks_single_view t
|
||||||
|
WHERE id = t_id AND badness = 0;
|
||||||
|
IF NOT FOUND THEN
|
||||||
|
RETURN 2;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO completed_tasks ( task_id , user_id )
|
||||||
|
VALUES ( t_id , u_id );
|
||||||
|
EXCEPTION
|
||||||
|
WHEN unique_violation THEN
|
||||||
|
RETURN 1;
|
||||||
|
END;
|
||||||
|
|
||||||
|
UPDATE tasks SET user_id_assigned = NULL WHERE task_id = t_id;
|
||||||
|
INSERT INTO notes ( task_id , user_id , note_text )
|
||||||
|
VALUES ( t_id , u_id , n_text );
|
||||||
|
RETURN 0;
|
||||||
|
END;
|
||||||
|
$finish_task$ LANGUAGE plpgsql;
|
||||||
|
REVOKE EXECUTE ON FUNCTION finish_task( INT , INT , TEXT ) FROM PUBLIC;
|
||||||
|
GRANT EXECUTE ON FUNCTION finish_task( INT , INT , TEXT ) TO :webapp_user;
|
||||||
|
COMMIT;
|
Loading…
Reference in a new issue