Allow specifying insert method for bulk transactions #614
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
We have started adopting the bulk transactions extension for loading data into our pgstac backend, but are blocked by the fact that we occasionally need to re-ingest an updated item. The
bulk_item_insert
route does not provide a means of specifying alternate data loading methods (e.g. upsert, delsert, etc) and stac-fastapi-pgstac only supports inserts via thecreate_items
function. In the event of a conflict, it returns a ConflictError with no details regarding which of the bulk items caused the conflict, which makes it difficult to correct the issue.In this PR, I propose adding an optional parameter to the request object for the bulk_item_insert route. This
method
parameter will allow clients to specify the use ofupsert
rather than the defaultinsert
behavior. I have created a separate PR on stac-fastapi-pgstac to support conditionally using theupsert_items
function.This change should not impact any stac-fastapi backends which do not support alternate loading methods, since they will ignore the optional param.
PR Checklist:
pre-commit
hooks pass locallymake test
)make docs
)