Re: DateRange with mx.Date

From: Tilman Koschnick <til(at)subnetz(dot)org>
To: psycopg(at)postgresql(dot)org
Subject: Re: DateRange with mx.Date
Date: 2015-07-02 18:57:08
Message-ID: 1435863428.6358.16.camel@mother.subnetz.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hi Daniele,

thanks a lot for your explanation.

On Thu, 2015-06-25 at 15:02 +0100, Daniele Varrazzo wrote:
> On Thu, Jun 25, 2015 at 12:08 PM, Tilman Koschnick <til(at)subnetz(dot)org> wrote:
> > is there a way to adapt extras.DateRange to use extensions.MXDATE as a
> > typecaster and accept/return mx.Date values directly?

> The Range casters use whatever typecaster is registered for its base
> type so, if you register the mx.Date typecaster the range one should
> just work. Testing it seems working:

> with the noticeable exception that there is no type mx.Date it seems,
> only DateTime (sorry but I can't remember much about mx objects: I
> haven't used them for a long time):

> So it seems it should mostly work out of the box. I don't know if the
> Date/DateTime confusion can be solved but it shouldn't be hard to copy
> the adapter (from the _range.py module) and kick it until it complies
> to adapt mx.DateTime objects as they were dates.

Apparently casting from plain dates as well as dateranges to mx.DateTime
works fine, as does casting mx.DateTime back to plain dates. I'll dig a
bit deeper in the _range.py module, as you suggest.

Regards, Til

In response to

Browse psycopg by date

  From Date Subject
Next Message Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco) 2015-07-09 16:31:57 How to lock a table for update and make other connections to wait on it
Previous Message Shulgin, Oleksandr 2015-06-30 14:42:44 Re: Streaming replication for psycopg2