Opened 4 years ago

Closed 4 years ago

#52 closed defect (fixed)

Proper Python types for date/time/timestamp/interval values

Reported by: cito Owned by: cito
Priority: major Milestone: 5.0
Component: DB API 2 Version: 4.1
Keywords: date, time, typecast Cc:


Currently, Pygres can accept and return date/time/timestamp/interval values only as strings.

Using Python date/time/datetime/timedelta objects, as implemented in psycopg2, might be a much better solution.

This could be made configurable with a switch that would be set to off by default in 5.x, and then in 6.x the switch could be flipped.

Change History (2)

comment:1 Changed 4 years ago by cito

Keywords: date time typecast added
Milestone: 5.15.0
Owner: set to cito
Status: newassigned

I have decided to implement this already in 5.0 because it's a big change that should be done in a major version.

The typecasting was implemented in r814, using the current datestyle setting. You can easily restore the old behavior with set_typecast('date', None) if you need backward compatibility.

In r816 I added tests verifying that adaptation works as well, no matter how DateStyle? and IntervalStyle? are set. Postgres is able to make sense of the str() output of all the datetime objects without needing any adaptation.

Last edited 4 years ago by cito (previous) (diff)

comment:2 Changed 4 years ago by cito

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.