Skip to content

Commit

Permalink
fix crash of DecimalField lookup with F expression
Browse files Browse the repository at this point in the history
  • Loading branch information
WaVEV authored and timgraham committed Jul 30, 2024
1 parent a36f3f4 commit 638e95c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"model_fields.test_jsonfield.TestQuerying.test_order_grouping_custom_decoder",
"model_fields.test_jsonfield.TestQuerying.test_ordering_by_transform",
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_key_transform",
# DecimalField lookup with F expression crashes:
# decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
"lookup.tests.LookupTests.test_lookup_rhs",
# Wrong results in queries with multiple tables.
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_reverse_m2m",
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_with_m2m",
Expand Down
3 changes: 3 additions & 0 deletions django_mongodb/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def process_rhs(node, compiler, connection):
value = value[0]
if hasattr(node, "prep_lookup_value_mongo"):
value = node.prep_lookup_value_mongo(value)
# No need to prepare expressions like F() objects.
if hasattr(rhs, "resolve_expression"):
return value
return connection.ops.prep_lookup_value(value, node.lhs.output_field, node.lookup_name)


Expand Down

0 comments on commit 638e95c

Please sign in to comment.