morgan
02/24/2023, 3:03 AMwc_store_id
row.
So the table could have the same email a few times in relation to different wc_store_id
, but never for the same one.
Error when there's already a record:
js
{
"code": "23505",
"details": "Key (email, wc_store_id)=(hidden@gmail.com, 37d2310e-f789-4ae0-a314-b379aeea0851) already exists.",
"hint": null,
"message": "duplicate key value violates unique constraint \"unique_email_wc_store_id_for_wc_customers\""
}
Upsert:
js
const { error: errorUpsertingGuests } = await supabaseAdmin
.from("wc_customers")
.upsert(foundGuestCustomers, {
onConflict: "email,wc_store_id",
ignoreDuplicates: true, // This is not working with my setup. Maybe because the record matches the first contraint?
});
SQL Constraints:
sql
ALTER TABLE wc_customers
ADD CONSTRAINT unique_internal_id_wc_store_id_for_wc_customers UNIQUE (internal_id,wc_store_id);
ALTER TABLE wc_customers
ADD CONSTRAINT unique_email_wc_store_id_for_wc_customers UNIQUE (email,wc_store_id);
Any help is appreciated 🙏ostoto
02/24/2023, 3:08 AMdeclanmiddleton
02/24/2023, 3:32 AMjs
import { useSession } from "@supabase/auth-helpers-react";
import { supabase } from "../lib/supabase";
import { useEffect, useState } from "react";
import Navbar from "@/Navbar/Navbar";
import Footer from "@/Footer/Footer";
import Auth from "@/Auth/Auth";
const Layout = ({ children }) => {
const session = useSession();
return (
<>
{!session ? (
<>
<Auth />
</>
) : (
<>
<Navbar />
<main>
<section>{children}</section>
</main>
<Footer />
</>
)}
</>
);
};
export default Layout;
akshatgggggg
02/24/2023, 3:39 AMlecookie
02/24/2023, 4:17 AMaar2dee2
02/24/2023, 5:05 AM500
error when trying to view tables. There's a permission denied for schema supabase_functions
error in my Postgres logs. This is a recent bug, I could view the tables till a couple days ago.RB_Gaura
02/24/2023, 5:51 AMw3center
02/24/2023, 7:44 AMpostgresql
declare
orgId uuid := uuid_generate_v4();
begin
insert into public.org(id,name) values (orgId,'Personal');
insert into public.profile(orgId,userId,email) values (orgId,new.id,new.email);
return new;
end;
Unfortunately, the function returns an error:
function uuid_generate_v4() does not exist
Which is strange because the extension is enabled and generates uuid correctly elsewhere. It looks like it doesn't work only in the triggered function. I also tried using public.uuid_generate_v4()
but also without success.
Any hints?NJ™
02/24/2023, 7:48 AMJ_B
02/24/2023, 7:52 AMconst extent = "ST_BUFFER(ST_POINT(11.5339694, 48.2147208)::geography, 250)::geometry";
supabase.from("table").select().filter("location", "st_within", extent);
But it gave me an error:
Failed to parse [(\"location\",\"st_within().ST_BUFFER(ST_POINT(11.53397, 48.214712)::geography, 250)::geometry\")]
This generated query looks obviously wrong. I would expect to get the following query:
st_within(location, ST_BUFFER(ST_POINT(11.53397, 48.214712)::geography, 250)::geometry)
erik-beus
02/24/2023, 7:52 AMpg_net
extension, but want to update it to the latest version (0.7.1
). Currently, we're on version 0.2
on our cloud hosted postgres.
If I run:
SELECT * FROM pg_available_extension_versions where name='pg_net';
it seems that there are no other versions available than 0.2
If I start a new project in supabase, the postgres db is using version 0.7.1
of pg_net
.
How do we update this and other extensions?
Thank you 🙂jfbn
02/24/2023, 8:38 AMsignOut
function available on the supabase clients auth module.
The user is signed out, the session is terminated, but the onAuthStateChanged
listener from my layout is not firing.
Notice that it does fire correclty when signing in.Kcrik
02/24/2023, 9:16 AMMAXOUXAX
02/24/2023, 10:34 AMConnorSmiley
02/24/2023, 10:35 AMalter user postgres with superuser
but I am not a SU. I deleted by DB and restarted and cannot run the command inside the SQL editor on supabase. How can I become a superuser when creating a new DB? ThanksMaxoouuu
02/24/2023, 11:48 AMhttps://ydipallaaniajlzvcdqu.supabase.co/auth/v1/verify?token=547004c8a6763e54d8593f0700eb34e71caf2b7a951ec67140eac553&type=magiclink&redirect_to=http://localhost:3000/
js
const handleLogin = async (event) => {
try {
loading.value = true;
const { data: response, error } = await supabase.auth.signInWithOtp(
{
email: email.value,
},
{ redirectTo: "http://localhost:3000/test-connexion" }
);
if (error) throw error;
alert("Check your email for the login link!");
} catch (error) {
alert(error.error_description || error.message);
} finally {
loading.value = false;
}
};
Grimmjoww231
02/24/2023, 12:55 PMbenjaminpreiss
02/24/2023, 12:55 PMsql
auth.is_matched(auth.user_id(), user_id) = true
and the function auth.is_matched:
sql
create or replace function auth.is_matched(requesting_user text, requested_user text) returns boolean as $$
declare
is_matched boolean;
begin
raise log 'Value: %', $1;
raise log 'Value: %', $2;
is_matched := false;
if exists (
select o.user_id from match_offers o
inner join matches m on o.id = m.offer
inner join match_requests r on r.id = m.request
where o.user_id = $1 and r.user_id = $2 or o.user_id = $2 and r.user_id = $1
) then
is_matched := true;
end if;
return is_matched;
end;
$$ language plpgsql stable;
The problem is that the select policy seems to block all access. Any ideas what I am doing wrong?Alexander Kremenets
02/24/2023, 1:30 PMenyo
02/24/2023, 2:13 PMorganisations.default_team_id -> teams.id
teams.organisation_id -> organistion.id
I want to insert a default team every time an organisation is created, and because I know that this happens, I want default_team_id
to be not null
.
I tried creating a trigger like this:
sql
create
or replace function public.create_default_team_on_org_insert () returns trigger language 'plpgsql' volatile security definer cost 10000 as $body$
declare
new_team_id bigint;
begin
insert into teams (organisation_id, name, is_default) values (new.id, 'All', true) returning id into new_team_id;
new.default_team_id = new_team_id;
return new;
end;
$body$;
create trigger create_default_team_on_org_insert
before insert on organisations for each row
execute procedure create_default_team_on_org_insert ();
But this fails, because the organisation doesn't exist when I try to insert the team.
If I change the trigger to after
, then it fails because default_team_id
cannot be null.
Any tips?slavendjervida
02/24/2023, 3:06 PMstillmotion
02/24/2023, 3:22 PMkaaloo
02/24/2023, 4:23 PMHamburger
02/24/2023, 4:25 PMmaxbaluev
02/24/2023, 4:27 PMlecookie
02/24/2023, 4:45 PMsupabase.auth.getSession()
there is not access_token provided.
Here is my code js
import { createClient } from "@supabase/supabase-js";
import { Auth, ThemeSupa } from "@supabase/auth-ui-react";
import { useNavigate } from "react-router-dom";
import React, { useEffect, useState } from "react";
const supabase = createClient(
"https://yzrejpciblqqfsybjqye.supabase.co",
"secret"
);
function Success() {
const [user, setUser] = useState({});
const navigate = useNavigate();
useEffect(() => {
async function getUserData() {
await supabase.auth.getUser().then((value) => {
//value.data.user
if (value.data?.user) {
console.log(value.data.user);
setUser(value.data.user);
}
});
}
getUserData();
}, []);
async function getData() {
const { data, error } = await supabase.auth.getSession();
console.log(data);
}
async function signOutUser() {
const { error } = await supabase.auth.signOut();
navigate("/");
}
return (
<div className="App">
<header className="App-header">
{Object.keys(user).length !== 0 ? (
<>
<h1>Success</h1>
<button onClick={() => signOutUser()}>SignOut</button>
</>
) : (
<>
<h1>Your are not logged in</h1>
<button onClick={() => navigate("/")}>Go Back</button>
</>
)}
</header>
</div>
);
}
export default Success;
DevGuy
02/24/2023, 5:12 PMexport type Json =
| string
| number
| boolean
| null
| { [key: string]: Json }
| Json[];
I currently use this in my types with Supabase now but was wondering if anyone knows a good workflow to assign specfic typescript types to these json columns. Thanks!techleed
02/24/2023, 5:20 PMdota | DELETE {
dota | schema: 'public',
dota | table: 'steam_accounts',
dota | commit_timestamp: '2023-02-24T17:19:04Z',
dota | eventType: 'DELETE',
dota | new: {},
dota | old: { id: 'cleisrp4b0000cwt2tb96nmrb' },
dota | errors: null
dota | }
ime xpecting old to contain the entire row, not just id. how do i change this? my replication is already set to full
for this tablemct.dev
02/24/2023, 5:38 PMICAZ117
02/24/2023, 6:35 PMRelative import path "@supabase/supabase-js" not prefixed with / or ./ or ../ and not in import map from "file:///
My code is as follows:
js
import { createClient } from "@supabase/supabase-js";
I've also tried adding a deno.json file and changing the code to this:
js
import { createClient } from "supabase";
The deno.json file in the root directory of my Vue project (which contains the Supabase project). The contents of the deno.json file are as follows:
json
{
"imports": {
"std/": "https://deno.land/std@0.168.0/",
"stripe": "https://esm.sh/stripe@11.9.1",
"supabase": "npm:supabase/supabase-js"
}
}
I have attached a screenshot of the file structure of my project. Please advise on how to proceed. Thank you!