This appears to be due to a bug in psycopg 3.2. By using psycopg 3.1, things work as expected. There is a GitHub issue for the bug here: https://github.com/psycopg/psycopg/issues/888