[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.
This commit is contained in:
Xavier Morel
2017-08-20 23:25:54 +02:00
committed by Olivier Dony
parent 91fe770945
commit 9d83784f1d
+2 -2
View File
@@ -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: