kevlust
02/22/2023, 7:30 PMgorbypark
02/22/2023, 7:34 PMmatch_document
and I have an edge function taking in the search query, converting it an emedding and (attempting) to find matches using match_document
. My issue is the edge function always just returns null
(but status 200) and in the PostGRES logs I can see "column reference "id" is ambiguous". I'm not quite sure where I'm going off the rails.
Heres my match documents rpc:
sql
create or replace function match_documents (
query_embedding vector(1536),
similarity_threshold float,
match_count int
)
returns table (
id bigint,
content text,
similarity float
)
language plpgsql
as $$
begin
return query
select
id,
content,
1 - (documents.embedding <=> query_embedding) as similarity
from documents
where 1 - (documents.embedding <=> query_embedding) > similarity_threshold
order by documents.embedding <=> query_embedding
limit match_count;
end;
$$;
brettshep
02/22/2023, 7:37 PMmagnusbee
02/22/2023, 7:45 PMid
(primary key) and created_at
are vulnerable to being changed by a user that has access to other data in that row?Pisti2010
02/22/2023, 8:57 PMmaglev
02/22/2023, 9:15 PMeho.ai-studio.23
02/22/2023, 10:15 PMjcurbelo
02/22/2023, 10:22 PMError: db error: FATAL: remaining connection slots are reserved for non-replication superuser connections
any ideas what could we doing wrong? i followed these steps:
https://docs.nestjs.com/recipes/prisma
and still get that error even when executing migrationsaunum
02/22/2023, 10:46 PMcaseycrogers
02/22/2023, 11:38 PMdart
Failed to delete user: update or delete on table "users" violates foreign key constraint "objects_owner_fkey" on table "objects"
I get that this means that this user has uploaded one or more files to storage, but I have no idea which one(s). Is there any easy way to query for this so I can find them and delete them?whiskeywizard
02/22/2023, 11:49 PMkonga
02/23/2023, 12:20 AMpasha_dee
02/23/2023, 12:31 AMDarkPhoenix
02/23/2023, 1:03 AMNyx
02/23/2023, 2:11 AMKellen Mace
02/23/2023, 3:23 AMpeople
, movies
and colors
. I also have a person_movies
table to keep track of a person's favorite movies, and a person_colors
table to keep track of their favorite colors.
Data Requirements
My web app forces users to enter at least one movie and one color as their favorites. It should be impossible for a user to exist on the site who does not have a favorite movie or color saved.
Scenario
A user with favorite movies "A" and "B" and favorite colors "green" and "blue" logs into my web app. They remove their previous favorites and set "C" and "D" as their new favorite movies, and "yellow" and "orange" as their new favorite colors, and hit the button to save the data. The movies and colors they entered don't exist in the movies
and colors
tables yet, so they need to be inserted.
To handle this, I use the supabase-js client. I fire off these requests:
1. Insert movies "C" and "D" into the movies
table
2. Insert colors "yellow" and "orange" into the colors
table
3. Remove the old usermovies relationships from the person_movies
table
4. Remove the old usercolors relationships from the person_colors
table
5. Save the new usermovies relationships to the person_movies
table
6. Save the new usercolors relationships to the person_colors
table
Performing these six operations works great for making the changes needed, and I can even run some of them in parallel so they don't take long.
Data Integrity Concern
What if the user's network connection drops out or their browser crashes between operations 4 & 5? That could result in data integrity issues, since my app would have performed the operations necessary for removing the old usermovies and usercolors relationships, but it never had a chance to add the new, required relationships. How should I address this problem?ChinKX
02/23/2023, 3:55 AMNJ™
02/23/2023, 6:07 AMRevaycolizer
02/23/2023, 7:25 AMconst getPic = async () => {
try {
const { data: projects, error } = await supabase.storage
.from("profiles")
.download ()
if (error) throw error;
src.value = URL.createObjectURL(data)
} catch (error) {
error.value = error.message;
setTimeout(() => {
error.value = false;
}, 5000);
}
};
But it's not workingkresimirgalic
02/23/2023, 8:05 AMawait supabaseAdmin.auth.admin.updateUserById(res.id, {
email_confirm: true,
email: res.email,
email_confirmed_at: new Date().toISOString(),
user_metadata: {
is_onboarded: true,
},
});
Also for debugging purposes i tried to create a basic email signup and try with that and google login and it worked. So, it obviously the problem somewhere in verifying the user email and confirmation in the setup profile where i am doing the code above.
Can anyone help?jinsley8
02/23/2023, 8:13 AMpg_cron
.
expiry column is a text string in UNIX format. I want to find the rows with expiry date before current date.
This query works:
SELECT to_timestamp('1677129809')::timestamp < now() AND order_status = 'Fillable' FROM orderbook_direct;
Now this is my function but when pg_cron tries to run it, it returns an error:
function pg_catalog.to_timestamp(text) does not exist.
Why is pg_cron
not able to run to_timestamp() ?
Or is there a better way to compared a unix time string with current date?
sql
CREATE OR REPLACE FUNCTION check_expiry_and_update_status_direct_listing()
RETURNS VOID
AS $$
DECLARE
row record;
BEGIN
FOR row IN SELECT * FROM orderbook_direct WHERE pg_catalog.to_timestamp(expiry)::timestamp < now() AND order_status = 'Fillable' LOOP
UPDATE orderbook_direct SET order_status = 'Expired', nonce = NULL, signature = NULL, order_valid = false WHERE id = row.id;
END LOOP;
END;
$$ LANGUAGE plpgsql;
This is my cron job:
sql
SELECT cron.schedule('cleanup-expired-direct','*/5 * * * * *', 'SELECT check_expiry_and_update_status_direct_listing()');
nicetomytyuk
02/23/2023, 8:33 AMsupabase link --project-ref <project-id>
I created a database migration with supabase db diff --use-migra create_database -f create_database
and then tried to push all the changes with supabase db push
but instead I get this error:
> Error: supabase_migrations.schema_migrations table conflicts with the contents of supabase\migrations.; Expected version 20230222145918 but found migration 20230223081033_create_database.sql at index 0.
> Try rerunning the command with --debug to troubleshoot the error.
While pushing the functions I had no problems.Dembe
02/23/2023, 8:49 AMmessage: duplicate key value violates unique constraint "guestbook_pkey"
`
what is the problem really? tried to check in supabase what it is, but can't figure it out.
js
const add = async () => {
const { error } = await supabase.from("guestbook").insert({
body: text,
id: data?.user?.id,
name: data?.user?.name,
});
if (error) {
console.log(error);
}
};
Amr
02/23/2023, 9:48 AMhooks.server.ts
which causes infinite redirect loop when the user is logged in!
js
export const handle = (async ({ event, resolve }) => {
const { session } = await getSupabase(event);
const isAdmin = ['DEV', 'MANAGER', 'ADMIN'].includes(session?.user.app_metadata.userrole);
if (event.url.pathname.startsWith('/admin') && !isAdmin) {
// Unauthorized user is trying to access admin dashboard, redirect to login page
throw redirect(307, '/account');
} else if (event.url.pathname.startsWith('/account') &&
isAdmin
) {
// Admin is already logged in, redirect to admin dashboard
throw redirect(307, '/admin');
}
return await resolve(event);
}) satisfies Handle;
This was working before but broke some time ago and I only noticed it yesterday.Vince
02/23/2023, 9:50 AMkresimirgalic
02/23/2023, 9:52 AMconst { data, error } = await supabase.auth.signInWithOtp({
phone,
options: {
shouldCreateUser: false,
},
});
code: 400
msg: "Signups not allowed for otp"
davidf
02/23/2023, 10:06 AMsupabase.from('posts').select('')
etc
I have quite an elaborate query that fetches the author information, comments etc for each posts and does some filtering so my select is quite long.
I'm struggling to get the nearby
working. I have added the geolocation extension and all my posts store their location. I now have the users location and need to get posts based on a distance.
I've written a function which already gets posts which gets posts within a specific view area, BUT where I'm struggling is how to combine that. I think from what I understand, I should be able to USE that function and then still use the SDK to do all my querying etc but I'm not quite sure how.
Anyone able to help me out?Hugos
02/23/2023, 10:11 AMDevThoughts
02/23/2023, 10:15 AMbyod
02/23/2023, 10:23 AM