Skip to content

Commit b535444

Browse files
committed
add support for ListField and EmbeddedModelField
1 parent d3a106c commit b535444

File tree

5 files changed

+376
-8
lines changed

5 files changed

+376
-8
lines changed

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/checkout@v4
3232
with:
3333
repository: 'mongodb-forks/django'
34-
ref: 'mongodb-5.0.x'
34+
ref: 'embedded-model-field'
3535
path: 'django_repo'
3636
- name: Install system packages for Django's Python test dependencies
3737
run: |

django_mongodb/compiler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,12 @@ def execute_sql(self, result_type):
696696
elif hasattr(value, "prepare_database_save"):
697697
if field.remote_field:
698698
value = value.prepare_database_save(field)
699-
else:
700-
raise TypeError(
701-
f"Tried to update field {field} with a model "
702-
f"instance, {value!r}. Use a value compatible with "
703-
f"{field.__class__.__name__}."
704-
)
699+
# else:
700+
# raise TypeError(
701+
# f"Tried to update field {field} with a model "
702+
# f"instance, {value!r}. Use a value compatible with "
703+
# f"{field.__class__.__name__}."
704+
# )
705705
prepared = field.get_db_prep_save(value, connection=self.connection)
706706
if hasattr(value, "as_mql"):
707707
prepared = prepared.as_mql(self, self.connection)

django_mongodb/features.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ class DatabaseFeatures(BaseDatabaseFeatures):
4040
uses_savepoints = False
4141

4242
_django_test_expected_failures = {
43+
# Unsupported conversion from array to string in $convert with no onError value
44+
"mongo_fields.test_listfield.IterableFieldsTests.test_options",
45+
"mongo_fields.test_listfield.IterableFieldsTests.test_startswith",
46+
# No results:
47+
"mongo_fields.test_listfield.IterableFieldsTests.test_chained_filter",
48+
"mongo_fields.test_listfield.IterableFieldsTests.test_exclude",
49+
"mongo_fields.test_listfield.IterableFieldsTests.test_gt",
50+
"mongo_fields.test_listfield.IterableFieldsTests.test_gte",
51+
"mongo_fields.test_listfield.IterableFieldsTests.test_lt",
52+
"mongo_fields.test_listfield.IterableFieldsTests.test_lte",
53+
"mongo_fields.test_listfield.IterableFieldsTests.test_Q_objects",
4354
# 'NulledTransform' object has no attribute 'as_mql'.
4455
"lookup.tests.LookupTests.test_exact_none_transform",
4556
# "Save with update_fields did not affect any rows."

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)