From df4e5f0cb09da01cc5be3c07c7974480724e30ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 27 Mar 2018 22:14:01 +0200 Subject: [PATCH] Replace day and month by 1 in date_trunk for SQLite The value 0 is not valid for day and month. issue7263 review45311002 --- trytond/backend/sqlite/database.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/trytond/backend/sqlite/database.py b/trytond/backend/sqlite/database.py index d689c0283a..1749cf0434 100644 --- a/trytond/backend/sqlite/database.py +++ b/trytond/backend/sqlite/database.py @@ -91,11 +91,16 @@ def date_trunc(_type, date): break else: return None - for attribute in [ - 'microsecond', 'second', 'minute', 'hour', 'day', 'month', 'year']: + for attribute, replace in [ + ('microsecond', 0), + ('second', 0), + ('minute', 0), + ('hour', 0), + ('day', 1), + ('month', 1)]: if _type.startswith(attribute): break - value = value.replace(**{attribute: 0}) + value = value.replace(**{attribute: replace}) return str(value)