Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Upsert#156

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
geoffrey-eisenbarth wants to merge15 commits intopalewire:main
base:main
Choose a base branch
Loading
fromgeoffrey-eisenbarth:upsert

Conversation

geoffrey-eisenbarth
Copy link
Contributor

I'm willing to write tests and update documentation if this approach seems sufficient.

Having some trouble getting the test suite to run (gettingdjango.db.utils.OperationalError: fe_sendauth: no password supplied when I runpipenv run python setup.py test); do I need to create a (postgres) database calledtest?

pauloxnet reacted with thumbs up emoji
@palewire
Copy link
Owner

palewire commentedMar 8, 2023
edited
Loading

Thanks for taking a run at it. Tests and documentation will def. be something we want. Yes I think you'll need a database to test against.

Here is how the test suite configures the databasehttps://github.com/palewire/django-postgres-copy/blob/main/.github/workflows/continuous-deployment.yaml#L11-L21

@geoffrey-eisenbarth
Copy link
ContributorAuthor

geoffrey-eisenbarth commentedMar 8, 2023
edited
Loading

@palewire Thanks for giving the go-ahead. I've got some new tests in progress, but will wait to commit them until I can run them locally.

EDIT: Got testing up and running, had to edit mypg_hba.conf totrust, I think mypostgres db user had a password set.

@geoffrey-eisenbarth
Copy link
ContributorAuthor

@palewire While writing tests I discovered a weird nuance about Django's "Model Constraints," it's now been addressed (and covered in testing).

The basic issue was that if a constraint is specified as

class Meta:  constraints = [    models.UniqueConstraint(      fields=['field1', 'field2'],      include=['field3'],  # This prevents a real psql "constraint" from being created      name='my_constraint',    )  ],

then Django doesn't actually create a PSQL constrained named "my_constraint", it creates a UNIQUE INDEX, so doing something likeON CONFLICT ON CONSTRAINT "my_constraint" DO... will fail because there is no PSQL constraint named "my_constraint."

However, it seems in PSQL documentation forINSERT they recommend not naming constraints directly, but rather to let PSQL figure it out by just naming the relevant columns, so I've done that and things look good, all tests passing.

Going to look into how to update the documentation next. Is there anything obvious next steps I'm missing? Thanks!

@geoffrey-eisenbarth
Copy link
ContributorAuthor

@palewire Is it possible for me to re-run the GitHub actions? The PR is passing tests and flake8 locally. Not sure how to progress.

@geoffrey-eisenbarth
Copy link
ContributorAuthor

@palewire Can I get an update on this? It's been working well on my machine for awhile now, hoping to use it in production soon. Is there anything else I can do to move this forward?

Thanks!

@geoffrey-eisenbarth
Copy link
ContributorAuthor

After a discussion awhile back on the postgresql Slack, it was recommended I add theIS DISTINCT FROM clause to avoid "updating" rows that didn't actually change.

@geoffrey-eisenbarthgeoffrey-eisenbarth mentioned this pull requestDec 30, 2023
@geoffrey-eisenbarth
Copy link
ContributorAuthor

@palewire Any movement for this? I'm willing to fix any conflicts with the current version. If it's your preference not to support upsert, or do it a different way, could you let me know?

Thanks!

@geoffrey-eisenbarth
Copy link
ContributorAuthor

@palewire Just giving you another ping. If you want me to let this go, just let me know. Thanks!

@geoffrey-eisenbarth
Copy link
ContributorAuthor

geoffrey-eisenbarth commentedJun 16, 2025
edited
Loading

@palewire I'm willing to review this PR and update as necessary. I've been using my fork in production for the last year or so without any issues. I'd really like to get it implemented if you're interested.

Edit: BTW, at some point Django started supporting something similar with thebulk_createupdate_conflicts kwarg.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@palewirepalewireAwaiting requested review from palewirepalewire is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@geoffrey-eisenbarth@palewire

[8]ページ先頭

©2009-2025 Movatter.jp