Skip to content

Commit a6479ba

Browse files
committed
add support for ListField and EmbeddedModelField
1 parent 5c29684 commit a6479ba

File tree

5 files changed

+378
-8
lines changed

5 files changed

+378
-8
lines changed

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
uses: actions/checkout@v4
4545
with:
4646
repository: 'mongodb-forks/django'
47-
ref: 'mongodb-5.0.x'
47+
ref: 'embedded-model-field'
4848
path: 'django_repo'
4949
- name: Install system packages for Django's Python test dependencies
5050
run: |

django_mongodb/compiler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,12 @@ def execute_sql(self, result_type):
687687
elif hasattr(value, "prepare_database_save"):
688688
if field.remote_field:
689689
value = value.prepare_database_save(field)
690-
else:
691-
raise TypeError(
692-
f"Tried to update field {field} with a model "
693-
f"instance, {value!r}. Use a value compatible with "
694-
f"{field.__class__.__name__}."
695-
)
690+
# else:
691+
# raise TypeError(
692+
# f"Tried to update field {field} with a model "
693+
# f"instance, {value!r}. Use a value compatible with "
694+
# f"{field.__class__.__name__}."
695+
# )
696696
prepared = field.get_db_prep_save(value, connection=self.connection)
697697
if hasattr(value, "as_mql"):
698698
prepared = prepared.as_mql(self, self.connection)

django_mongodb/features.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ class DatabaseFeatures(BaseDatabaseFeatures):
117117
# subclasses of BaseDatabaseIntrospection may require a get_constraints() method
118118
"migrations.test_operations.OperationTests.test_add_func_unique_constraint",
119119
"migrations.test_operations.OperationTests.test_remove_func_unique_constraint",
120+
# Unsupported conversion from array to string in $convert with no onError value
121+
"mongo_fields.test_listfield.IterableFieldsTests.test_options",
122+
"mongo_fields.test_listfield.IterableFieldsTests.test_startswith",
123+
# No results:
124+
"mongo_fields.test_listfield.IterableFieldsTests.test_chained_filter",
125+
"mongo_fields.test_listfield.IterableFieldsTests.test_equals",
126+
"mongo_fields.test_listfield.IterableFieldsTests.test_exclude",
127+
"mongo_fields.test_listfield.IterableFieldsTests.test_gt",
128+
"mongo_fields.test_listfield.IterableFieldsTests.test_gte",
129+
"mongo_fields.test_listfield.IterableFieldsTests.test_list_with_foreignkeys",
130+
"mongo_fields.test_listfield.IterableFieldsTests.test_lt",
131+
"mongo_fields.test_listfield.IterableFieldsTests.test_lte",
132+
"mongo_fields.test_listfield.IterableFieldsTests.test_Q_objects",
120133
}
121134
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
122135
_django_test_expected_failures_bitwise = {

django_mongodb/fields/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from .auto import ObjectIdAutoField
22
from .duration import register_duration_field
3+
from .embedded_model import EmbeddedModelField, ListField
34
from .json import register_json_field
45

5-
__all__ = ["register_fields", "ObjectIdAutoField"]
6+
__all__ = ["register_fields", "EmbeddedModelField", "ListField", "ObjectIdAutoField"]
67

78

89
def register_fields():

0 commit comments

Comments
 (0)