elhe26
03/25/2022, 2:11 PM{"code":"42P01","hint":null,"details":null}
Needle
03/25/2022, 2:11 PM/title
command!
We have solved your problem?
Click the button below to archive it.elhe26
03/25/2022, 2:13 PMbegin
insert into public.Users(email, password, acctKey, updatedAt)
values (email, crypt(password, gen_salt('bf')), acctkey, updatedat) returning id, password;
end;
Advanced Settings
Language: * plpgsql*
Type of security: Security Definerlet {data, error } = await supabaseClient.rpc('function_one', {
'email': 'john@example.com',
'password': 'mypass',
'acctkey':'key1',
'updatedat': Date.now()
});
PLPGSQL
, AUTOINC
, and PGCRYPTO
on Extensions page.Scott P
03/25/2022, 2:20 PMUsers
to users
- Quote the table like insert into "public.Users"
(it may also be public."Users"
- I'm not sure as I've only ever dealt with snake_case table names)
The first option can prevent a lot of easily avoidable issues, while the second option is quicker.Needle
03/25/2022, 2:20 PMelhe26
03/25/2022, 2:21 PMinsert into public."users"
or insert into public.users
?Scott P
03/25/2022, 2:24 PMinsert into public."Users"
, or insert into "public.Users"
, but I'm not sure which is correctelhe26
03/25/2022, 2:28 PMsupabaseClient.from("Users").upsert
insert into public."Users"
and I got this error: {"code":"42703","hint":null,"details":null}
Scott P
03/25/2022, 2:36 PM"acctKey"
and "updatedAt"
)elhe26
03/25/2022, 2:36 PMinsert into "public.Users"
: {"code":"42P01","details":null,"hint":null}
public."Users"
is the right way if we're using uppercase names.supabaseClient.from("Users").upsert
with camelcase variables (ie. updatedAt
) and I didn't have any issues. It seems the same cannot be said when defining RPCs.{"hint":null,"code":"42601","details":null}
Scott P
03/25/2022, 2:45 PM.from()
call is run via the PostgREST endpoint, so it's capable of doing some clever mapping based upon the database structure. It's also likely that it quotes the table name to avoid issues.elhe26
03/25/2022, 2:46 PMScott P
03/25/2022, 2:52 PMSELECT * FROM function_name(arg1, arg2, arg3)
The query you listed just above your latest message, try running that directly in the SQL console in the dashboard without begin
or end;
, and add some dummy data for email
password
, acctkey
and updatedat
in the values
part of the query.elhe26
03/25/2022, 3:00 PMbegin
return (select * from public."Keys" where "keyName" = keyname AND "keyLoc" = keyloc limit 1);
end;
column "myKeyName1" does not exist
"myKeyName1"
value is the actual column.Scott P
03/25/2022, 3:25 PMelhe26
03/25/2022, 3:27 PMScott P
03/25/2022, 3:30 PMelhe26
03/25/2022, 6:24 PM