From 9d83784f1df18306b6166fd92a0573f39bf6262d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 15 May 2017 16:13:28 +0200 Subject: [PATCH] [FIX] P3: "mogrify" returns bytes, decode it Otherwise when the subquery is somehow injected in the parent query (didn't find where but...) it's b-prefixed and treated as a binary rather than a sub-query somehow, which fails. --- odoo/osv/expression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/osv/expression.py b/odoo/osv/expression.py index c1363c4f06d..761b9bef4fe 100644 --- a/odoo/osv/expression.py +++ b/odoo/osv/expression.py @@ -988,7 +988,7 @@ class expression(object): else: subquery = 'SELECT "%s" FROM "%s" WHERE "%s" IN %%s' % (rel_id1, rel_table, rel_id2) # avoid flattening of argument in to_sql() - subquery = cr.mogrify(subquery, [tuple(ids2)]) + subquery = cr.mogrify(subquery, [tuple(ids2)]).decode('utf-8') push(create_substitution_leaf(leaf, ('id', 'inselect', (subquery, [])), internal=True)) else: call_null_m2m = True @@ -1018,7 +1018,7 @@ class expression(object): subop = 'not inselect' if operator in NEGATIVE_TERM_OPERATORS else 'inselect' subquery = 'SELECT "%s" FROM "%s" WHERE "%s" IN %%s' % (rel_id1, rel_table, rel_id2) # avoid flattening of argument in to_sql() - subquery = cr.mogrify(subquery, [tuple(it for it in res_ids if it)]) + subquery = cr.mogrify(subquery, [tuple(it for it in res_ids if it)]).decode('utf-8') push(create_substitution_leaf(leaf, ('id', subop, (subquery, [])), internal=True)) if call_null_m2m: