mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

read_preference_tags are not registered correct in the ReadPrecence Object

Open miha93 opened this issue 3 years ago • 0 comments

Hi All,

I'm trying to pass a read preference tags in my URI:

Using the following command: mongo_connection = connect(host=config.MONGO_CONNECTION_URI)

With the following URI: 'mongodb://root:[email protected]:27017,2.2.2.2:27017,3.3.3.3:27017/api?replicaSet=s0&readPreference=secondary&readPreferenceTags=region:us-west-2,usage:api'

But the result I get when looking at the mongoclient created

MongoClient(host=['1.1.1.1:27017', '2.2.2.2:27017', '3.3.3.3:27017'], document_class=dict, tz_aware=False, connect=True, replicaset='s0', readpreference='secondary', readpreferencetags=[{'region': 'us-west-2', 'usage': 'api'}], read_preference=Secondary(tag_sets=None, max_staleness=-1, hedge=None))

you can see tag_sets is empty and it's not taken into account, Please advise what is the best way to use read preference tags with MongoEngine

miha93 avatar Mar 31 '22 14:03 miha93