Issues with supabase inserts with drizzle
the transaction returns the team object with id from supabase db but when querying it to make sure it exists the team is not found. not sure whats going on exactly would love some clarification on is i'm just missing something
22 Replies
Do you see the team on Supabase dashboard?
it is not there but if i do spam this function it will work sometimes so it’s super weird
really weird yes. Maybe you can share the whole function?
Maybe turn on Drizzle logging to see what the sql output looks like.
this my logger queries
and this is the full function
I'm using sveltekit, and supabase
I don't see a transaction beginning or ending in your query there..
Does Supabase use Mysql? Does it support transactions? I don't see anything wrong with your function.
supabase uses postgres and i do believe they support transactions
this console log logs
showing the id was made from db but when checking that same id that was made
i get undefined
ah it seems like some prepared statements are failing
Not sure to be able to read that this evening but I'll take a look.
I use Supabase and transaction every day 😄
any help will be much appreciated sir i kinda narrowed it down to when i check supabase logs under postgres i get which im not sure why since im not doing any prepared statements
something trouble me with query logs
The only thing you is
Error Team not created
right?
Even if it fails at if (!test) throw error(500, 'Error Team not created');
, you see the team on db?the thing is i don’t see it in db like the above insert did nothing but has to be doing SOMETHING to be returning back data right? that if was there so i can at least figure out when it’s working or not
Surprising because if the transaction end, it should be committed on db
I would understand if it was throwing in the transaction but here it seems to not be the case
I’m not aware of such a bug. what driver are you using?
yes that’s what i’m not understanding i’m switching from the pooling url to the long standing one but since i’ll be using vercel for production i’m not sure that will work
on the supabase dashboard, you are sure that you don’t have any set filter (it happened to me ... four hours lol)
Is it an open-source project?
I will try to reverse-engineer your tables and tell you if it works for me
potential issue: do you have your pgbouncer settings in supabase set to statement level pooling
it's an option you can select and if you do transactions no longer work as expected
Where do you find this?
I only have transaction or session
If it matters, I use postgres-js as driver
oh, maybe they removed it. They used to allow you to turn statement level pooling on which would break all transaction support
My production db is in transaction mode. Seems to be the default now.
it is not open source but i can invite you since its only i working on it, and yeah mine is transaction too no filters on that i know of
Don't worry. Maybe you can share you schema?
Or else I will typing it lol
can be in private if you want 😉
For people following this thread, pooler on port 6543 is really unstable on high rate.
Direct connection on 5432 works fine.
If you encounter the same issue on Supabase serverless env, try to ask Supabase for Supavisor
https://supabase.com/docs/guides/database/connecting-to-postgres#supavisor
Connecting to your database | Supabase Docs
Explore the options for connecting to your Postgres database.