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

test: bulk inserting 2 docs with same primary key #6589

Conversation

enrico-teterra-maramalabs

This PR contains:

a failing test

Describe the problem you have without this PR

bulk inserting 2 docs with same primary key should throw conflict error
instead, the collection now contains 2 docs with the same primary key

example:

  • given a collection: people has a primary key: id
  • when people.bulkInsert({id: 1, name: bob}, {id: 1, name: jane})
  • then the bulkInsert is successful and now i have 2 records with the same primary key in the collection
  • people.count().exec() is 2

…hrow conflict error

instead, the collection now contains 2 docs with the same primary key
@pubkey
Copy link
Owner

pubkey commented Nov 17, 2024

Thank you for reporting. I added a fix. I think the correct behavior should be to just throw, RxDB should not be used in that way and the user should ensure bulk opertions do not have duplicates in them.

@enrico-teterra-maramalabs
Copy link
Author

yep throwing an error in this case seems fine! thanks

pubkey added a commit that referenced this pull request Nov 17, 2024
…6595)

* FIX bulk inserting 2 docs with same primary key should throw #6589

* FIX error meta
@pubkey pubkey closed this Nov 17, 2024
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.

2 participants