Skip to content

Commit cc22e8d

Browse files
committed
fix issue avidal#8
1 parent bce251f commit cc22e8d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

django_pyodbc/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,18 @@
2525
from django.db.backends.signals import connection_created
2626
from django.conf import settings
2727
from django import VERSION as DjangoVersion
28-
if DjangoVersion[:2] == (1,2):
29-
from django import get_version
30-
version_str = get_version()
31-
if 'SVN' in version_str and int(version_str.split('SVN-')[-1]) < 11952: # django trunk revision 11952 Added multiple database support.
32-
_DJANGO_VERSION = 11
33-
else:
34-
_DJANGO_VERSION = 12
28+
if DjangoVersion[:2] >= (1,5):
29+
_DJANGO_VERSION = 15
30+
elif DjangoVersion[:2] == (1,4):
31+
_DJANGO_VERSION = 14
32+
elif DjangoVersion[:2] == (1,3):
33+
_DJANGO_VERSION = 13
34+
elif DjangoVersion[:2] == (1,2):
35+
_DJANGO_VERSION = 12
3536
elif DjangoVersion[:2] == (1,1):
3637
_DJANGO_VERSION = 11
3738
elif DjangoVersion[:2] == (1,0):
3839
_DJANGO_VERSION = 10
39-
elif DjangoVersion[0] == 1:
40-
_DJANGO_VERSION = 13
4140
else:
4241
_DJANGO_VERSION = 9
4342

@@ -85,6 +84,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
8584

8685

8786
class DatabaseWrapper(BaseDatabaseWrapper):
87+
_DJANGO_VERSION = _DJANGO_VERSION
8888
drv_name = None
8989
driver_needs_utf8 = None
9090
MARS_Connection = False

django_pyodbc/compiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ def _as_sql(self, strategy):
165165
result.append('WHERE %s' % where)
166166
params.extend(w_params)
167167

168-
grouping, gb_params = self.get_grouping(ordering_group_by)
168+
if self.connection._DJANGO_VERSION >= 15:
169+
grouping, gb_params = self.get_grouping(ordering_group_by)
170+
else:
171+
grouping, gb_params = self.get_grouping()
169172
if grouping:
170173
if ordering:
171174
# If the backend can't group by PK (i.e., any database

0 commit comments

Comments
 (0)