CASB-178258: Changes for pymongo-4.7+ - #8
Conversation
|
|
||
| if return_id: | ||
| return collection.save(doc, **options) | ||
| return collection.insert_one(doc, **options) |
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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).
|
@kondaiahv : is this command needs to be taken care? |
| 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}}, |
There was a problem hiding this comment.
@kondaiahv will this be update_many or update_one?
There was a problem hiding this comment.
That's a DDL add column method. So, that's should be update_many to add new column/field in all docs.
| def delete_column(self, table_name, name): | ||
| collection = self._get_collection(table_name) | ||
| collection.update({}, {'$unset': {name: 1}}) | ||
| collection.update_many({}, {'$unset': {name: 1}}) |
There was a problem hiding this comment.
@kondaiahv will this be update_many or update_one?
There was a problem hiding this comment.
That's a DDL remove column method. So, that's should be update_many to remove a column/field from all docs.
| 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}}, |
There was a problem hiding this comment.
That's a DDL add column method. So, that's should be update_many to add new column/field in all docs.
| def delete_column(self, table_name, name): | ||
| collection = self._get_collection(table_name) | ||
| collection.update({}, {'$unset': {name: 1}}) | ||
| collection.update_many({}, {'$unset': {name: 1}}) |
There was a problem hiding this comment.
That's a DDL remove column method. So, that's should be update_many to remove a column/field from all docs.
Adding changes for Django-mongodb-engine to support pymongo-4.7+