bry
02/13/2023, 7:43 PMGRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO postgres;
. I go to add a row to a table, same error. I then try GRANT supabase_admin TO postgres;
, but I can't do that either.
I am bashing my head into my keyboard since this problem is so simple yet am finding nothing online about it that works. Any help appreciatedali
02/13/2023, 7:53 PMHugos
02/13/2023, 8:00 PMICAZ117
02/13/2023, 8:05 PMnimo
02/13/2023, 8:07 PMerror - Error: {"code":"23505","details":null,"hint":null,"message":"duplicate key value violates unique constraint \"transcript_pkey\""}
Hey all -- getting the above error when I run an insert as follows:
const { data, error } = await supabase
.from('transcript')
.insert({ transcript: transcript.trim(), project_id })
.select('*')
.single();
I'm not sure what's going on, as the transcript ID is a sequential number (should be auto-computed right?). Below are the SQL queries used to create the table.
CREATE TABLE "public"."transcript" (
"id" bigint NOT NULL,
"created_at" timestamp with time zone DEFAULT "now"(),
"transcript" "text",
"project_id" "uuid",
"cleaning_status" "public"."transcript_cleaning_status" DEFAULT 'started'::"public"."transcript_cleaning_status"
);
ALTER TABLE "public"."transcript" OWNER TO "postgres";
--
-- Name: transcript_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE "public"."transcript" ALTER COLUMN "id" ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "public"."transcript_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
elliott
02/13/2023, 9:34 PMVuFFeR
02/13/2023, 11:03 PMawait supabase.auth.updateUser({
password: password.getValue(),
data: {
avatar_url: avatar.src,
}
}):
is called.
Here the trigger is:
begin
update public.members set avatar_url = NEW.raw_user_meta_data->>'avatar_url'
where m.id = NEW.id;
end
Is it a syntax error?cdbattags
02/13/2023, 11:25 PMDanMossa
02/14/2023, 12:35 AMEmmett
02/14/2023, 12:41 AMrajamaka
02/14/2023, 1:00 AMcls.table.select("data").eq("data->>email", "foobsar.com").execute().data
Returns successfully:
[{'data': {'email': 'foobsar.com', 'skills': ['Java', 'Python', 'JavaScriptd'], 'address': {'city': 'San Francisco', 'state': 'CA', 'street': '1 Main St', 'zip_code': '94102'}, 'hire_date': '2022-01-01', 'is_active': True, 'last_name': 'Doe', 'department': 'IT', 'first_name': 'John', 'employee_id': 999}}, {'data': {'email': 'foobsar.com', 'skills': ['Java', 'Python', 'JavaScript', 13], 'address': {'city': 'San Francisco', 'state': 'CA', 'street': '1 Main St', 'zip_code': '94102'}, 'hire_date': '2022-01-01', 'is_active': True, 'last_name': 'Doe', 'department': 'IT', 'first_name': 'John', 'employee_id': '12345'}}]
However following up with a query to check a bool value
cls.table.select("data").eq("data->>is_active", True).execute().data
Having the same issue with weird behaviour for gte / lte queries.. 😦lost12487
02/14/2023, 1:19 AMgetSupabase
is returning null
for the session.
Sign in action:
typescript
export const actions: Actions = {
signIn: async (event) => {
const { supabaseClient: sb } = await getSupabase(event);
const provider = event.url.searchParams.get('provider') as Provider | undefined;
if (!provider) {
return fail(400, { message: 'Missing provider' });
}
const { data, error: err } = await sb.auth.signInWithOAuth({
provider,
options: { redirectTo: 'http://localhost:5173/app' } // temporary - for debugging
});
if (err) {
return fail(500, { messaage: 'Failed to sign in with provider. Please try again later.' });
}
throw redirect(302, data.url);
}
};
Server load of the page I'm attempting to redirect to after sign in:
typescript
export const load: PageServerLoad = async (event) => {
const { session } = await getSupabase(event);
if (!session) {
throw redirect(302, '/sign-in?unauthorized=true'); // This is always hit
}
return {};
};
I feel like there's got to be some small thing I'm misusing here. Apologies if this is something I'm doing incorrectly.DYELbrah
02/14/2023, 3:00 AMconst channel = supabase
.channel("table-db-changes")
.on(
"postgres_changes",
{
event: "*",
schema: "public",
table: "customer",
},
(payload) => {
console.log("payload", payload);
void queryClient.invalidateQueries(["customerTableData"]);
}
)
.subscribe();
Is there a way I can avoid having to use React Query and simply get the results back directly from Supabase for a query. In V1 docs I saw you could write a query and subscribe to it. I believe that's no longer the case in V2.
Thanks!elliott
02/14/2023, 5:45 AMPoypoypoy
02/14/2023, 7:21 AMChrisCoCreated
02/14/2023, 7:28 AMreq
as far as I can see.
Here's the code
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
console.log("Hello from Functions!")
serve(async (req) => {
// const { streamData } = await req.json()
console.log(req);
return new Response(
JSON.stringify("thanks for testing"),
{ headers: { "Content-Type": "application/json" } },
)
})
Here's the log from the postman request.
Log ID
0157d979-d9e1-4cb2-9089-c704e9af4e32
Log Timestamp (UTC)
2023-02-14T07:11:27.875Z
Log Event Message
Request {
bodyUsed: false,
headers: Headers {
accept: "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "*",
"cdn-loop": "deno;s=deno;d=0xgb8wqb38d0",
"content-type": "application/json",
host: "subhosting-v1.deno-aws.net",
"postman-token": "f0a82679-e7c0-41a6-a3c5-00e2a1036093",
"user-agent": "PostmanRuntime/7.31.0",
"x-forwarded-for": "95.97.53.229"
},
method: "POST",
redirect: "follow",
url: "https://subhosting-v1.deno-aws.net/hello"
}
Log Metadata
[
{
"boot_time": null,
"deployment_id": "tzkolxmyzqprcmyinkum_2f768470-9986-4ddb-a463-12d6e17afb6c_8",
"event_type": "log",
"execution_id": "eaab427e-a25e-4789-b5ab-01709f5e66a8",
"function_id": "2f768470-9986-4ddb-a463-12d6e17afb6c",
"level": "info",
"project_ref": "tzkolxmyzqprcmyinkum",
"region": "aws-eu-central-1",
"timestamp": "2023-02-14T07:11:27.685824837+00:00",
"version": "8"
}
]
Screen shot Postman attached.
What might I be doing wrong? Any guidance for a noob appreciated. thanks!JacobCoRo
02/14/2023, 7:47 AMauth.signOut()
and redirecting back to the login page, by the time the user gets to the login page, the cookie has already been rewritten into the browser and our login page directs them right back into the logged-in protected pages.eloahsam
02/14/2023, 7:59 AMbkyerv
02/14/2023, 9:09 AM(await supabase.auth.signUp(
email: 'example@email.com',
password: 'example-password',
);
I don't get a confirmation message to the email used to sign up and I don't see any user in the profile db (unlike when I use magic link where I see users using their emails). Are we supposed to implement ourselves all the logic related to sending out a confirmation message to the email address provided during sign up and keeping record of users who confirmed their email?Rain2o
02/14/2023, 10:53 AMpermission denied for view
. As far as I can tell I can't set RLS or any other security permissions on a view. I used the same saved script to recreate it, only adding a new column. I've also tried removing the new column to create the view back to how it was before, but still receiving this error.
It's in the public
schema. Running a select * query from the query editor in Supabase UI works without issue. And the API calls from my app are working fine for everything else, and were working on this view before I dropped/created it again..
Here's a snippet from the Supabase logs
"query": "WITH pgrst_source AS ( SELECT \"public\".\"all_posts\".* FROM \"public\".\"all_posts\" WHERE \"public\".\"all_posts\".\"user_id\" = $1 ORDER BY \"public\".\"all_posts\".\"updated_at\" DESC NULLS LAST LIMIT $2 OFFSET $3 ) SELECT null::bigint AS total_result_set, pg_catalog.count(_postgrest_t) AS page_total, coalesce(json_agg(_postgrest_t), '[]')::character varying AS body, nullif(current_setting('response.headers', true), '') AS response_headers, nullif(current_setting('response.status', true), '') AS response_status FROM ( SELECT * FROM pgrst_source ) _postgrest_t",
cohlar
02/14/2023, 2:46 PMA-PRYME
02/14/2023, 2:56 PMPost
, Comment
and User
. A post has a list of comments, and each comment belongs to a single user. How might I get a list of comments with their associated users as a stream? I'm looking to build a reactive comment section where each comment is displayed together with the name and avatar of the user who wrote it. If a new comment is added
, liked
or removed
, the comment section should react accordingly.
This means I need to join my comment table with my user table and get the data as a stream, something that's currently not possible. But is there any chance at all that this feature will be supported in the near future?Smiley
02/14/2023, 3:16 PMBabou 🧙
02/14/2023, 3:38 PMjoshuabaker
02/14/2023, 4:33 PMconst { data: projects } = await supabaseAdmin
.from("projects")
.select("*, project_users(*)")
.eq("project_users.user_id", user.id);
User ID: bb872bc9-90f1-40a7-af0c-bed5b5662e6f
Result: [
{
"id": 1,
"created_at": "2023-02-07T18:19:54+00:00",
"updated_at": "2023-02-07T18:19:54+00:00",
"title": "Test Search 0001",
"project_users": [
{
"id": 1,
"created_at": "2023-02-08T12:00:41.024374+00:00",
"project_id": 1,
"user_id": "bb872bc9-90f1-40a7-af0c-bed5b5662e6f"
}
]
},
{
"id": 2,
"created_at": "2023-02-07T18:25:48.607192+00:00",
"updated_at": "2023-02-07T18:25:48.607192+00:00",
"title": "Test Search 0002",
"project_users": []
},
{
"id": 3,
"created_at": "2023-02-07T18:27:40.645989+00:00",
"updated_at": "2023-02-07T18:27:40.645989+00:00",
"title": "Test Search 0003",
"project_users": []
}
]
This case is almost exactly like the one in the docs (https://supabase.com/docs/reference/javascript/select).
What’s happening here?Ruzelmania
02/14/2023, 4:40 PMHugos
02/14/2023, 4:47 PMjs
const {data, error} = await serviceRoleSupabaseClient
.from('games')
.insert([
{
player_id_white: playerWhite.id,
player_id_black: playerBlack.id,
pgn: chess.toString("pgn")
}
]);
if (error) {
return new Response(JSON.stringify({ error: error.message }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 400,
});
}
return new Response(JSON.stringify({ message: 'Successfully created game', game: data }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200,
});
Atrox
02/14/2023, 6:02 PMsosapps
02/14/2023, 6:02 PM