Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime does not work for tables with User-defined fields #211

Closed
kausko opened this issue Dec 23, 2021 · 2 comments
Closed

Realtime does not work for tables with User-defined fields #211

kausko opened this issue Dec 23, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@kausko
Copy link

kausko commented Dec 23, 2021

Bug report

Describe the bug

One of my tables in the supabase_realtime publication has a column of user-defined type/enum. I'm unable to subscribe to changes in this table, but other tables in the realtime publication are working. Removing this column fixes this issue.

To Reproduce

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

  1. Create an enum/user-defined type
DO $$ BEGIN
  CREATE TYPE "level" AS ENUM (
    'OWNER',
    'GUEST'
  );
EXCEPTION
  WHEN duplicate_object THEN null;
END $$;
  1. Create a table with a column of this type
CREATE TABLE IF NOT EXISTS "users" (
  id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  access "level" DEFAULT 'GUEST' NOT NULL,
);
  1. Add table to realtime publication
BEGIN; 
  DROP publication IF EXISTS supabase_realtime; 
  CREATE publication supabase_realtime;  
COMMIT;
ALTER publication supabase_realtime ADD TABLE users;
  1. Subscribe to table(s)
client
.from("*")
.on("*", console.log)
.subscribe()
  1. Wait for changes

Expected behavior

To receive payloads with updated data

System information

  • OS: Windows
  • Browser (if applies): Edge 96.0.1054.62 (Official build) (64-bit)
  • Version of supabase-js: ^1.28.5
  • Version of Node.js: 14.17.5

Additional context

Possibly related to #203 and #207?

@kausko kausko added the bug Something isn't working label Dec 23, 2021
@w3b6x9
Copy link
Member

w3b6x9 commented Dec 23, 2021

@kausko this is a known issue that we're currently dealing with. Realtime RLS, which is what all Supabase projects are currently using, rely on wal2json to function and we need to upgrade it v2.4. We'll be rolling out the upgrade to all Supabase projects in the next week or so.

We were going to deal with it using supabase/walrus#32 but then discovered that it's already been fixed upstream eulerto/wal2json#224.

In the meantime, you can define the type without quotation marks (i.e. "level" -> level) and it should work just fine.

If you're using a Supase project you can email support@supabase.io with your project ref and we can manually upgrade your db wal2json version to v2.4.

@kausko
Copy link
Author

kausko commented Dec 24, 2021

Thank you for getting back to me so quickly @w3b6x9!

Redefining the type without the quotation marks worked perfectly, so I'm closing this issue.

I really appreciate your offer for a manual upgrade, but I'll stick to your solution for now. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants