Search code examples
fluttersupabasesupabase-database

Supabase stream with filter does not work with delete operation


I have one stream listening changes from a table in supabase, insert and update operations works fine, when occurs one change the stream on flutter listen and re draw the widget but if I delete one row in the database or through the app the stream not listen.

This is the code of stream that listen on flutter.

    Stream<List<Map<String, dynamic>>> response = clientSupabase
    .from('PollSongs:id_pub=eq.$id')
    .stream(['id'])
    .order('likes', ascending: false)
    .execute();

I try without filter just using .from('PollSongs') and the same code and all operation works fine insert, update, and delete.

Stream<List<Map<String, dynamic>>> response = clientSupabase
.from('PollSongs')
.stream(['id'])
.order('likes', ascending: false)
.execute();

Solution

  • Apologies for not documenting this on the stream() section, but could you try running the following SQL and see if it fixes it?

    alter table "PollSongs" replica identity full;
    

    You can read more about this configuration here in the official docs. https://supabase.com/docs/reference/javascript/subscribe#listening-to-deletes