Skip to content

Commit 888709e

Browse files
David GrochowskiThePumpingLemma
authored andcommitted
Remove support for MongoDB
1 parent a804b51 commit 888709e

File tree

3 files changed

+2
-54
lines changed

3 files changed

+2
-54
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changes
44
Unreleased
55
------------------
66
- Add pre and post create_historical_record signals (gh-426)
7+
- Remove support for `django_mongodb_engine` when converting AutoFields
78

89
2.3.0 (2018-07-19)
910
------------------

simple_history/models.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def transform_field(field):
389389
"""Customize field appropriately for use in historical model"""
390390
field.name = field.attname
391391
if isinstance(field, models.AutoField):
392-
field.__class__ = convert_auto_field(field)
392+
field.__class__ = models.IntegerField
393393

394394
elif isinstance(field, models.FileField):
395395
# Don't copy file, just path.
@@ -408,20 +408,6 @@ def transform_field(field):
408408
field.serialize = True
409409

410410

411-
def convert_auto_field(field):
412-
"""Convert AutoField to a non-incrementing type
413-
414-
The historical model gets its own AutoField, so any existing one
415-
must be replaced with an IntegerField.
416-
"""
417-
connection = router.db_for_write(field.model)
418-
if settings.DATABASES[connection].get('ENGINE') in \
419-
('django_mongodb_engine',):
420-
# Check if AutoField is string for django-non-rel support
421-
return models.TextField
422-
return models.IntegerField
423-
424-
425411
class HistoricalObjectDescriptor(object):
426412
def __init__(self, model, fields_included):
427413
self.model = model

simple_history/tests/tests/test_models.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from simple_history.models import (
1616
HistoricalRecords,
17-
convert_auto_field,
1817
ModelChange
1918
)
2019
from simple_history.utils import update_change_reason
@@ -778,44 +777,6 @@ def test_state_serialization_of_customfk(self):
778777
state.ModelState.from_model(HistoricalCustomFKError)
779778

780779

781-
class TestConvertAutoField(TestCase):
782-
"""Check what AutoFields get converted to."""
783-
784-
def setUp(self):
785-
for field in Poll._meta.fields:
786-
if isinstance(field, models.AutoField):
787-
self.field = field
788-
break
789-
790-
def test_relational(self):
791-
"""Relational test
792-
793-
Default Django ORM uses an integer-based auto field.
794-
"""
795-
with warnings.catch_warnings():
796-
warnings.filterwarnings('ignore', category=UserWarning,
797-
message='Overriding setting DATABASES ' +
798-
'can lead to unexpected behavior.')
799-
with self.settings(DATABASES={'default': {
800-
'ENGINE': 'django.db.backends.postgresql_psycopg2'}}):
801-
assert convert_auto_field(self.field) == models.IntegerField
802-
803-
def test_non_relational(self):
804-
"""Non-relational test
805-
806-
MongoDB uses a string-based auto field. We need to make sure
807-
the converted field type is string.
808-
"""
809-
810-
with warnings.catch_warnings():
811-
warnings.filterwarnings('ignore', category=UserWarning,
812-
message='Overriding setting DATABASES ' +
813-
'can lead to unexpected behavior.')
814-
with self.settings(DATABASES={'default': {
815-
'ENGINE': 'django_mongodb_engine'}}):
816-
assert convert_auto_field(self.field) == models.TextField
817-
818-
819780
class TestOrderWrtField(TestCase):
820781
"""Check behaviour of _order field added by Meta.order_with_respect_to.
821782

0 commit comments

Comments
 (0)