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

returning data from stream in flutter #218

Closed
yutech23 opened this issue Sep 16, 2022 · 22 comments
Closed

returning data from stream in flutter #218

yutech23 opened this issue Sep 16, 2022 · 22 comments
Labels
bug Something isn't working realtime This issue or pull request is related to realtime

Comments

@yutech23
Copy link

yutech23 commented Sep 16, 2022

doesn't work listening to a specific column.

My Table;
database columns(category5) = (category5_id,name,fk_category4_id)

My code is;

db.supabase
.from('category5:fk_category4_id=eq.${selectCategory5!.keys.first}')
.stream(['category5_id,name']).execute();

return data => all columns.
@yutech23 yutech23 added the bug Something isn't working label Sep 16, 2022
@dshukertjr
Copy link
Member

@yutech23
Thanks for opening this issue.

Are you unable to receive all insert, update, and delete events, or is it only delete events?

There was an issue on our realtime server where the delete events stopped coming through when listening with eq filter, which is resolved now.

@iampopal
Copy link

@dshukertjr
In my case
The stream return for the first time, After initializing str again
Stream failed to load

@iampopal
Copy link

We need to able to cancel stream with StreamSubscription
And
Initialize again

Like
If user not have internet, an error throws form stream,
Then
When user get internet and press refresh we shall able to initialize stream again

@dshukertjr
Copy link
Member

@iampopal That sounds like a separate issue, so would you want to open a new issue and discuss it there? It would be helpful if you could follow the issue template and include some reproducible code as well!

@dshukertjr dshukertjr added the realtime This issue or pull request is related to realtime label Sep 27, 2022
@dshukertjr
Copy link
Member

@yutech23 The issue with not being able to receive delete events has been resolved, so I would like to close this one assuming you were facing the same issue, but if you are still experiencing the issue that you open this thread for, please feel free to reopen it at any time!

@yutech23
Copy link
Author

yutech23 commented Oct 5, 2022

@yutech23 The issue with not being able to receive delete events has been resolved, so I would like to close this one assuming you were facing the same issue, but if you are still experiencing the issue that you open this thread for, please feel free to reopen it at any time!

Hi Sorry for late reply, this problem continues.
image

return value:

image

@dshukertjr dshukertjr reopened this Oct 6, 2022
@dshukertjr
Copy link
Member

@yutech23
Thanks for notifying that it is still not working.

May I ask how you are listening to your stream? Also, you have a provided an screenshot of a log, but how are you logging the data? If you could provide the code for it as well, it would be amazing!

@yutech23
Copy link
Author

yutech23 commented Oct 7, 2022

@yutech23 Thanks for notifying that it is still not working.

May I ask how you are listening to your stream? Also, you have a provided an screenshot of a log, but how are you logging the data? If you could provide the code for it as well, it would be amazing!

Of course.

Listining
image

like this Data input;

image

@dshukertjr
Copy link
Member

@yutech23
Thanks for providing the code. Generally, it would be more awesome if you could copy and paste the code rather than taking a screenshot of it!

I want to make sure that I understand the issue here, but in the title of this issue, you wrote that relatime does not work when listening to a specific column, but it looks like you are not listening to a specific column in this example. Is the issue that you are not able to receive any realtime data at all?

If so, there are few things that come to my mind here.

  • Persist the stream data as state. More details here. In your case, I would just make the stream a property of the bloc instead of returning it in a method.
  • Make sure you have realtime turned on. You can turn it on by managing replication under database menu of your Supabase dashboard.

@yutech23
Copy link
Author

yutech23 commented Oct 14, 2022

Hi,
I made an example similar to this problem.
My database column names are ('category1_id','name')
I want to stream only 'name' column.

My Code;

ElevatedButton(
  onPressed:() async{
    var res =  db.supabase.from('category1').stream(['name']).execute();
    res.listen((event) {
      print(event);
    });

  },
  child: Text('Gönder'))

Returning Data;

[{category1_id: 15, name: Unisex}, {category1_id: 23, name: Kadın}, {category1_id: 25, name: Erkek}]

Note: Returned All Table data.

Thank you for all of replies.

@Vinzent03
Copy link
Collaborator

@yutech23 I don't think you can stream specific columns. Is name your primary key column?

@dshukertjr
Copy link
Member

@yutech23
Yup, with stream(), there is currently no way to limit which columns to retrieve. It can only retrieve all the columns in a table. The List you pass inside the .stream() is list of primary keys for the table.

@Vinzent03
I wonder if we can make the API better by making the primary keys named parameters like this:

supabase.from('category1').stream(primaryKeys: ['id'])

This might open up the api to allow only retrieving certain columns like this:

supabase.from('category1').stream(primaryKeys: ['id'], columns: ['name', 'category'])

@Vinzent03
Copy link
Collaborator

I think that makes it more clear. Do you want to support the column select on client or just prepare for server select with named parameters. But we should change the name, because there is only one primary key, but with multiple columns.

@dshukertjr
Copy link
Member

@Vinzent03

Do you want to support the column select on client or just prepare for server select with named parameters.

Sorry, didn't catch this one. What do you mean by "server select"?

But we should change the name, because there is only one primary key, but with multiple columns.

Oh yeah, makes sense!

@Vinzent03
Copy link
Collaborator

@dshukertjr I mean whether you want to prepare for a future feature of the realtime server of selecting columns, because that's currently not possible, right? Or you want to select columns in the local dart code? So basically where the column filtering happens, on realtime server or local.

@dshukertjr
Copy link
Member

@Vinzent03
Thanks for the clarification! I was thinking about this over the weekend, and was wondering if we really need to add the ability to restrict which columns to select. At least since this would be a new feature, we don't have to implement it right now. Let's wait on this one for now, and just go with changing the syntax around primaryKey for now!

@Vinzent03
Copy link
Collaborator

@dshukertjr lets include the stream parameter change in supabase-dart 1.0.0, right?

@yutech23
Copy link
Author

I don't think you can stream specific columns

'name' is not primary key column.
category1_id is primary key.

@dshukertjr
Copy link
Member

@yutech23
Yup, in your case, you need to get the stream like this:

db.supabase.from('category1').stream(['category1_id']).execute();

Note that there is no way to limit which columns to retrieve at the moment, and .stream() will return all the columns for the table.

@yutech23
Copy link
Author

yutech23 commented Oct 19, 2022

Thank you for all of replies. This feature would be good.

@Vinzent03
Copy link
Collaborator

@yutech23 Is your original issue solved, so we can close this? Selecting columns in stream should be discussed in another issue.

@yutech23
Copy link
Author

@yutech23 Is your original issue solved, so we can close this? Selecting columns in stream should be discussed in another issue.

Of course you could close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working realtime This issue or pull request is related to realtime
Projects
None yet
Development

No branches or pull requests

4 participants