﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34434	psycopg 3 cursor.execute no longer accepts Python tuple binding	David Burke	nobody	"This may be a bug or a missing feature of psycopg 3. If expected, it may be worth mentioning as a breaking change when using psycopg3.

The following Django code works with psycopg2. Notice the usage of a tuple with the ""in"" statement.

cursor.execute(""select 1 where 1 in %s"", ((1,),)

But in psycopg 3 it gives an error 

django.db.utils.ProgrammingError: syntax error at or near ""'{1}'""
LINE 1: select 1 where 1 in '{1}'::int2[]

A fix is to use ANY with a list. It must specifically be a list and not a tuple.

cursor.execute(""select 1 where 1 = ANY(%s)"", ([1],))

With a tuple, we get the error

django.db.utils.ProgrammingError: syntax error at or near ""'(1)'""
LINE 1: select 1 where 1 in '(1)'

I would expect execute to treat a Python list and tuple the same when binding to a postgresql parameter. But this is not so."	Bug	closed	Database layer (models, ORM)	4.2	Normal	invalid		Florian Apolloner Simon Charette	Unreviewed	0	0	0	0	0	0
