supabase-community / postgrest-go

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

Fix malformed array literal cause by Contains & ContainedBy functions #46

Closed whoiscarlo closed 7 months ago

whoiscarlo commented 7 months ago

What kind of change does this PR introduce?

Correctly formatting the array used by the Contains & ContainedBy functions

Bug fix, feature, docs update, ... Arrays in Postgres use this string format {10000, 10000, 10000, 10000} or {"meeting", "lunch"}

What is the current behavior?

value []string{"foo", "bar"} turns into foo bar

Please link any relevant issues here. https://github.com/supabase-community/postgrest-go/pull/43

What is the new behavior?

Will turn values []string{"foo", "bar"} into '{"foo", "bar"}

Additional context

https://www.postgresql.org/docs/current/arrays.html

yusufpapurcu commented 7 months ago

Hey, thanks for contribution 👋 Supabase uses PostgREST underneath to expose postgres as an API. What we have in the client code is written according to that. Here is the related documentation about it. https://postgrest.org/en/stable/references/api/tables_views.html#horizontal-filtering

To be honest PostgREST documentation doesn't clarify the question "How the arrays should be represented?". So it would be great if you test the expected behaviour and edge cases and link to the PR.

(Also I will be trying it as well 🙂 )

muratmirgun commented 7 months ago

Hey, first of all, thank you, I have created a new local setup and cases for this pr and will test it completely fine. I will get back to your additions

yusufpapurcu commented 7 months ago

I tested the usecase and it works with your PR!