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

Fix upsert SQL to take a list of unique defs #895

Merged
merged 1 commit into from
Apr 16, 2019

Conversation

parsonsmatt
Copy link
Collaborator

@parsonsmatt parsonsmatt commented Apr 16, 2019

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@@ -315,7 +317,7 @@ upsertSql' ent updateVal = T.concat
, " RETURNING ??"
]
where
wher = T.intercalate " AND " $ map singleCondition $ entityUniques ent
wher = T.intercalate " AND " $ map singleCondition $ NEL.toList uniqs
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue that prompted this change is documented in #856 . Basically, the type UpsertBy in the tests has two unique defs. The old implementation summoned up all the uniquedefs, and this was OK since the upsert function would blow up at runtime before generating this unless the entity had exactly one unique key.

This change allows the user to provide the unique keys to upsert by. This enables backend-specific upsert-by which should be faster and safer.

@parsonsmatt parsonsmatt merged commit 67bcd37 into master Apr 16, 2019
@parsonsmatt parsonsmatt deleted the matt/upsert-sql-uniqs branch April 16, 2019 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant