[Broken] Custom primary keys (nanoids) breaks realtime listeners
Bug report
- [x] I confirm this is a bug with Supabase, not with my own application.
- [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
When using nanoids as a primary key on a real-time table—instead of the default uuidv4 values—it breaks all real-time functionality on that table in various ways (see below).
To Reproduce
- Add a script like this to migrations to generate nanoids as primary keys https://gist.github.com/iwasrobbed/a537ddb745d313904fa7188e4dd82a68
- Configure a real-time table to use those nanoids as primary keys (e.g.
id char(21) PRIMARY KEY DEFAULT generate_nano_id() NOT NULL) - Notice how the real-time listeners break (e.g. inserts no longer get called and for deletes it trims the
iddown to a single char versus showing the full 21 chars)
Expected behavior
Real-time should be agnostic to the type of primary key as long as it's a valid SQL primary key type
Screenshots
In the below delete callback, it trimmed the old id down to a single character (regardless of if it starts with a number or letter) when the original id was a 21 character nanoid
System information
- OS: macOS
- Browser (if applies): Arc
- Version of supabase-js: ^2.39.3
- Version of Node.js: v21.6.2
Additional context
Switching back to uuidv4 as primary keys immediately resolved the issue, but is not ideal for indexing.
I also have problem with NanoID. It only detects table changes if I DELETE, not INSERT or UPDATE. Have you find a solution for it? Thanks!