Skip to content

Commit

Permalink
import backend-related fixes from Django 1.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
michiya committed Mar 4, 2015
1 parent 9998f82 commit bd11bc8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Microsoft SQL Server and Azure SQL Database.
Features
--------

- Supports Django 1.7.4
- Supports Django 1.7.5
- Supports Microsoft SQL Server 2005, 2008/2008R2, 2012, 2014 and
Azure SQL Database
- Supports LIMIT+OFFSET and offset w/o LIMIT emulation.
Expand All @@ -28,7 +28,7 @@ Features
Dependencies
------------

- Django 1.7.4
- Django 1.7.5
- pyodbc 3.0 or newer

Installation
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
license='BSD',
packages=['sql_server', 'sql_server.pyodbc'],
install_requires=[
'Django>=1.7.4',
'Django>=1.7.5,<1.8',
'pyodbc>=3.0',
],
classifiers=CLASSIFIERS,
Expand Down
2 changes: 1 addition & 1 deletion sql_server/pyodbc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from django.utils.six import binary_type, text_type
from django.utils.timezone import utc
from django import VERSION as DjangoVersion
if DjangoVersion[:3] >= (1,7,4):
if DjangoVersion[:3] >= (1,7,5):
_DJANGO_VERSION = 17
else:
raise ImproperlyConfigured("Django %d.%d.%d is not supported." % DjangoVersion[:3])
Expand Down
7 changes: 5 additions & 2 deletions sql_server/pyodbc/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.db.backends.schema import BaseDatabaseSchemaEditor, logger
from django.db.models.fields import AutoField
from django.db.models.fields.related import ManyToManyField
from django.utils import six
from django.utils.text import force_text

Expand Down Expand Up @@ -302,7 +303,8 @@ def add_field(self, model, field):
table instead (for M2M fields)
"""
# Special-case implicit M2M tables
if field.get_internal_type() == 'ManyToManyField' and field.rel.through._meta.auto_created:
if ((isinstance(field, ManyToManyField) or field.get_internal_type() == 'ManyToManyField') and
field.rel.through._meta.auto_created):
return self.create_model(field.rel.through)
# Get the column's definition
definition, params = self.column_sql(model, field, include_default=True)
Expand Down Expand Up @@ -470,7 +472,8 @@ def remove_field(self, model, field):
but for M2Ms may involve deleting a table.
"""
# Special-case implicit M2M tables
if field.get_internal_type() == 'ManyToManyField' and field.rel.through._meta.auto_created:
if ((isinstance(field, ManyToManyField) or field.get_internal_type() == 'ManyToManyField') and
field.rel.through._meta.auto_created):
return self.delete_model(field.rel.through)
# It might not actually have a column behind it
if field.db_parameters(connection=self.connection)['type'] is None:
Expand Down

0 comments on commit bd11bc8

Please sign in to comment.