Skip to content

Commit cb50893

Browse files
committed
add support for ListField and EmbeddedModelField
1 parent 30a09c5 commit cb50893

File tree

9 files changed

+837
-39
lines changed

9 files changed

+837
-39
lines changed

.github/workflows/test-python.yml

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,6 @@ jobs:
5151
- name: Run tests
5252
run: >
5353
python3 django_repo/tests/runtests.py --settings mongodb_settings -v 2
54-
aggregation
55-
aggregation_regress
56-
annotations
57-
auth_tests.test_models.UserManagerTestCase
58-
backends
59-
basic
60-
bulk_create
61-
custom_pk
62-
dates
63-
datetimes
64-
db_functions
65-
dbshell1
66-
delete
67-
delete_regress
68-
empty
69-
expressions
70-
expressions_case
71-
defer
72-
defer_regress
73-
force_insert_update
74-
from_db_value
75-
generic_relations
76-
generic_relations_regress
77-
introspection
78-
known_related_objects
7954
lookup
8055
m2m_and_m2o
8156
m2m_intermediary
@@ -93,20 +68,9 @@ jobs:
9368
model_fields
9469
model_forms
9570
model_inheritance_regress
71+
mongo_fields
9672
mutually_referential
9773
nested_foreign_keys
9874
null_fk
9975
null_fk_ordering
10076
null_queries
101-
one_to_one
102-
ordering
103-
or_lookups
104-
queries
105-
schema
106-
select_related
107-
select_related_onetoone
108-
select_related_regress
109-
sessions_tests
110-
timezones
111-
update
112-
xor_lookups

django_mongodb/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def execute_sql(self, result_type):
703703
elif hasattr(value, "prepare_database_save"):
704704
if field.remote_field:
705705
value = value.prepare_database_save(field)
706-
else:
706+
elif not hasattr(field, "embedded_model"):
707707
raise TypeError(
708708
f"Tried to update field {field} with a model "
709709
f"instance, {value!r}. Use a value compatible with "

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)