Skip to content

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

Merged
parsonsmatt merged 1 commit intomasterfrom
matt/upsert-sql-uniqs
Apr 16, 2019
Merged

Fix upsert SQL to take a list of unique defs#895
parsonsmatt merged 1 commit intomasterfrom
matt/upsert-sql-uniqs

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)

@parsonsmatt parsonsmatt force-pushed the matt/upsert-sql-uniqs branch from c295f42 to fc72f34 Compare April 16, 2019 03:11
@parsonsmatt parsonsmatt requested a review from psibi April 16, 2019 03:11
@parsonsmatt parsonsmatt mentioned this pull request Apr 16, 2019
4 tasks
@parsonsmatt parsonsmatt requested a review from MaxGabriel April 16, 2019 03:16
]
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