From 8b38f5e3b382a8539a15bb46147a80b554398a84 Mon Sep 17 00:00:00 2001 From: "A.J.Rouvoet" Date: Wed, 6 Mar 2013 23:33:57 +0100 Subject: [PATCH] Fixed two issues arising when the backend is used against Django v1.5: + get_grouping() argument list changed: in 1.5 it takes the `ordering_group_by` parameter + _DJANGO_VERSION was not set correctly in base.py --- sql_server/pyodbc/base.py | 7 ++++++- sql_server/pyodbc/compiler.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sql_server/pyodbc/base.py b/sql_server/pyodbc/base.py index 7270a509..d3f1969d 100644 --- a/sql_server/pyodbc/base.py +++ b/sql_server/pyodbc/base.py @@ -21,7 +21,12 @@ from django.db.backends.signals import connection_created from django.conf import settings from django import VERSION as DjangoVersion -if DjangoVersion[:2] == (1,4): + +if DjangoVersion[:2] == (1,5): + # Django version 1.5 requires connection to be passed + # to BaseDatabaseOperations + _DJANGO_VERSION = 15 +elif DjangoVersion[:2] == (1,4): # Django version 1.4 adds a backwards incompatible change to # DatabaseOperations _DJANGO_VERSION = 14 diff --git a/sql_server/pyodbc/compiler.py b/sql_server/pyodbc/compiler.py index a45e56d1..cc0f48b7 100644 --- a/sql_server/pyodbc/compiler.py +++ b/sql_server/pyodbc/compiler.py @@ -165,7 +165,7 @@ def _as_sql(self, strategy): result.append('WHERE %s' % where) params.extend(w_params) - grouping, gb_params = self.get_grouping() + grouping, gb_params = self.get_grouping( ordering_group_by ) if grouping: if ordering: # If the backend can't group by PK (i.e., any database