postgrest icon indicating copy to clipboard operation
postgrest copied to clipboard

Bulk insert replies with bogus Location header

Open begriffs opened this issue 10 years ago • 1 comments

Sending a bulk post to /foo responds with 201 Created, Location: /foo?. It's incomplete. We could either

  1. Construct a clever Location header like /foo?id.in=4,5,6,7 that would return just the objects inserted. It's difficult because we may be dealing with a compound primary key or a table without a primary key.
  2. Not return a Location header for bulk requests. The user can can use Prefer: return=representation to learn about the inserted objects and even shape the results with a select query param.

begriffs avatar Nov 28 '15 00:11 begriffs

By now, we're not getting a wrong location header in this case anymore, but just no location header at all.

It's difficult because we may be dealing with a compound primary key or a table without a primary key.

What we would really need to solve this properly would be some kind of ROW() constructor query. This would be good in general for queries that request multiple rows for a table with compound pk.

If we could do something like this:

GET /foo?(a,b,c)=in.((1,1,1),(2,2,2),(3,3,3))

then we could do that.

wolfgangwalther avatar Dec 10 '20 09:12 wolfgangwalther

GET /foo?(a,b,c)=in.((1,1,1),(2,2,2),(3,3,3))

If we do that then we might able to clear https://github.com/PostgREST/postgrest/issues/1122 too. Like:

GET /foo?select=()

Would be an empty root select.

/foo?id.in=4,5,6,7

That syntax reminds me of https://github.com/PostgREST/postgrest/issues/2066, things would have been much easier if we had adopted it since the beginning.

steve-chavez avatar Aug 07 '23 05:08 steve-chavez