Hi all, how can we get more details about the sql ...
# sql
d
Hi all, how can we get more details about the sql execution? I have 2 triggers that calls their own function on my insert one before the insert to update the column value and one to update another table, my problem is only the second one is happening and I can't seem to find any details why the other is not happening
b
Can you post some sample code? That would help us try to debug what's going on.
Debugging triggers can be difficult because you don't get any information back when things fail. That's why, for my SupaScript library (Javascript / NodeJS wrapper for PLV8) I mapped the
console.log
function so it writes output to a log table, then I can view the log table to see what's going on. Maybe you can do something similar in your trigger(s)?
d
here is the code for the before insert
Copy code
BEGIN
    new.admin_id = auth.uid();
    RETURN NEW;
  END;
here is the code for after insert
Copy code
BEGIN
  UPDATE public.user_profile
  SET company_id = new.company_id
  WHERE id = auth.uid();
  RETURN NEW;
END;
actually I have not started on my front end yet as right now I am focused on ensuring the database security is in place via RLS