Skip to content

inFilter method in streams doesn't filter table if it is primary key #852

Open
@Lazizbek97

Description

@Lazizbek97

Describe the bug
I have one table(chats) which has id auto generated when any items added. other table(chat_members) connected with this table's id field(foreign key pairs). when i listen this chats table, with following code:

final currentUserId = supabase.auth.currentUser?.id;

    final memberSubquery = await supabase
        .from('chat_members')
        .select('chat_id')
        .eq('user_id', currentUserId ?? '');

final List<dynamic> currentUserChatIds =
        memberSubquery.map((e) => e.values.firstOrNull ?? '').toList() ?? [];

  final messageStream = supabase
          .from('chats')
          .stream(primaryKey: ['id']).inFilter('id', chatIds as List<String>);

 await emit.forEach(messageStream, onData: (data) {
        final chats = data.map((e) => ChatMd.fromMap(e)).toList();
        return ChatsLoaded(chats);
      });

it is not giving chats, where its id contains currentUserChatIds.

Expected behavior
i want to filter chats where its id are in current user's chats id list.

Screenshots
Here is chat table
Screenshot 2024-03-09 at 13 48 50

Here is chat member table, where members added when user click on join button
Screenshot 2024-03-09 at 13 49 16

Additional context
flutter version:

Framework • revision 41456452f2 (6 weeks ago) • 2024-01-25 10:06:23 -0800
Engine • revision f40e976bed
Tools • Dart 3.2.6 • DevTools 2.28.5```

supabase version:
supabase_flutter: ^2.3.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedThis issue is blocked by another issuebugSomething isn't workingpostgrestThis issue or pull request is related to postgrestrealtimeThis issue or pull request is related to realtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions