From 6bfef60caea11ca8ab5f02455bd0141acdee5ded Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 6 Mar 2025 11:16:21 +0100 Subject: 🐛 criteria search: fix exact date query for datetime fields (refs #6206) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/views_item.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ishtar_common/views_item.py') diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 52444fed9..a6984be8e 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -1236,6 +1236,12 @@ def _manage_date(k, dct): maxs = [value for dt, value in results if dt == "lte"] eqs = [value for dt, value in results if dt == "eq"] if eqs and not mins and not maxs: # TODO: min and max not available when using single dates + for datetime_field in BASE_DATETIME_FIELDS: + # manage exact date match on datetime field + if k.startswith(datetime_field): + dct.pop(k) + k = k + "__date" + break dct[k] = ";".join(eqs) return dct.pop(k) @@ -1429,7 +1435,6 @@ def _manage_hierarchic_area(base_req, dct, and_reqs): q = query_list[0] for query in query_list[1:]: q |= query - print(q) and_reqs.append(q) @@ -2322,7 +2327,7 @@ def manage_hierarchy_shorcut(model, request, query): DEFAULT_ROW_NUMBER = 10 # length is used by ajax DataTables requests EXCLUDED_FIELDS = ["length"] -BASE_DATED_FIELDS = ["created", "last_modified"] +BASE_DATETIME_FIELDS = ["created", "last_modified"] def get_item( @@ -2471,7 +2476,7 @@ def get_item( my_dated_fields = model.DATED_FIELDS[:] else: my_dated_fields = dated_fields[:] if dated_fields else [] - my_dated_fields += BASE_DATED_FIELDS + my_dated_fields += BASE_DATETIME_FIELDS if not associated_models and hasattr(model, "ASSOCIATED_MODELS"): my_associated_models = model.ASSOCIATED_MODELS[:] else: -- cgit v1.2.3