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

feat: support upserting tables with only unique constraint(s) #680

Merged
merged 4 commits into from
Jul 29, 2023

Conversation

bchrobot
Copy link
Contributor

@bchrobot bchrobot commented Jul 28, 2023

Problem

Upsert mutations are not created for tables without primary keys, even if they have at least one unique constraint. This is inconsistent with Postgraphile core, which generates update mutations for tables with just unique constraints.

Proposed Solution

This updates logic to check for primary key OR at least one unique constraint on the table.

Testing

I have extended an existing test case but have not run the test suite yet (a Contributing section in readme would be a nice addition 🙂).

I have verified behavior experimentally by yarn linking the local clone to an application codebase.

@cdaringe
Copy link
Owner

Githib should show ya the contributing.md, but a link would be nice too. Feel free to add those patches inline here.

https://github.com/cdaringe/postgraphile-upsert/blob/main/.github/contributing.md

missing is the call fir need of docker for integration tests to run

@bchrobot
Copy link
Contributor Author

Githib should show ya the contributing.md, but a link would be nice too. Feel free to add those patches inline here.

https://github.com/cdaringe/postgraphile-upsert/blob/main/.github/contributing.md

missing is the call fir need of docker for integration tests to run

Ah! Thank you for the link. I hadn't thought to look in the .github folder. I don't recall being prompted when opening the PR but maybe missed it

@bchrobot
Copy link
Contributor Author

Okay, I got tests running and passing locally now

@cdaringe cdaringe merged commit 6367c1a into cdaringe:main Jul 29, 2023
@cdaringe
Copy link
Owner

Thanks!

@cdaringe
Copy link
Owner

Ah crap i meant to release it as a breaking change

@github-actions
Copy link

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bchrobot bchrobot deleted the feat-support-unique-only branch July 29, 2023 09:00
@bchrobot
Copy link
Contributor Author

Ah crap i meant to release it as a breaking change

There isn't really a way to pass config options to v4 plugins is there? To have this feature there but off by default.

@cdaringe
Copy link
Owner

No big deal :) thx for the patches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants