I am using Supabase as my DB.
I have users table with id
field being populated with uuid_generate_v4().
I also have table bank_ao with foreign key bankId
pointed to users.id.
When I do following:
const uuid = req.params.id //this 100% works correctly and returns UUID every time!
await supabase
.from("bank_ao")
.select()
.eq("bankId", uuid);
I get this error
{"code":"22P02","details":null,"hint":null,"message":"invalid input syntax for type bigint: "914eda70-2ecf-49b0-9ea6-87640944ed16""}
I don’t have BIGINT field in my entire DB. I have checked 100x.
I also tried to add '
around my uuid
variable, but it still doesn’t work.
Any ideas?
Could this be some error specific to Supabase?
2
Answers
The problem was the following.
Before I used UUID as my id column value, it used to be BIGINT. When I changed it, it didn't change in cache, or some other type of memory. So, it threw an error.
I fixed it by re-creating entire database (I tried with table first, but it didn't work).
I have read online that if this is local version of Supabase you can just restart Postgres and it works fine (https://github.com/supabase/supabase/discussions/11891).
You need to cast the UUID into text to compare it there:
Assuming table format as:
Output:
Please note that for using BigInt in Javascript safely, then you can check it here (similar approach).