sassoftware / postgrest-client

General purpose type-safe TypeScript client for PostgREST. Supports select, insert, update, upsert, delete queries with composite joins, resource embedding, full JSON column data handling and typing.
Apache License 2.0
7 stars 0 forks source link

feat: top level filter (!inner) #12

Closed bojan88 closed 3 weeks ago

bojan88 commented 1 month ago

Support for top level filtering (!inner keyword) https://postgrest.org/en/v12/references/api/resource_embedding.html#top-level-filtering

This is adding .inner() method to the query class. In case it's used on root query it will throw an error later in toString(), and if called in embedded query it will set !inner keyword in the constructed query string.

Documentation will be updated later after releasing this.

bojan88 commented 1 month ago

Tests are fixed in https://github.com/sassoftware/postgrest-client/pull/13, so we'll need to merge that first

kegjon commented 3 weeks ago

A random note that, while I understand its referencing INNER joins, I wish that PostgREST simply used joins explicitly in their query building instead of embedded queries. I think the extra layer of domain words / knowledge is unnecessary.

But the implementation should match PostgREST for us, so matching the spec is what will make the most sense for us. Adding the exception for top level is a good call, but allowing it for simplicity is fine with me.

Also the unit tests have great coverage. Really appreciate the work to maintain them across the whole interface. Gives confidence in adding features. :)