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 Definerelhe26
03/25/2022, 2:13 PMlet {data, error } = await supabaseClient.rpc('function_one', {
'email': 'john@example.com',
'password': 'mypass',
'acctkey':'key1',
'updatedat': Date.now()
});elhe26
03/25/2022, 2:13 PMPLPGSQL, 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 PMelhe26
03/25/2022, 2:23 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").upsertelhe26
03/25/2022, 2:33 PMelhe26
03/25/2022, 2:34 PMinsert 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}elhe26
03/25/2022, 2:38 PMpublic."Users" is the right way if we're using uppercase names.elhe26
03/25/2022, 2:40 PMsupabaseClient.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.elhe26
03/25/2022, 2:45 PM{"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.Scott P
03/25/2022, 2:45 PMelhe26
03/25/2022, 2:46 PMelhe26
03/25/2022, 2:47 PMelhe26
03/25/2022, 2:48 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 PMelhe26
03/25/2022, 3:04 PMbegin
return (select * from public."Keys" where "keyName" = keyname AND "keyLoc" = keyloc limit 1);
end;elhe26
03/25/2022, 3:05 PMcolumn "myKeyName1" does not existelhe26
03/25/2022, 3:23 PMelhe26
03/25/2022, 3:24 PM"myKeyName1" value is the actual column.elhe26
03/25/2022, 3:25 PMScott P
03/25/2022, 3:25 PMelhe26
03/25/2022, 3:27 PMelhe26
03/25/2022, 3:29 PMScott P
03/25/2022, 3:30 PMelhe26
03/25/2022, 6:24 PMelhe26
03/25/2022, 6:27 PM