supabase-community / postgrest-go

Isomorphic Go client for PostgREST. (Now Updating)
https://supabase.io
Apache License 2.0
170 stars 27 forks source link

Filter conditions on the same column overwrite each other #53

Open dmedora opened 2 months ago

dmedora commented 2 months ago

Bug report

Describe the bug

If multiple filters are provided for a particular column, only the last filter is applied in the query. All the previous ones are overwritten. This happens here in the FilterBuilder implementation (for all operators).

If we take a look at the other Supabase PostgREST implementations, they append additional filters instead (eg. here in postgrest-dart, here in postgREST-js).

To Reproduce

// Table has a column 'year' with values 2020, 2022, 2024.

client.From("mytable").Select("*", "exact", false).gte("year", 2023).lte("year", 2024).Execute()

// Results include 2020, 2022, 2024. Expected only 2024.

Expected behavior

Multiple filters for a given column should all be applied.

System information

dmedora commented 2 months ago

This was also reported in supabase-go: https://github.com/supabase-community/supabase-go/issues/13