Open rombr opened 9 months ago
Hi, I need to use CodecOptions(tz_aware=True)
CodecOptions(tz_aware=True)
In motor I do this:
from bson.codec_options import CodecOptions import motor.motor_asyncio db = motor.motor_asyncio.AsyncIOMotorClient("connection_str")).get_database( "db_name", codec_options=CodecOptions(tz_aware=True), )
In mongomock_motor I tried:
mongomock_motor
from bson.codec_options import CodecOptions from mongomock_motor import AsyncMongoMockClient fake_db = AsyncMongoMockClient().get_database( "db_name", codec_options=CodecOptions(tz_aware=True), )
But got an error:
lib/python3.11/site-packages/mongomock_motor/__init__.py:242: in get_database self.__client.get_database(*args, **kwargs), lib/python3.11/site-packages/mongomock/mongo_client.py:158: in get_database db = self._database_accesses[name] = Database( lib/python3.11/site-packages/mongomock/database.py:45: in __init__ mongomock_codec_options.is_supported(codec_options) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ custom_codec_options = CodecOptions(document_class=dict, tz_aware=True, uuid_representation=UuidRepresentation.UNSPECIFIED, unicode_decode_er...ne, type_registry=TypeRegistry(type_codecs=[], fallback_encoder=None), datetime_conversion=DatetimeConversion.DATETIME) def is_supported(custom_codec_options): if not custom_codec_options: return None > return CodecOptions(**custom_codec_options._asdict()) E TypeError: CodecOptions.__new__() got an unexpected keyword argument 'datetime_conversion' lib/python3.11/site-packages/mongomock/codec_options.py:87: TypeError
Versions:
mongomock-motor==0.0.21 mongomock==4.1.2 pymongo==4.4.1
Hi, I need to use
CodecOptions(tz_aware=True)
In motor I do this:
In
mongomock_motor
I tried:But got an error:
Versions: