Skip to content

Commit 74086a5

Browse files
committed
fix model_fields.test_jsonfield.TestSaveLoad.test_bulk_update_custom_get_prep_value
django/django@9525135
1 parent 7931488 commit 74086a5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

django_mongodb_backend/expressions.py

+6
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ def when(self, compiler, connection):
186186

187187
def value(self, compiler, connection): # noqa: ARG001
188188
value = self.value
189+
output_field = self._output_field_or_none
190+
if output_field is not None:
191+
if self.for_save:
192+
value = output_field.get_db_prep_save(value, connection=connection)
193+
else:
194+
value = output_field.get_db_prep_value(value, connection=connection)
189195
if isinstance(value, int):
190196
# Wrap numbers in $literal to prevent ambiguity when Value appears in
191197
# $project.

django_mongodb_backend/features.py

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class DatabaseFeatures(BaseDatabaseFeatures):
9898
"prefetch_related.tests.NestedPrefetchTests.test_nested_prefetch_is_not_overwritten_by_related_object",
9999
"prefetch_related.tests.NullableTest.test_prefetch_nullable",
100100
"prefetch_related.tests.Ticket19607Tests.test_bug",
101+
# {'$project': {'name': Decimal128('1')} is broken? (gives None)
102+
"expressions.tests.ValueTests.test_output_field_decimalfield",
101103
}
102104
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
103105
_django_test_expected_failures_bitwise = {

0 commit comments

Comments
 (0)