From 47d012aadd65dc2003259da170ad79a6ac504f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 9 Oct 2024 17:19:44 +0200 Subject: [PATCH] Surround exclude expression with parenthesis Closes #13576 (grafted from e3ad47f562e5a8b03d4ff01014c83944c9dbd9ce) --HG-- branch : 7.0 --- trytond/trytond/model/modelsql.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/trytond/trytond/model/modelsql.py b/trytond/trytond/model/modelsql.py index 023212e6a6..a82cc3a534 100644 --- a/trytond/trytond/model/modelsql.py +++ b/trytond/trytond/model/modelsql.py @@ -137,7 +137,13 @@ class Exclude(Constraint): return self._where def __str__(self): - exclude = ', '.join('%s WITH %s' % (column, operator._operator) + def format_(element): + if isinstance(element, Column): + return element + else: + return '(%s)' % element + exclude = ', '.join( + '%s WITH %s' % (format_(column), operator._operator) for column, operator in self.excludes) where = '' if self.where: