Skip to content

Commit 8d87249

Browse files
committed
fix ManyToManyField repointing
1 parent bbec58c commit 8d87249

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

django_mongodb/features.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
122122
# alter_unique_together
123123
"schema.tests.SchemaTests.test_remove_unique_together_does_not_remove_meta_constraints",
124124
"schema.tests.SchemaTests.test_unique_together",
125-
# ManyToManyField
126-
"schema.tests.SchemaTests.test_m2m_repoint",
127-
"schema.tests.SchemaTests.test_m2m_repoint_custom",
128-
"schema.tests.SchemaTests.test_m2m_repoint_inherited",
129-
"schema.tests.SchemaTests.test_m2m_through_remove",
130125
# add/remove_constraint
131126
"schema.tests.SchemaTests.test_composed_constraint_with_fk",
132127
"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)