Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the filters in POST requests for UPSERTS #3611

Open
laurenceisla opened this issue Jun 19, 2024 · 1 comment
Open

Use the filters in POST requests for UPSERTS #3611

laurenceisla opened this issue Jun 19, 2024 · 1 comment
Labels
idea Needs of discussion to become an enhancement, not ready for implementation

Comments

@laurenceisla
Copy link
Member

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:

-- ...
ON CONFLICT DO
   UPDATE ...
   WHERE <the filter goes here>

Then the previous request would return:

[{"unique_key":2,"value":"C"}]
@laurenceisla laurenceisla added the idea Needs of discussion to become an enhancement, not ready for implementation label Jun 19, 2024
@wolfgangwalther
Copy link
Member

I don't think that's the right thing to do semantically. This smells like PUT, not POST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Needs of discussion to become an enhancement, not ready for implementation
Development

No branches or pull requests

2 participants