Skip to content

Commit afaf3aa

Browse files
committed
fix ManyToManyField repointing
1 parent a1414d7 commit afaf3aa

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

django_mongodb/features.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
127127
"schema.tests.SchemaTests.test_unique_together",
128128
# ManyToManyField
129129
"schema.tests.SchemaTests.test_m2m_rename_field_in_target_model",
130-
"schema.tests.SchemaTests.test_m2m_repoint",
131-
"schema.tests.SchemaTests.test_m2m_repoint_custom",
132-
"schema.tests.SchemaTests.test_m2m_repoint_inherited",
133-
"schema.tests.SchemaTests.test_m2m_through_remove",
134130
# add/remove_constraint
135131
"schema.tests.SchemaTests.test_composed_constraint_with_fk",
136132
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",

django_mongodb/fields/auto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from bson import ObjectId, errors
22
from django.core import exceptions
3-
from django.db.models.fields import AutoField, Field
3+
from django.db.models.fields import AutoField
44
from django.utils.functional import cached_property
55
from django.utils.translation import gettext_lazy as _
66

@@ -31,8 +31,8 @@ def get_prep_value(self, value):
3131
return int(value)
3232
raise ValueError(f"Field '{self.name}' expected an ObjectId but got {value!r}.") from e
3333

34-
def rel_db_type(self, connection):
35-
return Field().db_type(connection=connection)
34+
def db_type(self, connection):
35+
return "ObjectId"
3636

3737
def to_python(self, value):
3838
if value is None or isinstance(value, int):

django_mongodb/schema.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ def add_field(self, model, field):
2727
{}, [{"$set": {column: self.effective_default(field)}}]
2828
)
2929

30-
def alter_field(self, model, old_field, new_field, strict=False):
30+
def _alter_field(
31+
self,
32+
model,
33+
old_field,
34+
new_field,
35+
old_type,
36+
new_type,
37+
old_db_params,
38+
new_db_params,
39+
strict=False,
40+
):
3141
pass
3242

3343
def remove_field(self, model, field):

0 commit comments

Comments
 (0)