Skip to content

Commit 221bed4

Browse files
committed
fix issue avidal#6
1 parent 8b6f2a9 commit 221bed4

File tree

4 files changed

+11
-390
lines changed

4 files changed

+11
-390
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ supports SQL Server 2000 and 2005.
88
Features
99
--------
1010

11+
* Supports Django 1.2 or newer.
1112
* Supports LIMIT+OFFSET and offset w/o LIMIT emulation under SS2005.
1213
* Supports LIMIT+OFFSET under SS2000.
1314
* Transparently supports Django's TextField both under SS2000 and SS2005.
@@ -114,6 +115,7 @@ Credits
114115

115116
* [Alex Vidal](https://github.com/avidal)
116117
* [Dan Loewenherz](http://dlo.me)
118+
* [Michiya Takahashi](https://github.com/michiya)
117119
* [Filip Wasilewski](http://code.djangoproject.com/ticket/5246)
118120
* [Ramiro Morales](http://djangopeople.net/ramiro/)
119121
* [Wei guangjing](http://djangopeople.net/vcc/)

django_pyodbc/base.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
_DJANGO_VERSION = 13
3434
elif DjangoVersion[:2] == (1,2):
3535
_DJANGO_VERSION = 12
36-
elif DjangoVersion[:2] == (1,1):
37-
_DJANGO_VERSION = 11
38-
elif DjangoVersion[:2] == (1,0):
39-
_DJANGO_VERSION = 10
4036
else:
41-
_DJANGO_VERSION = 9
37+
raise ImproperlyConfigured("Django %d.%d is not supported." % DjangoVersion[:2])
4238

4339
from django_pyodbc.operations import DatabaseOperations
4440
from django_pyodbc.client import DatabaseClient
@@ -49,6 +45,7 @@
4945

5046
logger = logging.getLogger(__name__)
5147

48+
collation = 'Latin1_General_CI_AS'
5249
try:
5350
if hasattr(settings, 'DATABASE_COLLATION'):
5451
warnings.warn(
@@ -59,7 +56,7 @@
5956
elif 'collation' in settings.DATABASE_OPTIONS:
6057
collation = settings.DATABASE_OPTIONS['collation']
6158
except AttributeError:
62-
collation = 'Latin1_General_CI_AS'
59+
pass
6360

6461
deprecated = (
6562
('DATABASE_ODBC_DRIVER', 'driver'),
@@ -77,7 +74,6 @@
7774
IntegrityError = Database.IntegrityError
7875

7976
class DatabaseFeatures(BaseDatabaseFeatures):
80-
uses_custom_query_class = True
8177
can_use_chunked_reads = False
8278
can_return_id_from_insert = True
8379
#uses_savepoints = True
@@ -141,10 +137,7 @@ def __init__(self, *args, **kwargs):
141137
self.client = DatabaseClient(self)
142138
self.creation = DatabaseCreation(self)
143139
self.introspection = DatabaseIntrospection(self)
144-
if _DJANGO_VERSION >= 12:
145-
self.validation = BaseDatabaseValidation(self)
146-
else:
147-
self.validation = BaseDatabaseValidation()
140+
self.validation = BaseDatabaseValidation(self)
148141

149142
self.connection = None
150143

django_pyodbc/operations.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
from django.db.backends import BaseDatabaseOperations
2-
from django_pyodbc import query
32
import datetime
43
import time
54
import decimal
65

76
class DatabaseOperations(BaseDatabaseOperations):
87
compiler_module = "django_pyodbc.compiler"
98
def __init__(self, connection):
10-
super(DatabaseOperations, self).__init__(connection)
9+
if connection._DJANGO_VERSION >= 14:
10+
super(DatabaseOperations, self).__init__(connection)
11+
else:
12+
super(DatabaseOperations, self).__init__()
13+
1114
self.connection = connection
1215
self._ss_ver = None
1316

@@ -111,15 +114,6 @@ def lookup_cast(self, lookup_type):
111114
return "UPPER(%s)"
112115
return "%s"
113116

114-
def query_class(self, DefaultQueryClass):
115-
"""
116-
Given the default Query class, returns a custom Query class
117-
to use for this backend. Returns None if a custom Query isn't used.
118-
See also BaseDatabaseFeatures.uses_custom_query_class, which regulates
119-
whether this method is called at all.
120-
"""
121-
return query.query_class(DefaultQueryClass)
122-
123117
def quote_name(self, name):
124118
"""
125119
Returns a quoted version of the given table, index or column name. Does

0 commit comments

Comments
 (0)