From 257a43298b93785d9280d3942745aab7149bf627 Mon Sep 17 00:00:00 2001 From: Erdenezul Batmunkh Date: Sun, 20 May 2018 12:31:27 +0800 Subject: [PATCH] use MongoClient.is_mongos in ensure indexes #1759 --- mongoengine/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/document.py b/mongoengine/document.py index 2de0b1a3..865bb063 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -854,7 +854,7 @@ class Document(BaseDocument): collection = cls._get_collection() # 746: when connection is via mongos, the read preference is not necessarily an indication that # this code runs on a secondary - if not collection.is_mongos and collection.read_preference > 1: + if not collection.database.client.is_mongos and collection.read_preference > 1: return # determine if an index which we are creating includes