Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"backends.tests.ThreadTests.test_pass_connection_between_threads",
"backends.tests.ThreadTests.test_closing_non_shared_connections",
"backends.tests.ThreadTests.test_default_connection_thread_local",
# AddField
"schema.tests.SchemaTests.test_add_datefield_and_datetimefield_use_effective_default",
"schema.tests.SchemaTests.test_add_field",
"schema.tests.SchemaTests.test_add_field_binary",
"schema.tests.SchemaTests.test_add_field_both_defaults_preserves_db_default",
"schema.tests.SchemaTests.test_add_field_default_dropped",
"schema.tests.SchemaTests.test_add_field_default_nullable",
"schema.tests.SchemaTests.test_add_field_default_transform",
"schema.tests.SchemaTests.test_add_field_durationfield_with_default",
"schema.tests.SchemaTests.test_add_field_o2o_nullable",
"schema.tests.SchemaTests.test_add_field_temp_default",
"schema.tests.SchemaTests.test_add_field_temp_default_boolean",
"schema.tests.SchemaTests.test_add_field_use_effective_default",
"schema.tests.SchemaTests.test_add_text_field_with_db_default",
"schema.tests.SchemaTests.test_add_textfield_default_nullable",
# RemoveField
"schema.tests.SchemaTests.test_remove_field",
"schema.tests.SchemaTests.test_remove_indexed_field",
# Add/RemoveIndex
"schema.tests.SchemaTests.test_add_remove_index",
"schema.tests.SchemaTests.test_composed_desc_index_with_fk",
Expand Down Expand Up @@ -145,12 +127,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"schema.tests.SchemaTests.test_remove_unique_together_does_not_remove_meta_constraints",
"schema.tests.SchemaTests.test_unique_together",
# ManyToManyField
"schema.tests.SchemaTests.test_m2m",
"schema.tests.SchemaTests.test_m2m_create",
"schema.tests.SchemaTests.test_m2m_create_custom",
"schema.tests.SchemaTests.test_m2m_create_inherited",
"schema.tests.SchemaTests.test_m2m_custom",
"schema.tests.SchemaTests.test_m2m_inherited",
"schema.tests.SchemaTests.test_m2m_rename_field_in_target_model",
"schema.tests.SchemaTests.test_m2m_repoint",
"schema.tests.SchemaTests.test_m2m_repoint_custom",
Expand Down
18 changes: 16 additions & 2 deletions django_mongodb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ def delete_model(self, model):
self.connection.database[model._meta.db_table].drop()

def add_field(self, model, field):
pass
# Create implicit M2M tables.
if field.many_to_many and field.remote_field.through._meta.auto_created:
self.create_model(field.remote_field.through)
return
# Set default value on existing documents.
if column := field.column:
self.connection.database[model._meta.db_table].update_many(
{}, [{"$set": {column: self.effective_default(field)}}]
)

def alter_field(self, model, old_field, new_field, strict=False):
pass

def remove_field(self, model, field):
pass
# Remove implicit M2M tables.
if field.many_to_many and field.remote_field.through._meta.auto_created:
self.delete_model(field.remote_field.through)
return
# Unset field on existing documents.
if column := field.column:
self.connection.database[model._meta.db_table].update_many({}, {"$unset": {column: ""}})

def alter_index_together(self, model, old_index_together, new_index_together):
pass
Expand Down