Skip to content

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

@apollo13

Description

@apollo13

Starting with:

338dbe70a6c78c7edddea985e2386ebd864378c6 is the first bad commit
commit 338dbe70a6c78c7edddea985e2386ebd864378c6
Author: Daniele Varrazzo <daniele.varrazzo@gmail.com>
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 = datetime.datetime.now().replace(tzinfo=pytz.utc)
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, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=120, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions