File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 2
2
import os
3
3
4
4
from django .core .exceptions import ImproperlyConfigured
5
- from django .db import DEFAULT_DB_ALIAS
5
+ from django .db import DEFAULT_DB_ALIAS , connections
6
6
from django .db .backends .base .base import BaseDatabaseWrapper
7
7
from django .db .backends .utils import debug_transaction
8
8
from django .utils .asyncio import async_unsafe
9
9
from django .utils .functional import cached_property
10
10
from pymongo .collection import Collection
11
11
from pymongo .driver_info import DriverInfo
12
+ from pymongo .errors import EncryptionError
12
13
from pymongo .mongo_client import MongoClient
13
14
14
15
from . import __version__ as django_mongodb_backend_version
@@ -286,5 +287,10 @@ def validate_no_broken_transaction(self):
286
287
287
288
def get_database_version (self ):
288
289
"""Return a tuple of the database's version."""
289
- # return tuple(self.connection.server_info()["versionArray"])
290
- return (8 , 1 , 1 )
290
+ try :
291
+ return tuple (self .connection .server_info ()["versionArray" ])
292
+ except EncryptionError :
293
+ # Work around self.connection.server_info's refusal to work
294
+ # with encrypted connections.
295
+ default_connection = connections [DEFAULT_DB_ALIAS ]
296
+ return default_connection .get_database_version ()
You can’t perform that action at this time.
0 commit comments