[PyGreSQL] datetime.date and float and nan
Maxim Yegorushkin
maxim.yegorushkin at gmail.com
Sat Jul 16 09:29:13 EDT 2011
On 15 July 2011 17:26, D'Arcy J.M. Cain <darcy at pygresql.org> wrote:
> On Fri, 15 Jul 2011 17:02:43 +0100
> Maxim Yegorushkin <maxim.yegorushkin at gmail.com> wrote:
> > However, it misses support for datetime.date objects and can't correctly
> > quote floats with nan value. So, I thought you may like to consider
> adding
> > the following to pgdb.py:
>
> Looks reasonable. Can you work up the unit tests as well? See the
> script TEST_PyGreSQL_dbapi20.py. I did check and your changes don't
> break the existing tests but we always like to add new tests along with
> new code.
Oh, I am a fan of unit tests myself. The original patch was made in anger,
here is a more thoughtful one.
This patch extends float handling by supporting nan and inf values along
with a new unit test. It basically always quotes floats to avoid isinf() and
isnan() checks for each and every float value.
With regards to date support, I am thinking of handling date and datetime
similar to decimal, that is, to convert strings to date and datetime when
reading rowsets, so that user code does not have to convert strings to
dates. Does it make sense?
-- Maxim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.vex.net/pipermail/pygresql/attachments/20110716/9dbecfaa/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: float.diff
Type: text/x-patch
Size: 2649 bytes
Desc: not available
URL: <http://mailman.vex.net/pipermail/pygresql/attachments/20110716/9dbecfaa/attachment.bin>
More information about the PyGreSQL
mailing list