Jokcy
04/17/2023, 1:34 PMLukas V
04/17/2023, 1:51 PMcreators
and I have a column relevance_score
, I don't want creators to be able to edit their relevance score, themselves, so is there a way to create a RLS policy that prevents users to update that column themselves?mikel
04/17/2023, 3:25 PMhttps://cdn.discordapp.com/attachments/1097543368264908900/1097543368508198922/7bb56946-3e7c-45d9-8147-366f7bdb2c40.png▾
https://cdn.discordapp.com/attachments/1097543368264908900/1097543368801787914/6868ec6a-1c67-4871-8fb4-fefe65559205.png▾
netdesignr
04/17/2023, 3:39 PMdoorknob88
04/17/2023, 5:40 PMCREATE FUNCTION test_credentials()
RETURNS TRIGGER
AS $$
BEGIN
IF (NEW.phone = ANY(array['<test-phone1>', '<test-phone2>'])) THEN
NEW.confirmation_token := '123456';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER test_credentials BEFORE INSERT OR UPDATE ON auth.users FOR EACH ROW EXECUTE PROCEDURE test_credentials();
to setup a trigger to setup an override for a particular phone number. it worked on my local self hosted setup but when i set it up against https://app.supabase.com/ , it doesn't seem to work.
I checked the table value being altered and noticed that the confirmation tokens in the users table is being hashed/encoded to some string so that the confirmation token value isn't exposed (which isn't the case for when my function overrides it.)
I'm wondering where I can find what that hash function is so that my overridden confirmation token can be used.marcusdavanco
04/17/2023, 5:40 PMts
async function attachProjectFiles(project: ProjectFormValues, file: File) {
const attachments = await supabase.storage
.from("attachments")
.upload(`${project.name}/${file.name}`, file, {
cacheControl: "3600",
upsert: false,
});
return attachments;
}
In the attachProjectFiles, the response from the request that is sent to the storage is typed like this:
ts
{
data: {
path: string;
};
error: null;
} | {
data: null;
error: StorageError;
}
Considering that we have to use those types to destructure the error at least on the function that is passed to the onError property, what type should be used? I've considered creating an interface that corresponded to the type that mentioned above, but I didn't found the StorageError type exported from @supabase/supabase-js, any recommendations on what should be used? Here's the hook I have right now:
ts
export function useAttachProjectFiles(project: ProjectFormValues, file: File) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => attachProjectFiles(project, file),
onSuccess: async () => {
await queryClient.invalidateQueries(["attachments"]);
},
onError: ({ error }: { error: unknown } /* TODO: Replace with proper typing */) => {
console.error((error as Error)?.message);
},
});
}
Thanks in advanceYuu
04/17/2023, 5:53 PMhttps://cdn.discordapp.com/attachments/1097580601797783664/1097580601952968876/image.png▾
Rikka
04/17/2023, 6:15 PMhttps://cdn.discordapp.com/attachments/1097586093106397297/1097586093672636456/image.png▾
preef
04/17/2023, 6:25 PMsupabase db dump --db-url "$DB_URL_PROD" -f dumps/roles.sql --role-only &&\
supabase db dump --db-url "$DB_URL_PROD" -f dumps/schema.sql &&\
supabase db dump --db-url "$DB_URL_PROD" -f dumps/data.sql --data-only
The first two invocations of pg_dump
run fine, but the data-only
invocation fails with the following error:
pg_dump: error: query failed: ERROR: permission denied for sequence hooks_id_seq
pg_dump: detail: Query was: SELECT last_value, is_called FROM "supabase_functions"."hooks_id_seq"
Any ideas for fixing this?imagio
04/17/2023, 7:56 PMCREATE OR REPLACE FUNCTION public.update_fcm_key
(new_key TEXT) RETURNS bool
LANGUAGE plpgsql
SECURITY DEFINER AS
$$
.....
but when I call it from the supabase client I end up with No operator matches the given name and argument types. You might need to add explicit type casts.","message":"operator does not exist: text = uuid"
It seems that the Supabase client is detecting any string with dashes in it as a UUID and blindly casting it. Is this just a known bug? Is there a way to add an explicit cast from the supabase.rpc
client?Rosibert
04/17/2023, 8:02 PMjs
const { error } = await supabase.auth.signUp({
email,
password,
options: {
roles:['customer']
}
});
Is there an easy way to do so?Ammar Almuain
04/17/2023, 9:21 PMRyan [untitled]
04/17/2023, 9:44 PMUncaught (in promise) Error: tus: unexpected response while creating upload, originated from request (method: POST
when I attempt to post an upload to the endpoint outlined in https://supabase.com/blog/storage-v3-resumable-uploadsTiago
04/17/2023, 9:45 PMcustom claims
(https://github.com/supabase-community/supabase-custom-claims) and everything works fine on the dashboard, (1) I can get_claims
, (2) set_claims
. Not a problem doing that from the sql editor on supabase dashboard.
However, once I try to call a postgress function on the client side I always get error:`access denied`. Example of my function:
async function checkProfileClaims() {
try {
const updates = {
uid: userData.id,
// claim: "userrole",
// value: "Broker",
};
let { error, data } = await supabase?.rpc('get_claims', {...updates});
if (error) throw error;
console.log({ data, updates });
} catch (error) {
alert(JSON.stringify(error, null, 2));
console.log({ error, updates });
}
}
Thank you for the help.Rocket
04/17/2023, 10:28 PMxdcx18
04/17/2023, 10:42 PMhttps://cdn.discordapp.com/attachments/1097653307293581474/1097653307541049404/Screenshot_2023-04-17_at_5.37.29_PM.png▾
squallsama
04/17/2023, 10:43 PMsupabaseClient
.from('user_profiles')
.select<List<Map<String, dynamic>>>() .or("nick_name.contains.$searchPhrase,name.contains.$searchPhrase")
But got following exception:
PostgrestException(message: "failed to parse logic tree ((nick_name.contains.spar,name.contains.spar))" (line 1, column 23), code: PGRST100, details: unknown single value operator contains, hint: null)
Any suggestions about proper syntax or docs ? All examples related to or
uses eq
as filtersekansh005
04/17/2023, 11:00 PMDATABASE_URL="postgresql://postgres:my-secret-pwd@localhost:5432/postgres?connection_limit=40&pool_timeout=60"
but it is not connecting to supabase postgres and failing with `Error: P1001: Can't reach database server at `localhost`:`5432`
Please make sure your database server is running at `localhost`:`5432`.`
Can someone please help with this one?esparkman
04/17/2023, 11:02 PMProperty 'ok' does not exist on type PostgresSingleResponse
I'm at a loss as to how to get the Types pulled in for this.
I'm also not able to pull back data.mansedan
04/17/2023, 11:07 PMjs
const supabaseClient = createServerSupabaseClient({ req, res })
const { data: notifications, error } = await supabaseClient
.from('notifications')
.select('*')
.order('notification_date', { ascending: false })
// handful of lines between requests that shouldnt be relevant. and then:
const readNotifications = [...notifications].map(({ id }) => ({ id, read: 1 }));
const { data: readNotifications, error: readNotificationsError } = await supabaseClient.from('notifications').upsert([...readNotifications], { onConflict: 'id' })
https://cdn.discordapp.com/attachments/1097659723429462128/1097659723555283024/image.png▾
https://cdn.discordapp.com/attachments/1097659723429462128/1097659723823714344/image.png▾
adt2
04/17/2023, 11:14 PMjdgamble555
04/18/2023, 12:12 AMnpx supabase link --project-ref (my project id)
then
npx supabase db diff -f first_changes
and I got the response:
No changes found
However, there is definitely a table on supabase.com that doesn't exists on my local host (redirects table). Is the diff function buggy, or am I not using it correctly?
Jkekington
04/18/2023, 1:26 AMBEGIN
IF EXISTS(SELECT 1 FROM public.whitelist WHERE whitelist_string = NEW.email AND type = 'user') THEN
RETURN NEW;
END IF;
IF EXISTS(SELECT 1 FROM public.whitelist WHERE whitelist_string = SUBSTRING(NEW.email FROM '@(.*)') AND type = 'org') THEN
RETURN NEW;
END IF;
RETURN null;
END;
It never seems to correctly follow the logic and allow user creation. The logs are not very informative.
If I run the conditional queries (the ones inside the IF statements), they return the results as expected. Furthermore, I had cases where it hit the last case (RETURN null;) and still allowed for user creation.
I'm not sure what else I could try here. Would appreciate any pointers.kleveland
04/18/2023, 1:29 AMcache
function.PSully
04/18/2023, 2:02 AMINSERT
events, I am returned:
{
...
new: { column1: "value", column2: "value", column3: "value", ... },
old: {}
...
}
This lets me do something with the value that was inserted. However, when I get the response back from a DELETE
event, I'm returned:
{
...
new: {},
old: {
id: 999
}
...
}
Which means I can't really do anything with the value that was deleted. Sure, I could probably find ways around this, but I feel like I shouldn't have to, as it kinda feels like it defeats the purpose of this being RealtimeChannel.
Am I doing something wrong here? Am I misunderstanding how this should work?spy16
04/18/2023, 2:31 AMcveering
04/18/2023, 3:35 AMpermission denied for schema public
. I am using the Project URL for the supbaseURL and the anon/public key for the supabaseKey in the client constructor. There is currently no RLS. I have also restarted the database. I was previously using Prisma on this system if that matters. Thanks in advance for your suggestions.KurustyKrabs
04/18/2023, 5:16 AMhttps://cdn.discordapp.com/attachments/1097752513601622066/1097752513823903815/image.png▾
darick
04/18/2023, 5:47 AMaaale83
04/18/2023, 7:11 AM