adeola13
02/20/2023, 11:37 AMAless.c06
02/20/2023, 12:19 PMsql
create or replace function public.join_lobby_by_id(username_input text, pfp_input text, tag_input text, lobby_id int)
returns int as $$
declare
player_id int;
players_number int;
players_lobby int[];
begin
players_lobby := ARRAY[1,2,3,4];
players_number = size from lobbies where id = lobby_id;
player_id := (floor(random() * 9) + 1) * pow(10, 3);
player_id := player_id + (floor(random() * 9) + 1) * pow(10, 2);
player_id := player_id + (floor(random() * 9) + 1) * pow(10, 1);
player_id := player_id + (floor(random() * 9) + 1) * pow(10, 0);
if username_input LIKE '%>%' or username_input LIKE '%<%' or length(username_input) > 15 or length(username_input) < 3 then
return -1;
end if;
insert into players(id, username, pfp, tag)
values(player_id, username_input, pfp_input, tag_input);
SELECT players INTO players_lobby
FROM lobbies
WHERE id = lobby_id;
update lobbies
set players = array_append(players_lobby, player_id)
where id = lobby_id;
return player_id;
end
$$ language plpgsql
security definer set search_path = public;
Error:
"\"[\" must introduce explicitly-specified array dimensions."
"malformed array literal: \"[]\""
I'm trying to add a "player id" to another array that I want to take from the databaseNemesis
02/20/2023, 12:46 PMKatoka
02/20/2023, 2:10 PMKatoka
02/20/2023, 2:21 PMJubilantJam
02/20/2023, 2:32 PMdocker/volumes/db/init/data.sql
Do I need to use those files somehow?JubilantJam
02/20/2023, 2:39 PMmaxim
02/20/2023, 3:44 PMlake_mattiato
02/20/2023, 3:47 PMpython
import smtplib
from napkin import response, request
recipient = request.body['recipient']
referrer_name = request.body['referrer_name']
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('test.info@gmail.com', 'XXXXX')
# Set the sender and recipient
sender = 'example.sender.info@gmail.com'
# Set the subject and body of the email
subject = 'Referral Closed'
body = f"""
Dear {referrer_name},
This is an example mail
"""""
# Construct the email
email = f'Subject: {subject}\n\n{body}'
# Send the email
server.sendmail(sender, recipient, email)
# Disconnect from the server
server.quit()
response.status_code = 200
response.body = "OK"
Can i use the this email to send emails from supabase?Tadasajon
02/20/2023, 4:50 PMJack Bridger
02/20/2023, 5:15 PMCREATE TABLE apps (
id UUID PRIMARY KEY default uuid_generate_v4() unique,
name VARCHAR(255) NOT NULL
);
CREATE TABLE users (
id UUID not null,
app_id UUID REFERENCES apps(id) on delete cascade not null,
display_name VARCHAR(255),
PRIMARY KEY (id, app_id)
);
But the error I get back in the Supabase editor is
Failed to run sql query: there is no unique constraint matching given keys for referenced table "users"
Any tips or help is appreciated!jopfre
02/20/2023, 5:27 PMexport const getServerSideProps = async (ctx) => {
const supabase = createServerSupabaseClient(ctx);
const { report, client } = ctx.query;
let { data, error } = await supabase
.from(`reports`)
.select('status, years_covered, year_end, progress, dates')
.single()
.eq('id', report);
if (error) console.error(error);
return { props: { report, client, data } };
};
I have both Supabase and Vercel region set in eu-west-2.
I have no issue with CSR and have in fact moved a lot of my SSR code to the client to avoid this timeout but I feel like something is wrong. Surely I should be able to query one row from one table before Vercel timesout?
Not saying this is a supabase issue but just wondering if anyone else has experienced it with Vercel/AWS?
I am on vercel free tier and the issue did seem better when I was doing the pro trial. I will upgrade to pro but I feel like free tier should be able to handle this request?
Thanks for your time 🙂
Github Discussion for search engines: https://github.com/supabase/supabase/discussions/12559solibe1
02/20/2023, 6:27 PMSELECT array_append(ARRAY['apple', 'banana', 'cherry'], ARRAY['date', 'elderberry']);
i get this error Failed to run sql query: function array_append(text[], text[]) does not exist
hortinstein
02/20/2023, 7:19 PMHolliday
02/20/2023, 8:43 PMThe database server at XXXXXX:5432 was reached but timed out.
Please make sure your database server is running at XXXXXX:5432
Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See https://pris.ly/d/migrate-advisory-locking for details.
I'm running Prisma 4.8. I'm also deploying it from my local machine, not in a CI environment. (WSL2)
I also recently upgraded my supabase postgres instance, so I'm wondering if that could have affected anything.Revaycolizer
02/20/2023, 9:01 PM<q-file
type="file"
style="padding: 8px; margin: 12px"
label="Project picture"
rounded
outlined
counter
max-files="1"
clearable
use-chips
max-file-size="3072000"
v-model="file"
accept=".png,.jpg,.gif,.avif,image/*"
><template v-slot:prepend><q-icon name="attach_file" /></template
></q-file>
const savePic = async () => {
try {
const { error } = await supabase.storage.from("profiles").upload(file, {
cacheControl: "3600",
upsert: false,
});
if (error) throw error;
statusMsg.value = "Successfully added";
file.value = null;
} catch (error) {
error.value = "Error: ${error.message}";
setTimeout(() => {
error.value = false;
}, 5000);
}
};
Dxlan
02/20/2023, 9:24 PMuseSession
hook provided by supabase/auth-helpers-react
to pass in to a Profile
component as a prop. This is the component where I am using a useEffect
hook that has an asynchronous callback getProfile()
where I filter through a table in my db and check if a rows id is equal to the id of the current user by using .eq('id', user.id)
. This is the line that seems to be causing the error TypeError: Cannot read properties of null (reading 'id')
. The sessioncontext is wrapped around <Component {...pageProps} />
in app.js
so user.id should be available everywhere right? Or would this only be possible if I was conditionally rendering the entire component in index.js
like in the tutorial? I haven't been able to find any docs on the auth-helpers. Can any one help?jar
02/20/2023, 10:22 PMkevlust
02/20/2023, 10:22 PMONA
02/20/2023, 11:14 PMjs
import { makeRedirectUri, startAsync } from "expo-auth-session";
import { supabase, supabaseUrl } from "../supabase";
export const signInWithFacebook = async () => {
const redirectUrl = makeRedirectUri({
path: "/auth/callback",
});
const authResponse = await startAsync({
authUrl: `${supabaseUrl}/auth/v1/authorize?provider=facebook&redirect_to=${redirectUrl}`,
returnUrl: redirectUrl,
});
if (authResponse.type === "success") {
supabase.auth.setSession({
access_token: authResponse.params.access_token,
refresh_token: authResponse.params.refresh_token,
});
}
};
(Taken from https://dev.to/fedorish/google-sign-in-using-supabase-and-react-native-expo-14jf)
I am in search for a more native way to achieve this. Any experiences or knowledge?jj_sessa
02/21/2023, 12:00 AMrichardkyk
02/21/2023, 1:30 AMreadiness_items
which are linked to readiness_tables
and I have a realtime subscription to each of the respective tables.
There can be multiple "ReadinessTable" each with multiple "ReadinessItem". Whenever I add an item to an individual table, I get multiple messages back from the websocket.
One message for each "ReadinessTable".
Is this how it is supposed to work or have I missed something?
In the following payload, you can see the readinessTableId
is different than the one used in the topic.
javascript
{
"event": "postgres_changes",
"payload": {
"data": {
"columns": [...],
"commit_timestamp": "2023-02-21T01:13:13Z",
"errors": null,
"record": {
"completeDate": null,
"createdAt": "2023-02-21T01:13:13.718137+00:00",
"description": "Description of item",
"id": "sj7hPjrvEarSVrM1kQpeC9",
"meta": {},
"readinessTableId": "9PVjE7ZjdVJFq5vk5X8YW1",
"releaseId": "j7ZskHh1ieD4BDPT8onfTx",
"status": "Not yet started",
"teamId": "7HyBvzaHiAFZy5vLE7AuEe",
"updatedAt": "2023-02-21T01:13:13.718137+00:00"
},
"schema": "public",
"table": "readiness_items",
"type": "INSERT"
},
"ids": [
21927122
]
},
"ref": null,
"topic": "realtime:readiness_items:readinessTableId=eq.inYnUf4R66mnqK22T6JjSz"
}
LukeHos
02/21/2023, 2:30 AM🎃🕸Jack-O-Lantern🕸🎃
02/21/2023, 3:03 AMpakkerr
02/21/2023, 3:28 AMrlee128
02/21/2023, 5:02 AMPragy
02/21/2023, 5:20 AMusers
, and have granted permissions
sql
create schema if not exists users;
-- not sure which permissions are really needed
-- since I'm still getting permission denied
grant all on schema users to authenticated;
grant all on schema users to authenticator;
grant all privileges on schema users to authenticated;
grant all privileges on schema users to authenticator;
Inside the users
schema, I've a table called config
, with a security policy
sql
create table if not exists users.config
(
id uuid primary key references auth.users,
config jsonb not null default '{}'::jsonb
);
alter table users.config enable row level security;
create policy "Users can CRUD own config" on users.config
for all
using (id = auth.uid())
with check (id = auth.uid());
Finally, I've a view with security_invoker=on
in the public
schema that exposes this table
sql
create or replace view public.user_config with (security_invoker=on) as
select *
from users.config;
Have also configured Extra search path
in API settings of supabase to public, extensions, common, users, wikis, minds
When querying via an authenticated user, I'm getting the following error on the frontend
js
{
code: '42501',
details: null,
hint: null,
message: 'permission denied for table config'
}
Postgres logs have the following
(in first comment because the post was getting too long)
Please help 😅
Thanks!bilals
02/21/2023, 8:38 AMHypersigils
02/21/2023, 9:13 AMfast
02/21/2023, 10:13 AM{
"message": "No API key found in request",
"hint": "No `apikey` request header or url param was found."
}
My configuration seems to be alright so I don't really know why such behaviour appears.