This project is archived and is in readonly mode.
Range types doesn't support infinity [now,infinity)
Reported by Psycopg website | May 24th, 2013 @ 07:12 AM
Submitted by: David Turon
if I get from database range for example:
and then insert back to db
["2013-05-23 14:31:52.892896+02","9999-12-31 23:59:59.999999+01") for example UPDATE updated 0 rows because
["2013-05-23 14:31:52.892896+02",infinity)!=["2013-05-23 14:31:52.892896+02","9999-12-31 23:59:59.999999+01")
Comments and changes to this ticket
Python dates don't support infinity, so the value is mapped on maxdate, and of course the mapping is not bidirectional. It's a known shortcoming of the dates mapping, it doesn't affect the ranges only.
You have two solutions:
if you don't need the values of the range in python but are using the range only as a key to fetch/store records you may create a text range leaving the ranges unparsed.
if your database stores infinity but not maxdate you can create a datetime adapter mapping python maxdate on postgres infinity and build a range on it.
Both objects are easy to implement and use. Let me know if you need a hand with them.
- State changed from new to invalid
I've added some docs to explain how to map date.max to infinity
the default adapter cannot be changed for backward compatibility reason. You can use a customized adapter in your application.
InfDateAdapter.getquotedshould return a bytestring in Python 3, but this is not obvious from the documentation, and the stack trace is kind of cryptic. I think people unfamiliar with psycopg2 adapters would benefit from writing the example with
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
WARNING: the informations in this tracker are archived. Please submit new tickets or comments to the new tracker.
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.