txmongo icon indicating copy to clipboard operation
txmongo copied to clipboard

insert_many: unexpected keyword argument 'bypass_document_validation' in calling pymongo `_Bulk`

Open vestronge opened this issue 4 years ago • 2 comments

Versions

txmongo==19.2.0
pymongo==3.0.3

The insert_many method of txmongo.collection.Collection uses

bulk = _Bulk(self, ordered, bypass_document_validation=False)

But the _Bulk method in pymongo 3.0.3 doesn't have the argument bypass_document_validation

class _Bulk(object):
    """The private guts of the bulk write API.
    """
    def __init__(self, collection, ordered):
         ...

This causes the following error on using insert_many

  File \"/usr/local/lib/python3.7/site-packages/txmongo/collection.py\", line 824, in insert_many
    bulk = _Bulk(self, ordered, bypass_document_validation=False)
TypeError: __init__() got an unexpected keyword argument 'bypass_document_validation'"}

vestronge avatar Sep 07 '21 12:09 vestronge

Seems like we need to rise pymongo version in our requirements.txt and setup.py, we are not compatible with 3.0 anymore...

Is it possible for you to use more recent version of PyMongo?

IlyaSkriblovsky avatar Sep 07 '21 13:09 IlyaSkriblovsky

Upgrading pymongo should work, but since it was a large repo and upgrade takes a little time (to go through all usages and changelogs and make changes accordingly), we didn't take that route.

Instead, we just used .insert(list of docs) function for the bulk write which worked fine.

vestronge avatar Sep 08 '21 07:09 vestronge