Re: [psycopg] Using infinite values with DateTimeTZRange - Mailing list psycopg

From Daniele Varrazzo
Subject Re: [psycopg] Using infinite values with DateTimeTZRange
Date
Msg-id CA+mi_8bkMQ_LRL-Q3oyX5qtZbu5LHDPi+50kbtcCnfi34-UM4g@mail.gmail.com
Whole thread Raw
In response to Re: [psycopg] Using infinite values with DateTimeTZRange  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
On Mon, Aug 21, 2017 at 1:14 PM, Daniele Varrazzo
<daniele.varrazzo@gmail.com> wrote:

[...]

>            else:
>                 return psycopg2.extensions.DateFromPy(self.wrapped).getquoted()
>
>     psycopg2.extensions.register_adapter(datetime, InfDateTimeTZAdapter)
>
> Once the dt adapter is fixed, the range adapter will use it automatically:
>
>     >>> print psycopg2.extensions.adapt(validity).getquoted()
>     tstzrange('2017-08-21T12:59:11.486205+00:00'::date,
> 'infinity'::datetimetz, '[)')

Sorry, this is obviously a bug in handling the not infinity dates :)
The else should be:

    return psycopg2.extensions.TimestampFromPy(self.wrapped).getquoted()

with which the range adapter will return an adapted value like:

    tstzrange('2017-08-21T13:23:49.222454+00:00'::timestamptz,
'infinity'::datetimetz, '[)')

-- Daniele


psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: [psycopg] Using infinite values with DateTimeTZRange
Next
From: Aryeh Leib Taurog
Date:
Subject: [psycopg] pgcopy 1.3.0 release announcement