Sacha
11/16/2022, 9:29 AMDennis
11/16/2022, 9:33 AMconst res = await supabase.auth.signInWithPassword({
email: 'test@email.com',
password: '12345678',
});
const { data, error } = await supabase
.from('test')
.select();
expect(data?.length).toBe(1);
Am i doing something wrong?Its-a-meMario
11/16/2022, 9:53 AMirreal
11/16/2022, 9:56 AMconst subscription = client
.from("agent_query")
.on("*", (payload) => {
console.log("got a payload", payload); //never triggers
}).subscribe();
console.log("initial state", subscription.state); //prints joining
subscription.onError(() => {
console.log("error!"); // never triggers
});
subscription.onClose(() => {
console.log("closed!"); //never triggers
});
subscription.onMessage(() => {
console.log("message!"); // never triggers
});
setInterval(() => {
console.log(subscription.state); // always prints "joined", so it succesfully joined but gets no messages
}, 2000);
I'm stumped, we made no changes whatsoever, in code or through the dashboard.
Any chance something is down on the supabase side?Kurdiez
11/16/2022, 10:39 AMsupabase.auth.admin.createUser
function to create a user and I am keep getting the 400 Bad Request
from the local API server. What's happening here? I can't find anything wrong.Evostance
11/16/2022, 11:29 AMsylar815
11/16/2022, 12:12 PMMoshe
11/16/2022, 12:38 PMismael1234
11/16/2022, 1:13 PMMaGnezij
11/16/2022, 3:26 PMMDobs
11/16/2022, 3:53 PMvar room = supabase
.channel(`public:room:id=eq.${id}`)
.on('postgres_changes', {
event: '*',
schema: 'public',
table: 'room',
filter: `id=eq.${id}`,
}, payload => {
console.log('Change received!', payload)
changeCallback(payload)
}).subscribe()
however if I immediately change a value on the DB sometimes I don't receive the change, if I delay the call by 200-500ms then I constantly get the callbacks from the changes.
But this is prone to race-conditions, is there a way to de-facto now that the site is listening to DB changes?mrmikardo
11/16/2022, 4:52 PMSmardrengr
11/16/2022, 5:00 PMselect * from profiles where name ilike in ('%jim%','%dave%', '%mary%');
Of course, this query doesn't work, but that's I'm trying to do with Supabase client. Any ideas?Cheqo
11/16/2022, 5:21 PMcould not find array type for data type text[]
here is my query:
const { data, error } = await supabase
.from('recipes')
.select('*')
.in('tags', ['Snack']);
Also, I converted my column from JSONB to Text[], does that make any difference?cdedreuille
11/16/2022, 6:22 PMsetProducts(data);
as the function doesn't return the new types. I'm a bit confused as to what could be the best way to set this up. Any idea where I'm doing something wrong?
const [products, setProducts] = useState<ProductsResponseSuccess[]>([]);
const supabaseClient = useSupabaseClient<Database>();
async function getProducts() {
return await supabaseClient.from("products").select("*, vendor(*)");
}
type Vendors = Database["public"]["Tables"]["vendors"]["Row"];
type ProductsResponse = Awaited<ReturnType<typeof getProducts>>;
type ProductsResponseSuccess = ProductsResponse["data"] & {
vendor: Vendors;
};
useEffect(() => {
async function loadData() {
const { data } = await getProducts();
if (data) setProducts(data);
}
loadData();
}, []);
Smardrengr
11/16/2022, 6:26 PMprofiles
table that references with RLS policies...
create table profiles (
id uuid primary key references auth.users on delete cascade,
name text,
email text,
avatar_url text,
constraint name_length check (char_length(name) >= 2)
);
alter table profiles enable row level security;
create policy "User profile can be read by everyone."
on profiles for select
using ( true );
create policy "Users can create their own profile."
on profiles for insert
with check ( auth.uid() = id );
create policy "Users can update own profile."
on profiles for update
using ( auth.uid() = id );
It appears to me that any user can, using the supabaseClient
fetch all user emails (in addition to name
and avatar_url
)? If my app has 10,000 users, that's kind of a problem, isn't it? That said, users of my app need to look up other users by email in order to add them as friends, so I sort of need a select RLS on email, I just don't want the client to be able to
const { data, error } = await supabaseClient.from('profiles).select();
Any thoughts on how to best approach this?Andrey Delov
11/16/2022, 6:53 PMsterbenc8
11/16/2022, 7:46 PMZaDeR47
11/16/2022, 7:56 PMAtrox
11/16/2022, 8:10 PMjs
CREATE OR REPLACE FUNCTION authorize(requested_permission app_permission, profile_id uuid, project_id uuid) RETURNS boolean AS $$
DECLARE
bind_permissions int;
BEGIN
SELECT count(*)
FROM public.role_permissions as p
INNER JOIN public.projects_users as pu on p.role = pu.role
WHERE p.permission = authorize.requested_permission
AND pu.profile_id = authorize.profile_id
AND pu.project_id = authorize.project_id
INTO bind_permissions;
RETURN bind_permissions > 0;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
In the roles_permissions
table I have added a single permission: project.view
for a role owner
.
In the projects_users
table I have a row with project_id
, profile_id
, and role
.
Calling the authorize
function manually works fine and returns true as I would expect. However, the RLS policy never passes. The projects
table has a SELECT policy defined as authorize('projects.view'::app_permission, uid(), id)
.
Does anyone have any idea what's going wrong here?Sacha
11/16/2022, 8:29 PMJH175
11/16/2022, 9:02 PMKlosiek
11/16/2022, 9:03 PMSmardrengr
11/16/2022, 9:33 PMselect * from profiles where id = '1234' and status in (true,null);
I tried
const { data: requests, error: rErr } = await supabaseClient
.from('friends')
.select(
'id, accepted, sender:user_id (id, name, bio, avatar_url), recipient:friend_id (id, name, bio, avatar_url)'
)
.match({ friend_id: session.user.id, accepted: null });
But I get the error
null {
code: '22P02',
details: null,
hint: null,
message: 'invalid input syntax for type boolean: "null"'
}
So is there some special where to specify a column is null/true/false within match()
? Can't find it in the docs...
¯\_(ツ)_/¯aaronksaunders
11/16/2022, 10:06 PMpg_dump \
-h db.thedatabase.supabase.co \
-U postgres --schema-only \
--clean --if-exists --schema=public \
> supabase_schema.sql
>
when I try to import into my new database, I am getting the error above
psql --dbname "$MAINDB" --single-transaction --variable ON_ERROR_STOP=1 --file supabase_schema.sql
on this statement in the SQL file
id uuid DEFAULT extensions.uuid_generate_v4() NOT NULL,
I have been googling around for the last few hours so any help will be appreciatedSmardrengr
11/17/2022, 5:22 AMprofiles
for a user?Exa
11/17/2022, 8:50 AMbrayden²
11/17/2022, 9:19 AMjsx
const addNewEmail = async (emailAddress: string) => {
if (!emailAddress || !emailAddress.includes("@")) return;
console.log(emailAddress);
// check to see if the email address is already in the database
const { data, error } = await supabase
.from("mailing_list")
.select("email_address")
.eq("email_address", emailAddress);
if (data === null || data.length === 0) {
console.log("email address is not in the database");
const { data, error } = await supabase
.from("mailing_list")
.insert({ email_address: emailAddress });
if (error) {
console.log(error);
}
return data;
}
return data;
};
Any ideas would be great 😄nuno.joao.andrade
11/17/2022, 11:13 AMtkrunning
11/17/2022, 11:17 AMid
column in the auth.users
table?
ALTER TABLE "auth"."users" ALTER COLUMN "id" SET DEFAULT 'uuid_generate_v7()';
Will it even work?