Skip to content

in filter is incorrect #2

Description

@Towerful

As per: https://supabase.com/docs/guides/realtime/extensions/postgres-changes#in

the in filter must follow the pattern of:
id=in.(1,2,3)

Currently, j-supabase is subscribing using the pattern:
id=in.1,2,3

passing in a string of (1,2,3) to the in() function properly subscribes and follows changes, however it then breaks the supabase/postgrest-js as follows:

Uncaught TypeError: values.map is not a function
    at PostgrestFilterBuilder.in (PostgrestFilterBuilder.ts:223:8)
    at initialize (realtime.ts:42:45)
    at realtime.ts:88:25

https://github.com/jdgamble555/j-supabase/blob/master/src/lib/realtime.ts#L32

const filterString = `${field}=${filterName}.${value}`;

needs to account for the in filter.
Perhaps something like:

let filterString = `${field}=${filterName}.${value}`;
if (filterName === 'in') {
  if (!Array.isArray(value)) throw new Error('Filter value must be an array when using "in"')
  filterString = `${field}=${filterName}.(${value.join(',')})`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions