Open laurenceisla opened 5 months ago
Right now, UPSERTS done with POST requests ignore the filters in the query string, e.g:
curl -X POST "localhost:3000/single_unique?on_conflict=unique_key&unique_key=neq.1" \ -H "Content-Type: application/json" \ -H "Prefer: resolution=merge-duplicates" \ -H "Prefer: return=representation" \ -d '[{ "unique_key": 1, "value": "B" },{ "unique_key": 2, "value": "C" }]'
[{"unique_key":1,"value":"B"}, {"unique_key":2,"value":"C"}]
But we could make the filter behave like when doing an UPDATE through PATCH. So, unique_key=neq.1 would not be ignored and instead, it would be used in:
unique_key=neq.1
-- ... ON CONFLICT DO UPDATE ... WHERE <the filter goes here>
Then the previous request would return:
[{"unique_key":2,"value":"C"}]
I don't think that's the right thing to do semantically. This smells like PUT, not POST.
PUT
POST
Right now, UPSERTS done with POST requests ignore the filters in the query string, e.g:
But we could make the filter behave like when doing an UPDATE through PATCH. So,
unique_key=neq.1
would not be ignored and instead, it would be used in:Then the previous request would return: