Nico PM
04/19/2023, 8:02 PMexplain analyze
on the queries are what we'd expect (some tables have very few rows, execution time ~1ms) but the time it takes since we perform the query using the Supbase client to when the data is available is many orders of magnitude higher.
Both our backend and Supabase projects are in the same region.
We also noticed that the roundtrip is much faster when using a direct connection to the Postgres DB.
Has anyone experienced this before? Are there any solutions to improve latency?mikel
04/19/2023, 8:11 PMIlgrand
04/19/2023, 8:18 PMfred kufner
04/19/2023, 9:24 PMashman
04/19/2023, 9:45 PMsnelson
04/19/2023, 10:16 PMwax911
04/19/2023, 10:40 PMJoyboy
04/19/2023, 10:51 PMencrypted_password
column. I tried to manually register a user with, let's say 12345678
and hardcode the hash in all rows but as expected, it didn't work.
I was hoping to get a better understanding of the way supabase encrypts passwords and maybe find a way to mokcup a large number of users and still be able to login as any of them.
However, this is my scropt in case it helps:
SQL
BEGIN;
WITH user_values AS (
SELECT
uuid_generate_v4() AS id,
uuid_generate_v4() AS instance_id,
'authenticated' AS aud,
'authenticated' AS role,
(ROW_NUMBER() OVER ()) || '@gmail.com' AS email,
'$2a$10$nc8ek4I97q1rDN6w3jKj8uUuKGF1fMlfKaD1GNPtYDwhW6IVzA39i' AS encrypted_password,
now() AS email_confirmed_at,
NULL::timestamp AS invited_at,
'' AS confirmation_token,
NULL::timestamp AS confirmation_sent_at,
'' AS recovery_token,
NULL::timestamp AS recovery_sent_at,
'' AS email_change_token_new,
'' AS email_change,
NULL::timestamp AS email_change_sent_at,
NULL::timestamp AS last_sign_in_at,
'{"provider":"email","providers":["email"]}'::jsonb AS raw_app_meta_data,
'{}'::jsonb AS raw_user_meta_data,
0::boolean AS is_super_admin,
'2022-10-04 03:41:27.391146+00'::timestamp AS created_at,
'2022-10-04 03:41:27.391146+00'::timestamp AS updated_at,
NULL AS phone,
NULL::timestamp AS phone_confirmed_at,
'' AS phone_change,
'' AS phone_change_token,
NULL::timestamp AS phone_change_sent_at,
'' AS email_change_token_current,
0 AS email_change_confirm_status,
NULL::timestamp AS banned_until,
'' AS reauthentication_token,
NULL::timestamp AS reauthentication_sent_at
FROM generate_series(1, 100)
),
....
SunTzu
04/19/2023, 11:40 PMAnshuman
04/20/2023, 1:14 AMhttps://cdn.discordapp.com/attachments/1098416390618222733/1098416391394185296/image.pngโพ
garyaustin
04/20/2023, 2:00 AMceN
04/20/2023, 1:44 AMDaveNash
04/20/2023, 1:49 AMven
04/20/2023, 2:07 AMAviation
04/20/2023, 3:19 AMCorrupted
04/20/2023, 5:16 AMmetafoo
04/20/2023, 5:33 AMmetafoo
04/20/2023, 5:46 AMFisher
04/20/2023, 7:37 AMcode
:
"23503"
details
:
"Key is not present in table \"users\"."
hint
:
null
message
:
"insert or update on table \"split_members\" violates foreign key constraint \"split_members_user_recipient_address_fkey\""
Ive been banging my head against the wall for hours now lol. Anyone have any words of advice?MaxTechnics
04/20/2023, 7:53 AMHermanus147
04/20/2023, 8:52 AMMarcio
04/20/2023, 8:57 AMtobowers | Crypto Colosseum
04/20/2023, 9:47 AMhttps://esm.sh/ethers@5.7.2
and the function runs perfectly fine locally, but when I go to deploy I'm getting:
Error: Error bundling function: exit status 1
file:///src/import_map.json
file:///src/index.ts
file:///_shared/cors.ts
file:///_shared/serviceClient.ts
error: Uncaught (in promise) Error: Module not found "https://esm.sh/v116/bn.js@5.2.1/index.d.ts".
const ret = new Error(getStringFromWasm0(arg0, arg1));
^
at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19)
at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439)
at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039)
at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894)
at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6)
at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)
Vadorequest
04/20/2023, 11:27 AMstatusText
is always "Created" even when the operation was an update.
I guess this is related to the pgREST plugin, and not directly to Supabase, but I wanted to know if this behavior is expected.
https://cdn.discordapp.com/attachments/1098570667319894118/1098570667634462882/image.pngโพ
SmadreThorkild
04/20/2023, 11:33 AMprofiles
is a foreign table to auth.users
. I use the profiles
.is_admin
column to determine if the authenticated user is admin or a regular user.
I'm trying to create an RLS policy where regular users can only select their own profiles (id = auth.uid()
) but where admins can select all profiles. This currently results in infinite recursion, because I'm selecting is_admin
from the same table in a subquery, resulting in recursion.
Is there any way to either bypass RLS or can I manage user roles in other ways using Supabase/Postgres?
Any help is highly appreciated ๐
The policy I've tried looks like this:
id = auth.uid()
OR EXISTS (
SELECT
is_admin
FROM
profiles AS p
WHERE
p.id = auth.uid()
AND p.is_admin = true
)
https://cdn.discordapp.com/attachments/1098572046335758407/1098572046763573368/Skrmbillede_2023-04-20_kl._13.23.23.pngโพ
jarnold
04/20/2023, 12:03 PMHemingway
04/20/2023, 1:56 PMRoman Vladimirov
04/20/2023, 2:04 PMhttps://cdn.discordapp.com/attachments/1098610108478533652/1098610108633714708/Screenshot_4.pngโพ
https://cdn.discordapp.com/attachments/1098610108478533652/1098610108944097420/Screenshot_3.pngโพ
SunTzu
04/20/2023, 2:04 PMcreate or replace function public.handle_update_user()
returns trigger
language plpgsql
security definer set search_path = public
as $$
begin
update public.profiles
set email = new.email,
full_name = new.raw_user_meta_data->>'full_name',
avatar_url = new.raw_user_meta_data->>'avatar_url',
username = new.raw_user_meta_data->>'username'
where id = new.id;
return new;
end;
$$;
create trigger on_auth_user_updated
after update of email on auth.users
for each row execute procedure public.handle_update_user();
When a user does an update to their account, I was hoping to update the public.profiles table with the additional data they updated. (full_name, username etc).
However it doesnt seem to be running. Is there anything I should change with this?kuna
04/20/2023, 2:41 PM