I'm trying to access the invited_at column in a da...
# help
n
I'm trying to access the invited_at column in a database function when a new user is inserted. I have an if statement that says
if new.invited_at IS NOT NULL
The if statement itself works fine, however, invited_at is checked and is seen as null even though it's not. Any clue what's happening?
n
Hello @Nin! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
n
Copy code
begin
  if new.invited_at IS NOT NULL then
    insert into public.users (user_id, user_email, temp)
    values (new.id, new.email, 1); return new;
  else
    insert into public.users (user_id, user_email)
    values (new.id, new.email);
    return new;
  END if;
end;
Full function for reference
s
When does this function called or how is this function called?
Is it a trigger function or a normal function that you call with the
.rpc
method of the supabase library?
n
When a new user is created
trigger function
Basically, I want to differentiate between whether a user is signed up or when a user is invited
s
Is the trigger a BEFORE INSERT or AFTER INSERT?
n
AFTER insert
Is that why new. isn't working?
s
new should still work
I have a similar function that is working but I'm checking if the value is null rather than not null.
n
When my other question is 'working' I can steal your code and do the check on that :p
s
Haha
n
Thread was archived by @Nin. Anyone can send a message to unarchive it.