I'm having problems with the database and flutter....
# help
k
I'm having problems with the database and flutter. Whenever I delete or add an entry, I don't get new data. I can see the data being added to the table editor. If I do a full reload I get the data
n
Hello @kevindmoore! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
m
Are you using streams or the realtime feature of Supabase??
n
kevindmoore (2022-05-23)
k
I've tried both
m
There is a good chance that you havent enable replication
k
I did that and was seeing some progress, however deleting still wasn't working
Inserting worked
g
Do you have a primary key on the table you are monitoring? Delete needs a primary key or you need to do: ALTER TABLE your_table REPLICA IDENTITY FULL in the sql editor.
k
I do
g
Do you have a filter on the subscription?
Here was a thread on flutter and deletes: https://github.com/supabase/supabase/discussions/5256 but it is relatively old in terms of realtime changes.
k
I do have a filter
g
So you may need to do replica full or put the delete in it's own handler. For protection delete normally sends only the primary key as deletes get sent to all subscribers ignoring RLS. replica full sends the full record so then the filter can run on other columns.
k
Do you know of an article that describes all this? Very confusing that I have to add all this. Seems like it should just work
In the Replication page all the toggles are on. In the tables button, my 2 public tables are enabled
g
Try running the sql statement I gave you above on the table, that turns on full replica copy for delete or drop the filter and see if it starts working. One of my feedbacks to the team has been lack of full examples of using realtime. The readme here has some stuff, but still not clear on some issues. https://github.com/supabase/realtime I end up searching issues on supabase/supabase both discussion and issues and supabase/realtime. I'll be honest, I've generated 1/2 dozen issues on realtime and done lots of debugging, and parts are still a mystery to me.
k
I think that worked!
g
Which?
k
The SQL command on the 2 tables I have
Just to confirm, I need to do the following:``` 1. Setup replication on my tables 2. Run the SQL command on my tables ```
g
Just realize now that all the deleted data will show even when you do RLS that might limit which user sees inserts/updates.
k
I don't have RLS turned on as I tried it and things didn't work (so I turned it off)
g
What do you plan to use realtime for?
k
I'm actually doing 2 things: 1. Writing my "Todo Manager" and 2. Creating a video course on how to use Supabase with Flutter
(I do articles, books and videos for raywenderlich.com)
g
Just realize that realtime is only as good as having a constant connection. Anytime a device sleeps, in some cases when a tab goes in background, or internet connection is lost, you really have to restart everything as there is no queue on the server.
k
Hmm. Is there a better solution?
g
I'm debating it's usefullness versus polling except for chat type stuff and even then put a bunch of code around it. This is probably more than you want to get into now, but this shows what I'm doing for reliability: https://github.com/supabase/supabase/discussions/5641 (it is a work in progress) There is a "bug" on background tabs still that I think they will address which will help in the desktop case of just going to another tab for 5 minutes....
k
I did notice that when i came back to the app after awhile, it lost it's authentication
g
Could be related to this, which has a fix about 2 weeks ago, but I'm not sure it caught everything... https://github.com/supabase/supabase/issues/6464
Oh that fix is so far just js, I think...
k
I think I am experiencing what you were talking about. My stream gets in a "waiting" state and I get no data