Skip to content

Commit 638e95c

Browse files
WaVEVtimgraham
authored andcommitted
fix crash of DecimalField lookup with F expression
1 parent a36f3f4 commit 638e95c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

django_mongodb/features.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
7070
"model_fields.test_jsonfield.TestQuerying.test_order_grouping_custom_decoder",
7171
"model_fields.test_jsonfield.TestQuerying.test_ordering_by_transform",
7272
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_key_transform",
73-
# DecimalField lookup with F expression crashes:
74-
# decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
75-
"lookup.tests.LookupTests.test_lookup_rhs",
7673
# Wrong results in queries with multiple tables.
7774
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_reverse_m2m",
7875
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_with_m2m",

django_mongodb/query_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def process_rhs(node, compiler, connection):
3434
value = value[0]
3535
if hasattr(node, "prep_lookup_value_mongo"):
3636
value = node.prep_lookup_value_mongo(value)
37+
# No need to prepare expressions like F() objects.
38+
if hasattr(rhs, "resolve_expression"):
39+
return value
3740
return connection.ops.prep_lookup_value(value, node.lhs.output_field, node.lookup_name)
3841

3942

0 commit comments

Comments
 (0)