PostgREST / PostgREST/postgrest
Partial document update based on JSON Patch
Nobody has claimed this yet.
- 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.
- https://github.com/PostgREST/postgrest/issues/465#issuecomment-1198884375 discusses json patch but there are certain operations (like
test) which don't make much sense given our horizontal filtering. - An alternative is proposed on https://github.com/PostgREST/postgrest/issues/465#issuecomment-1199858002, but it's flexibility makes it harder to implement. Additionally it's not isolated to a single content type.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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