Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

feat: add in_ filter on stream() #191

Merged
merged 4 commits into from
Apr 12, 2023
Merged

feat: add in_ filter on stream() #191

merged 4 commits into from
Apr 12, 2023

Conversation

dshukertjr
Copy link
Member

What kind of change does this PR introduce?

Add support for the in filter to be used in .stream(). Same as the postgrest in_ method, in is a reserved word in Dart, so had to change the filter from in to in_.

supabase.from('table').stream(primaryKey: ['id']).in_('name', ['Andy', 'Santiago', 'Holt']).listen();

'${currentStreamFilter.column}=${currentStreamFilter.type.name}.${currentStreamFilter.value}';
if (currentStreamFilter.type == _FilterType.in_) {
realtimeFilter =
'${currentStreamFilter.column}=in.(${currentStreamFilter.value.join(',')})';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need some additional " in case currentStreamFilter.value is a List of Strings containing , itself. I don't know how the realtime server handles them, but maybe do it like here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code, and did some testing. It works with int and basic string not containing ,, but it doesn't work with strings containing ,.

We could say it's a but on the realtime engine, but Supabase relatime isn't designed to cover every single query use case. If someone is trying to listen to values on the database with applying filters on a value with , in it, I'd say that particular person is doing something wrong.

We can keep the code in case Realtime engine does become compatible with , values in the string, but we shouldn't stress too much about it.

@bdlukaa
Copy link
Contributor

bdlukaa commented Apr 9, 2023

Have you considered inFilter or filterIn? I kinda find in_ weird

@dshukertjr
Copy link
Member Author

@bdlukaa
Great point! I have updated the code. We probably could update the name on postgrest methods too huh?

@dshukertjr dshukertjr merged commit 9757207 into main Apr 12, 2023
4 checks passed
@dshukertjr dshukertjr deleted the feat/stream-in branch April 12, 2023 03:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants