Skip to content

CASB-178258: Changes for pymongo-4.7+ - #8

Open
kondaiahv wants to merge 3 commits into
feature-pymongo-upgrade-py3from
feature-pymongo-django-upgrade
Open

CASB-178258: Changes for pymongo-4.7+#8
kondaiahv wants to merge 3 commits into
feature-pymongo-upgrade-py3from
feature-pymongo-django-upgrade

Conversation

@kondaiahv

Copy link
Copy Markdown

Adding changes for Django-mongodb-engine to support pymongo-4.7+

Comment thread django_mongodb_engine/compiler.py Outdated

if return_id:
return collection.save(doc, **options)
return collection.insert_one(doc, **options)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@kondaiahv : Looks like the function insert can pass single or multiple docs.
So we need to support both insert_one and insert_many()?
How the old code is working also we need to check

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Actual Django-mongo save(update/insert) only one doc at a time based on primary key(_id). If we want to update multiple documents, we need to change this logic & our code(if anywhere handling return ids).

@ilavajuthy

Copy link
Copy Markdown

@kondaiahv : is this command needs to be taken care?
self.database.command('ismaster')
I see this in base.py

Comment thread django_mongodb_engine/compiler.py
Comment thread django_mongodb_engine/south_adapter.py Outdated
default = connection.ops.value_for_db(db_prep_save, field)
# Update all the documents that haven't got this field yet
collection.update({name: {'$exists': False}},
collection.update_many({name: {'$exists': False}},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@kondaiahv will this be update_many or update_one?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That's a DDL add column method. So, that's should be update_many to add new column/field in all docs.

Comment thread django_mongodb_engine/south_adapter.py Outdated
def delete_column(self, table_name, name):
collection = self._get_collection(table_name)
collection.update({}, {'$unset': {name: 1}})
collection.update_many({}, {'$unset': {name: 1}})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@kondaiahv will this be update_many or update_one?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That's a DDL remove column method. So, that's should be update_many to remove a column/field from all docs.

Comment thread django_mongodb_engine/compiler.py
Comment thread django_mongodb_engine/south_adapter.py Outdated
default = connection.ops.value_for_db(db_prep_save, field)
# Update all the documents that haven't got this field yet
collection.update({name: {'$exists': False}},
collection.update_many({name: {'$exists': False}},

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That's a DDL add column method. So, that's should be update_many to add new column/field in all docs.

Comment thread django_mongodb_engine/south_adapter.py Outdated
def delete_column(self, table_name, name):
collection = self._get_collection(table_name)
collection.update({}, {'$unset': {name: 1}})
collection.update_many({}, {'$unset': {name: 1}})

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That's a DDL remove column method. So, that's should be update_many to remove a column/field from all docs.

Comment thread django_mongodb_engine/compiler.py
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