-
Notifications
You must be signed in to change notification settings - Fork 23
Add write concern support #328
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
base: main
Are you sure you want to change the base?
Add write concern support #328
Conversation
- Add WriteConcern import from pymongo - Add write concern parsing in DatabaseWrapper.__init__() - Support dict, string, and int write concern formats - Apply write concern to collections in get_collection() - Add comprehensive tests for write concern functionality
Thanks for your interest in contributing, Monisha. Since
|
Hey @timgraham, thanks for looking at this! I think there might be some confusion about what my code actually does. The crash you mentioned won't happen because I'm not passing # This extracts WRITE_CONCERN before MongoClient sees it
self._write_concern = self._parse_write_concern(settings_dict.get('OPTIONS', {}).get('WRITE_CONCERN')) So the difference is:
I went with collection-level because I thought it gave more control, but honestly I'm not sure which approach you'd prefer for this project. Would client-level write concern work better? I can easily change it if that's what makes more sense. Just let me know what direction you want to go - happy to adjust! |
The line you quoted doesn't remove
How does handling write concern at the collection level give more control (if you pass the same options to all collections)? Are you a MongoDB user who is using this project and needs this functionality? As Jib said, I believe we don't need any changes to support write concern after all. |
This PR implements write concern support to replace the broken implementation that didn't work with latest PyMongo APIs.
Changes:
Add WriteConcern import and parsing in DatabaseWrapper
Support dict, string, and int configuration formats
Apply write concern automatically to all collections
Add comprehensive tests
Usage:
DATABASES = { 'default': { 'ENGINE': 'django_mongodb_backend', 'NAME': 'mydb', 'OPTIONS': { 'WRITE_CONCERN': {'w': 'majority', 'j': True} # or 'majority' or 2 } } }
fixes #6