Serves PATCH /<table>?<filters> and DELETE /<table>?<filters>, on the pipeline in
PgRest.Write.
The filters (and logic trees) of the query string select the rows. They are planned like a
read's, so a typo (?idd=eq.1) is a 42703 and a column outside readable: a 42501, before
any SQL, and compiled onto the mutation target by PgRest.SQL.Write.update/5 and
delete/4: on the table itself for the identity scope (PostgREST's shape, which also serves
tables without a primary key), through the scope and FOR UPDATE otherwise.
- Authorization. The operation (
:updateor:delete), plus:readwhen the request has any filter, a count orreturn=representation: filters and counts are a read channel. require_filters_for_mutations(defaulttrue): a request with no filter is a 40021000(UPDATE requires a WHERE clause,DELETE requires a WHERE clause), as with Supabase'spg-safeupdate. APATCHthat sets no column is exempt: it touches no row.PATCHpayload. One object (PgRest.Write.Payload.build_update/5). Without a custom changeset the supplied keys (orcolumns=) are set as sent. With one, the columns set are the changeset's final changes (it runs once; seePgRest.Write.Payload): an absent or uncast key is untouched, and a value equal to the struct default is set only when the changeset casts withforce_changes: true. A payload column outside the resource's writable set is a 42501.- Write check. An updated row must still be visible through the scope, else 42501 and a
rollback, in the form
PgRest.Writeuses for inserts. ADELETEhas no check. - Response. 204 with
Content-Range(PgRest.Responder.mutation/6), or 200 with the rows forreturn=representation.Accept: application/vnd.pgrst.object+jsonrequires exactly one row (else 406 and a rollback).limit,offset,columns(forDELETE) do not select the rows and are ignored.
Differences from PostgREST
PATCH arrays with several objects return PGRST102 instead of applying one arbitrarily. Embedded mutation logic trees are rejected, and embedded pagination on minimal mutations returns PGRST108 rather than being ignored.
Summary
Functions
Runs the PATCH (:update) or DELETE (:delete) and sends the response.
Functions
@spec run(Plug.Conn.t(), map(), map(), PgRest.Request.t(), map(), :update | :delete) :: Plug.Conn.t()
Runs the PATCH (:update) or DELETE (:delete) and sends the response.