supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.

Home Page:https://supabase.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when deleting record by UUID: "invalid input syntax for type bigint"

ByScripts opened this issue · comments

Bug report

Describe the bug

I'm unable to delete a record by its UUID (v4) from the JS SDK.

I call the function as described here

await supabase.from("objectives").delete().eq("id", "7AD4D995-DBE8-4BB6-B40E-02459086A24D");

The URL generated is: https://<...>.supabase.co/rest/v1/objectives?id=eq.7AD4D995-DBE8-4BB6-B40E-02459086A24D

The error is: invalid input syntax for type bigint: "7AD4D995-DBE8-4BB6-B40E-02459086A24D"

I don't see what this has to do with a bigint, the field is defined as UUID 🤔

I also tried to change the id field type from uuid to text but I get the same error.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a table with the id column configured as UUID
  2. Add a row with a custom UUID (v4)
  3. Call supabase.from('your_table').delete().eq('id', 'your_v4_uuid')
  4. See error

Expected behavior

The item should be deleted without error.

Screenshots

Here is the configuration of the field.

Supabase Delete Error

System information

  • OS: macOS
  • Browser: Latest Edge
  • Version of supabase-js: 2.1.3
  • Version of Node.js: 16.17.0

As an additional information, update is working correctly:

await supabase.from("objectives").update({ name: "Edited" }).eq("id", "7AD4D995-DBE8-4BB6-B40E-02459086A24D");

The generated URL is exactly the same. The only difference is that it is called with PATCH method instead of DELETE

Interesting - does it work if you surround it with quotes? i.e. '"7AD4D995-DBE8-4BB6-B40E-02459086A24D"'

When adding quotes (single or double) they are part of the error: invalid input syntax for type bigint: "'7AD4D995-DBE8-4BB6-B40E-02459086A24D'"

As a workaround for now, I added a new auto incremented integer column (called it tmp_id)

Also, it's strange that the previous message mentioned "bigint" and since the creation of the new column the error mentions "integer". (my mystake, it still mention "bigint")

Just to check if the column is a uuid and not a bigint, can you try running this on the SQL editor?

select
  data_type
from
  information_schema.columns
where
  table_name = 'objectives'
  and column_name = 'id';

If it does return uuid I suggest you file a ticket on support - I couldn't reproduce the issue on my project.

It does return "uuid".

So i made somes tests:

  1. Create a new table "objective_new" with ID as UUID => ✅
  2. Duplicate "objectives" table + entries to "objectives_duplicate" => ✅ 🤔
  3. Rename "objectives" to "objectives_renamed" => ✅ 🤯
  4. Renamed "objective_duplicate" to "objectives" => 🚫
  5. Delete "objectives" then created a new "objectives" table => 🚫

Conclusion: The problem is not the table itself... it's the table name (at least on my project).

I'll file a ticket. Thank you for your time.

There's no assumption of bigint(or any type) on the postgREST/postgrest-js side.

Conclusion: The problem is not the table itself... it's the table name (at least on my project).

Seeing that those duplicated names look alike, it could be that you did select on an old table that had the id as bigint and did update on a new one.

Will close this for now but if you can provide a reproduction(with a sample CREATE TABLE..) we'll reopen.