django-postgres-copy
django-postgres-copy copied to clipboard
Add upsert functionality
I've updated my older PR #156 to align with the recent psycopg changes. Where possible, I have utilized the approach taken by Django in queryset.bulk_create(), which supports upsert (see docs).
At the moment, specifying update_conflicts=True also requires explicitly setting drop_indexes=False and drop_constraints=False (since they are required by PostgreSQL to locate conflicting rows). This leads to a few options:
- Keep as is and require the user to be explicit in overriding the
drop_indexesanddrop_constraintsdefaults. - Let
update_conflicts=Trueoverride and setdrop_indexesanddrop_constraintstoFalse. - Change the default values of
drop_indexesanddrop_constraints, as discussed in #117.
Despite my comments in #117, I now have no preference among those options and would be happy to have it implemented any such way.
I'd be happy to answer any questions or implement any requested changes.
Merging this PR would close #91, #117 (possibly as "won't fix"), #122, and #168.