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: batchDelete returns incorrect sync result #1907

Merged
merged 1 commit into from Mar 26, 2024

Conversation

TBonnin
Copy link
Collaborator

@TBonnin TBonnin commented Mar 26, 2024

Describe your changes

Sync can return incorrect deletion results.
Fixing by getting directly getting the modified rows when soft_delete = true

Issue ticket number and link

https://linear.app/nango/issue/NAN-641/batchdelete-doesnt-return-the-correct-result

Checklist before requesting a review (skip if just adding/editing APIs & templates)

  • I added tests, otherwise the reason is:
  • I added observability, otherwise the reason is:
  • I added analytics, otherwise the reason is:

Copy link

linear bot commented Mar 26, 2024

@@ -164,7 +164,7 @@ describe('Running sync', () => {
{ id: '1', name: 'a' },
{ id: '2', name: 'b' }
];
const expectedResult = { added: 0, updated: 0, deleted: 0 };
const expectedResult = { added: 0, updated: 0, deleted: 2 };
Copy link
Collaborator Author

@TBonnin TBonnin Mar 26, 2024

Choose a reason for hiding this comment

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

I had the wrong test 🤦


if (softDelete) {
return {
success: true,
summary: {
deletedKeys: [...addedKeys, ...updatedKeys],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addedKeys would be empty, since it is checking if the ids is already in the db. UpdatedKeys is also empty if the record hash hasn't changed

@TBonnin TBonnin force-pushed the tbonnin/NAN-641/batch-delete-incorrect-result branch from 612211f to 065b75e Compare March 26, 2024 15:47
@TBonnin TBonnin merged commit 8ddd5e7 into master Mar 26, 2024
18 checks passed
@TBonnin TBonnin deleted the tbonnin/NAN-641/batch-delete-incorrect-result branch March 26, 2024 16:32
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.

None yet

2 participants