Albert [tox/cis]
02/24/2022, 11:27 AMsql
create or replace function foo(id uuid) returns boolean as $$
begin
update tablename set bar='test';
return true;
end
$$ language plpgsql;
This returns true
but the table rows are not updated. When commenting out everything except the update query, it updates as expected. Why?tmw
02/26/2022, 9:36 PMtmw
02/26/2022, 9:36 PMALTER TABLE table_name
ADD CONSTRAINT column_name_unique UNIQUE (column_name);
tmw
02/26/2022, 9:37 PMgaryaustin
02/26/2022, 10:40 PM2old4this
02/27/2022, 8:03 PMgaryaustin
02/27/2022, 8:11 PMgaryaustin
02/27/2022, 8:14 PM2old4this
02/27/2022, 8:14 PM2old4this
02/27/2022, 8:15 PMmangysaurus
03/02/2022, 12:29 AMDeadlyDev
03/02/2022, 6:46 PMid task_id project_id project_task_number
------------------------------------------------
1 15 42 1
2 16 42 2
3 17 44 1
4 18 44 2
5 19 45 1
6 20 42 3
7 21 42 4
What is the best way to go about this?garyaustin
03/02/2022, 7:33 PMasleepingpanda
03/03/2022, 5:28 PMtype "shortkey" does not exist
Scott P
03/03/2022, 5:34 PMpg_shortkey
extension isn't installed in the database, meaning the types it generates don't exist. There's a thread for extension suggestions available at https://github.com/supabase/supabase/discussions/679asleepingpanda
03/03/2022, 5:38 PMScott P
03/03/2022, 5:43 PMFacu
03/03/2022, 7:13 PM'uuid_generate_v4()'
Scott P
03/03/2022, 7:15 PMFacu
03/03/2022, 7:25 PMSELECT EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000;
Scott P
03/03/2022, 7:25 PMFacu
03/03/2022, 7:27 PMasleepingpanda
03/04/2022, 3:27 AMmodified_by
to the current user's uuid. All the triggers are set correctly, but when i update a row from the Table Editor, nothing happens. Am I missing something?
-- Create function for updating the modified_by column
CREATE OR REPLACE FUNCTION sync_modified_by()
RETURNS trigger AS
$$
BEGIN
NEW.modified_by := auth.uid();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
garyaustin
03/04/2022, 3:35 AMasleepingpanda
03/04/2022, 3:38 AMgaryaustin
03/04/2022, 3:39 AMasleepingpanda
03/05/2022, 3:04 AMCREATE OR REPLACE FUNCTION get_folder_tree(sk varchar)
RETURNS TABLE (id int, name text, parent_id int, shortkey varchar)
AS $$
BEGIN
RETURN QUERY
WITH RECURSIVE
-- starting node(s)
starting (id, name, parent_id, shortkey) AS
(
SELECT t.id, t.name, t.parent_id, t.shortkey
FROM folders AS t
WHERE t.shortkey = sk
),
descendants (id, name, parent_id, shortkey) AS
(
SELECT s.id, s.name, s.parent_id, s.shortkey
FROM starting AS s
UNION ALL
SELECT t.id, t.name, t.parent_id, t.shortkey
FROM folders AS t JOIN descendants AS d ON t.parent_id = d.id
),
ancestors (id, name, parent_id, shortkey) AS
(
SELECT t.id, t.name, t.parent_id, t.shortkey
FROM folders AS t
WHERE t.id IN (SELECT parent_id FROM starting)
UNION ALL
SELECT t.id, t.name, t.parent_id, t.shortkey
FROM folders AS t JOIN ancestors AS a ON t.id = a.parent_id
)
TABLE ancestors
UNION ALL
TABLE descendants ;
END;
$$ LANGUAGE plpgsql;
Error: column reference "parent_id" is ambiguous
garyaustin
03/05/2022, 3:28 AMtourdownunder
03/05/2022, 4:00 AMsql
(SELECT s.parent_id FROM starting s)
asleepingpanda
03/05/2022, 4:32 AM