File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1616^^^^^
1717- Add `create() ` method to reverse ForeignKey relations, enabling `parent.children.create() ` syntax
1818
19+ Fixed
20+ ^^^^^
21+ - Fix sqlite decimal filter error with `__gt ` (#2020)
22+
19230.25
2024====
2125
Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ async def test_filter(self):
6262 .first ()
6363 )
6464 self .assertEqual (obj , obj0 )
65+ objs = await testmodels .DecimalFields .filter (decimal_nodec__gt = 2 ).all ()
66+ self .assertIn (obj , objs )
67+ objs = await testmodels .DecimalFields .filter (decimal_nodec__lt = 100 ).all ()
68+ self .assertIn (obj , objs )
6569
6670 async def test_f_expression_update (self ):
6771 obj0 = await testmodels .DecimalFields .create (decimal = Decimal ("1.23456" ), decimal_nodec = 18.7 )
Original file line number Diff line number Diff line change @@ -387,6 +387,7 @@ def _process_filter_kwarg(
387387 else :
388388 filter_info = model ._meta .get_filter (key )
389389
390+ field_object = None
390391 if "table" in filter_info :
391392 # join the table
392393 join = (
@@ -405,7 +406,14 @@ def _process_filter_kwarg(
405406 else field_object .to_db_value (value , model )
406407 )
407408 op = filter_info ["operator" ]
408- criterion = op (table [filter_info .get ("source_field" , filter_info ["field" ])], value )
409+ term : Term = table [filter_info .get ("source_field" , filter_info ["field" ])]
410+ if field_object is not None :
411+ func = field_object .get_for_dialect (
412+ model ._meta .db .capabilities .dialect , "function_cast"
413+ )
414+ if func is not None :
415+ term = func (field_object , term )
416+ criterion = op (term , value )
409417 return criterion , join
410418
411419 def _resolve_regular_kwarg (
You can’t perform that action at this time.
0 commit comments