supabase-community / postgrest-go

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

Add support for returning row count #23

Closed boatilus closed 2 years ago

boatilus commented 2 years ago

This an API-breaking PR that modifies the signature for execute functions, returning the count (if requested) as the second return parameter, and fixes a bug in the implementation where the Prefer option was being set as a query parameter rather than on the request headers. This change in signature pretty closely matches the API for supabase-js.

There was discussion in #8 regarding the need to update APIs to support transforms, so I'm unsure what implications this PR might have if a solution to that is being worked on.

I've also added some basic tests. By default they use httpmock to mock responses from the execute funcs, but POSTGREST_URL and, optionally API_KEY, env vars can be used to test against an actual Postgrest instance. I'm not sure if this is the general approach everyone would prefer to see for testing, but seemed like a sensible place to start. If everyone's satisfied with the approach, I'm happy to expand on tests and document testing in the README.

Note that this adds dependencies on httpmock and stretchr/testify.

muratmirgun commented 2 years ago

Thanks Foru Contribution 💯