Skip to content

Commit 54ef30d

Browse files
authored
Changed getting system datetime to cached_property (#217)
1 parent a62e064 commit 54ef30d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mssql/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import datetime
1212

1313
from django.core.exceptions import ImproperlyConfigured
14+
from django.utils.functional import cached_property
1415

1516
try:
1617
import pyodbc as Database
@@ -430,7 +431,7 @@ def init_connection_state(self):
430431
if (options.get('return_rows_bulk_insert', False)):
431432
self.features_class.can_return_rows_from_bulk_insert = True
432433

433-
val = self.get_system_datetime()
434+
val = self.get_system_datetime
434435
if isinstance(val, str):
435436
raise ImproperlyConfigured(
436437
"The database driver doesn't support modern datatime types.")
@@ -443,6 +444,7 @@ def is_usable(self):
443444
else:
444445
return True
445446

447+
@cached_property
446448
def get_system_datetime(self):
447449
# http://blogs.msdn.com/b/sqlnativeclient/archive/2008/02/27/microsoft-sql-server-native-client-and-microsoft-sql-server-2008-native-client.aspx
448450
with self.temporary_connection() as cursor:

0 commit comments

Comments
 (0)