Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression] 2.7.1 -> 2.7.2 no longer converts datetime objects #578

apollo13 opened this issue Jul 23, 2017 · 3 comments

[regression] 2.7.1 -> 2.7.2 no longer converts datetime objects #578

apollo13 opened this issue Jul 23, 2017 · 3 comments


Copy link

@apollo13 apollo13 commented Jul 23, 2017

Starting with:

338dbe70a6c78c7edddea985e2386ebd864378c6 is the first bad commit
commit 338dbe70a6c78c7edddea985e2386ebd864378c6
Author: Daniele Varrazzo <>
Date:   Thu Jun 15 18:24:25 2017 +0100

    Dropped wrong associations of PG types to datetime object
    The wrong associations are overwritten in the typecaster map by the
    right ones, so they have been harmless to date, but only because of the
    order of creation of the adapters.

:040000 040000 c23e215e83527f2986e8eff25be04f494bf78403 237707ef6d9f1aa3ef4e3c718ea5a6c9d88aa748 M	psycopg

the following code:

import psycopg2, pytz, datetime

conn = psycopg2.connect('dbname=florian')

c = conn.cursor()

c.execute('CREATE TABLE IF NOT EXISTS array_test (datetimes timestamp with time zone[])')
c.execute('TRUNCATE array_test')

d =
c.execute('INSERT INTO array_test VALUES (%s)', [[d]])

c.execute('SELECT * FROM array_test')
print c.fetchall()

results in:

[('{"2017-07-23 12:40:22.139347+02"}',)]

and previously returned something along the lines of:

[([datetime.datetime(2017, 7, 23, 12, 38, 4, 777967,, name=None))],)]

This currently causes Django testsuite to fail. Is this something we have to work around, or an error in psycopg? Please tell me if you need an more details.

Copy link

@fogzot fogzot commented Jul 24, 2017

I suppose removing the array definitions broke it. We can probably just revert that commit and investigate a bit more before removing what seems to be redundant code.

Copy link

@dvarrazzo dvarrazzo commented Jul 24, 2017

Ugh, will look into it and fix it urgently, sorry about that

@dvarrazzo dvarrazzo closed this in 775de75 Jul 24, 2017
Copy link

@apollo13 apollo13 commented Jul 26, 2017

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants