Development #77911
gérer les nombres décimaux dans les filtres de requêtes
Status:
Nouveau
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
25 May 2023
Due date:
% Done:
0%
Estimated time:
Patch proposed:
No
Planning:
No
Description
On gère le cas des entiers,
... value_is_int = isinstance(self.value, int) or value_is_list_of_int ... if self.field.key in ['item', 'string'] and value_is_int: # integer cast of db values attribute = "(CASE WHEN %s~E'^\\\\d{1,9}$' THEN (%s)::int ELSE NULL END)" % (
+ dans wcs/variables.py,
def format_value(self, op, value, field): def check_int(val): try: # cast to integer so it can be used with numerical operators # (limit to 32bits to match postgresql integer range) int_value = int(val) if -(2**31) <= int_value < 2**31 and (int_value == 0 or str(value)[0] != '0'): return int_value except (ValueError, TypeError): return str(val) return val
mais si on reçoit decimal ou float en entrée, 1/ on ne détectera pas qu'il s'agit de nombres, 2/ on ne fera pas le cast approprié dans la db.
Related issues
History
Updated by Frédéric Péters 15 days ago
- Related to Autre #77908: Le filtre greater_than_or_equal ne fonctionne pas toujours OU problème sur multiply added