PostgREST / PostgREST/postgrest

Partial document update based on JSON Patch

Open
#3,166 12 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

idea
Dominant language
Haskell
Stars
27.7k
Forks
1.2k
Avg merge
1d 9h
Merged PRs (30d)
54

Description

Problem

Currently there's no way to do a partial document update.

Solution

Use a vendored media type based on json patch where we support the operations we lack. As prior art, azure cosmosdb json patch (also see here) does a similar thing and adds support for increment and set, which are not defined in the JSON Patch RFC.

For starters, we can add support for increment. Like so:

PATCH /items?id=eq.1
Content-Type: application/vnd.pgrst.json-patch

[
  { "op": "incr", "path": "/inventory", "value": 10 },
]

Path would refer to any column and the generated SQL would be like UPDATE items SET inventory = inventory + 10.

Later on we can extend this to add other operations, like mult, div, concat, etc.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by tracing the PATCH endpoint and current media-type handling, then review the linked JSON Patch and Cosmos DB references. Done means the vendored media type accepts the shown incr operation for a column path and produces the described partial SQL update.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
api, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.