changeset 65c68ff9d858 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=65c68ff9d858
description:
        Use alias expression in where clause of implicit join

        issue11486
diffstat:

 trytond/model/fields/many2one.py |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diffs (20 lines):

diff -r c68efc32f275 -r 65c68ff9d858 trytond/model/fields/many2one.py
--- a/trytond/model/fields/many2one.py  Mon Jul 18 00:25:45 2022 +0200
+++ b/trytond/model/fields/many2one.py  Mon Jul 18 10:02:12 2022 +0200
@@ -1,6 +1,6 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
-from sql import Column, Expression, Literal, Query, With
+from sql import As, Column, Expression, Literal, Query, With
 from sql.aggregate import Max
 from sql.conditionals import Coalesce
 from sql.operators import Or
@@ -242,6 +242,8 @@
             if operator.endswith('where'):
                 query = Target.search(value, order=[], query=True)
                 target_id, = query.columns
+                if isinstance(target_id, As):
+                    target_id = target_id.expression
                 query.where &= target_id == column
                 expression = column.in_(query)
                 if operator.startswith('not'):

Reply via email to