Added suppport for UUID and related test.

This commit is contained in:
Federico Di Gregorio 2008-09-19 21:25:16 +02:00
parent 758eaf23d1
commit b92601306e
8 changed files with 226 additions and 125 deletions

View File

@ -1,3 +1,8 @@
2008-09-19 Federico Di Gregorio <fog@initd.org>
* lib/extras.py: added UUID support, modeled after the code
sent by Brian Sutherland.
2008-09-16 Federico Di Gregorio <fog@initd.org>
* Release 2.0.8.

View File

@ -18,7 +18,7 @@
# See the LICENSE file for details.
ALLOWED_PSYCOPG_VERSIONS = ('2.0.7',)
ALLOWED_PSYCOPG_VERSIONS = ('2.0.7','2.0.8')
import sys
import time

View File

@ -24,7 +24,8 @@ try:
import logging
except:
logging = None
from psycopg2 import extensions as _ext
from psycopg2.extensions import cursor as _cursor
from psycopg2.extensions import connection as _connection
from psycopg2.extensions import adapt as _A
@ -281,3 +282,43 @@ class MinTimeLoggingCursor(LoggingCursor):
self.timestamp = time.time()
return LoggingCursor.execute(self, procname, vars)
# a dbtype and adapter for Python UUID type
try:
import uuid
class UUID_adapter(object):
"""Adapt Python's uuid.UUID type to PostgreSQL's uuid."""
def __init__(self, uuid):
self._uuid = uuid
def prepare(self, conn):
pass
def getquoted(self):
return "'"+str(self._uuid)+"'::uuid"
__str__ = getquoted
def register_uuid(oid=None):
"""Create the UUID type and an uuid.UUID adapter."""
if not oid: oid = 2950
_ext.UUID = _ext.new_type((oid, ), "UUID",
lambda data, cursor: uuid.UUID(data))
_ext.register_type(_ext.UUID)
_ext.register_adapter(uuid.UUID, UUID_adapter)
return _ext.UUID
except ImportError, e:
def register_uuid(oid=None):
"""Create the UUID type and an uuid.UUID adapter.
This is a fake function that will always raise an error because the
import of the uuid module failed.
"""
raise e
__all__ = [ k for k in locals().keys() if not k.startswith('_') ]

View File

@ -1,138 +1,139 @@
<Project name="psycopg2" fileversion="2.0" language="C" ctype="CProject">
<Project name="psycopg2" fileversion="2.0" language="C" Target="Bin" ctype="CProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="CProjectConfiguration">
<CustomCommands>
<Command type="Build" command="/usr/bin/python setup.py build" workingdir="${ProjectDir}" />
<Command type="Clean" command="/usr/bin/python setup.py clean -a" workingdir="${ProjectDir}" />
</CustomCommands>
<Output directory="./" output="psycopg2" />
<Output directory="." output="psycopg2" />
<Build debugmode="True" target="Bin" />
<Execution runwithwarnings="True" consolepause="True" />
<CodeGeneration WarningLevel="Normal" OptimizationLevel="0" ExtraCompilerArguments="" ExtraLinkerArguments="" DefineSymbols="DEBUG MONODEVELOP" ctype="CCompilationParameters" />
<CodeGeneration WarningLevel="Normal" WarningsAsErrors="False" OptimizationLevel="0" ExtraCompilerArguments="" ExtraLinkerArguments="" DefineSymbols="DEBUG MONODEVELOP" ctype="CCompilationParameters" />
</Configuration>
<Configuration name="Release" ctype="CProjectConfiguration">
<Output directory="./bin/Release" output="psycopg2" />
<Output directory="bin/Release" output="psycopg2" />
<Build debugmode="False" target="Bin" />
<Execution runwithwarnings="True" consolepause="True" />
<CodeGeneration WarningLevel="Normal" OptimizationLevel="3" ExtraCompilerArguments="" ExtraLinkerArguments="" DefineSymbols="MONODEVELOP" ctype="CCompilationParameters" />
<CodeGeneration WarningLevel="Normal" WarningsAsErrors="False" OptimizationLevel="3" ExtraCompilerArguments="" ExtraLinkerArguments="" DefineSymbols="MONODEVELOP" ctype="CCompilationParameters" />
</Configuration>
</Configurations>
<Contents>
<File name="./AUTHORS" subtype="Code" buildaction="Nothing" />
<File name="./ChangeLog" subtype="Code" buildaction="Nothing" />
<File name="./INSTALL" subtype="Code" buildaction="Nothing" />
<File name="./LICENSE" subtype="Code" buildaction="Nothing" />
<File name="./MANIFEST.in" subtype="Code" buildaction="Nothing" />
<File name="./NEWS" subtype="Code" buildaction="Nothing" />
<File name="./README" subtype="Code" buildaction="Nothing" />
<File name="./setup.cfg" subtype="Code" buildaction="Nothing" />
<File name="./setup.py" subtype="Code" buildaction="Nothing" />
<File name="./doc/async.txt" subtype="Code" buildaction="Nothing" />
<File name="./doc/extensions.rst" subtype="Code" buildaction="Nothing" />
<File name="./doc/HACKING" subtype="Code" buildaction="Nothing" />
<File name="./doc/SUCCESS" subtype="Code" buildaction="Nothing" />
<File name="./doc/TODO" subtype="Code" buildaction="Nothing" />
<File name="./examples/binary.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/copy_from.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/copy_to.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/cursor.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/dialtone.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/dict.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/dt.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/encoding.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/fetch.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/lastrowid.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/mogrify.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/myfirstrecipe.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/notify.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/simple.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/somehackers.jpg" subtype="Code" buildaction="Nothing" />
<File name="./examples/threads.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/typecast.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/tz.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/usercast.py" subtype="Code" buildaction="Nothing" />
<File name="./examples/whereareyou.jpg" subtype="Code" buildaction="Nothing" />
<File name="./lib/errorcodes.py" subtype="Code" buildaction="Nothing" />
<File name="./lib/extensions.py" subtype="Code" buildaction="Nothing" />
<File name="./lib/extras.py" subtype="Code" buildaction="Nothing" />
<File name="./lib/__init__.py" subtype="Code" buildaction="Nothing" />
<File name="./lib/pool.py" subtype="Code" buildaction="Nothing" />
<File name="./lib/psycopg1.py" subtype="Code" buildaction="Nothing" />
<File name="./lib/tz.py" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/adapter_asis.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/adapter_asis.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/adapter_binary.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/adapter_binary.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/adapter_datetime.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/adapter_datetime.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/adapter_list.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/adapter_list.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/adapter_mxdatetime.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/adapter_mxdatetime.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/adapter_pboolean.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/adapter_pboolean.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/adapter_qstring.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/adapter_qstring.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/config.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/connection.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/connection_int.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/connection_type.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/cursor.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/cursor_int.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/cursor_type.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/microprotocols.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/microprotocols.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/microprotocols_proto.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/microprotocols_proto.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/pgtypes.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/pgversion.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/pqpath.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/pqpath.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/psycopg.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/psycopgmodule.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/python.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/typecast.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/typecast.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/typecast_array.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/typecast_basic.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/typecast_binary.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/typecast_binary.h" subtype="Code" buildaction="Nothing" />
<File name="./psycopg/typecast_builtins.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/typecast_datetime.c" subtype="Code" buildaction="Compile" />
<File name="./psycopg/typecast_mxdatetime.c" subtype="Code" buildaction="Compile" />
<File name="./scripts/buildtypes.py" subtype="Code" buildaction="Nothing" />
<File name="./scripts/ext2html.py" subtype="Code" buildaction="Nothing" />
<File name="./scripts/makedocs.py" subtype="Code" buildaction="Nothing" />
<File name="./scripts/maketypes.sh" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/dtml/add.dtml" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/dtml/browse.dtml" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/dtml/edit.dtml" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/dtml/table_info.dtml" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/bin.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/date.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/datetime.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/field.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/float.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/int.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/stable.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/table.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/text.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/time.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/view.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/icons/what.gif" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/DA.py" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/db.py" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/__init__.py" subtype="Code" buildaction="Nothing" />
<File name="./ZPsycopgDA/pool.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/dbapi20.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/extras_dictcursor.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/__init__.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/test_psycopg2_dbapi20.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/test_transaction.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/types_basic.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/bugX000.py" subtype="Code" buildaction="Nothing" />
<File name="./tests/Makefile" subtype="Code" buildaction="Nothing" />
<File name="./tests/runtests.py" subtype="Code" buildaction="Nothing" />
<File name="AUTHORS" subtype="Code" buildaction="Nothing" />
<File name="ChangeLog" subtype="Code" buildaction="Nothing" />
<File name="INSTALL" subtype="Code" buildaction="Nothing" />
<File name="LICENSE" subtype="Code" buildaction="Nothing" />
<File name="MANIFEST.in" subtype="Code" buildaction="Nothing" />
<File name="NEWS" subtype="Code" buildaction="Nothing" />
<File name="README" subtype="Code" buildaction="Nothing" />
<File name="setup.cfg" subtype="Code" buildaction="Nothing" />
<File name="setup.py" subtype="Code" buildaction="Nothing" />
<File name="doc/async.txt" subtype="Code" buildaction="Nothing" />
<File name="doc/extensions.rst" subtype="Code" buildaction="Nothing" />
<File name="doc/HACKING" subtype="Code" buildaction="Nothing" />
<File name="doc/SUCCESS" subtype="Code" buildaction="Nothing" />
<File name="doc/TODO" subtype="Code" buildaction="Nothing" />
<File name="examples/binary.py" subtype="Code" buildaction="Nothing" />
<File name="examples/copy_from.py" subtype="Code" buildaction="Nothing" />
<File name="examples/copy_to.py" subtype="Code" buildaction="Nothing" />
<File name="examples/cursor.py" subtype="Code" buildaction="Nothing" />
<File name="examples/dialtone.py" subtype="Code" buildaction="Nothing" />
<File name="examples/dict.py" subtype="Code" buildaction="Nothing" />
<File name="examples/dt.py" subtype="Code" buildaction="Nothing" />
<File name="examples/encoding.py" subtype="Code" buildaction="Nothing" />
<File name="examples/fetch.py" subtype="Code" buildaction="Nothing" />
<File name="examples/lastrowid.py" subtype="Code" buildaction="Nothing" />
<File name="examples/mogrify.py" subtype="Code" buildaction="Nothing" />
<File name="examples/myfirstrecipe.py" subtype="Code" buildaction="Nothing" />
<File name="examples/notify.py" subtype="Code" buildaction="Nothing" />
<File name="examples/simple.py" subtype="Code" buildaction="Nothing" />
<File name="examples/somehackers.jpg" subtype="Code" buildaction="Nothing" />
<File name="examples/threads.py" subtype="Code" buildaction="Nothing" />
<File name="examples/typecast.py" subtype="Code" buildaction="Nothing" />
<File name="examples/tz.py" subtype="Code" buildaction="Nothing" />
<File name="examples/usercast.py" subtype="Code" buildaction="Nothing" />
<File name="examples/whereareyou.jpg" subtype="Code" buildaction="Nothing" />
<File name="lib/errorcodes.py" subtype="Code" buildaction="Nothing" />
<File name="lib/extensions.py" subtype="Code" buildaction="Nothing" />
<File name="lib/extras.py" subtype="Code" buildaction="Nothing" />
<File name="lib/__init__.py" subtype="Code" buildaction="Nothing" />
<File name="lib/pool.py" subtype="Code" buildaction="Nothing" />
<File name="lib/psycopg1.py" subtype="Code" buildaction="Nothing" />
<File name="lib/tz.py" subtype="Code" buildaction="Nothing" />
<File name="psycopg/adapter_asis.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/adapter_asis.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/adapter_binary.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/adapter_binary.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/adapter_datetime.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/adapter_datetime.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/adapter_list.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/adapter_list.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/adapter_mxdatetime.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/adapter_mxdatetime.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/adapter_pboolean.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/adapter_pboolean.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/adapter_qstring.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/adapter_qstring.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/config.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/connection.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/connection_int.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/connection_type.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/cursor.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/cursor_int.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/cursor_type.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/microprotocols.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/microprotocols.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/microprotocols_proto.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/microprotocols_proto.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/pgtypes.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/pgversion.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/pqpath.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/pqpath.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/psycopg.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/psycopgmodule.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/python.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/typecast.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/typecast.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/typecast_array.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/typecast_basic.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/typecast_binary.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/typecast_binary.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/typecast_builtins.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/typecast_datetime.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/typecast_mxdatetime.c" subtype="Code" buildaction="Compile" />
<File name="scripts/buildtypes.py" subtype="Code" buildaction="Nothing" />
<File name="scripts/ext2html.py" subtype="Code" buildaction="Nothing" />
<File name="scripts/makedocs.py" subtype="Code" buildaction="Nothing" />
<File name="scripts/maketypes.sh" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/dtml/add.dtml" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/dtml/browse.dtml" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/dtml/edit.dtml" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/dtml/table_info.dtml" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/bin.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/date.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/datetime.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/field.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/float.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/int.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/stable.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/table.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/text.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/time.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/view.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/icons/what.gif" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/DA.py" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/db.py" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/__init__.py" subtype="Code" buildaction="Nothing" />
<File name="ZPsycopgDA/pool.py" subtype="Code" buildaction="Nothing" />
<File name="tests/dbapi20.py" subtype="Code" buildaction="Nothing" />
<File name="tests/extras_dictcursor.py" subtype="Code" buildaction="Nothing" />
<File name="tests/__init__.py" subtype="Code" buildaction="Nothing" />
<File name="tests/test_psycopg2_dbapi20.py" subtype="Code" buildaction="Nothing" />
<File name="tests/test_transaction.py" subtype="Code" buildaction="Nothing" />
<File name="tests/types_basic.py" subtype="Code" buildaction="Nothing" />
<File name="tests/bugX000.py" subtype="Code" buildaction="Nothing" />
<File name="tests/Makefile" subtype="Code" buildaction="Nothing" />
<File name="tests/runtests.py" subtype="Code" buildaction="Nothing" />
<File name="tests/types_extras.py" subtype="Code" buildaction="Nothing" />
</Contents>
<compiler ctype="GccCompiler" />
<MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" />

View File

@ -1,5 +1,5 @@
[build_ext]
define=PSYCOPG_EXTENSIONS,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3
define=PSYCOPG_EXTENSIONS,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3,PSYCOPG_DEBUG
# PSYCOPG_EXTENSIONS enables extensions to PEP-249 (you really want this)
# PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower)

View File

@ -54,7 +54,7 @@ from distutils.command.build_ext import build_ext
from distutils.sysconfig import get_python_inc
from distutils.ccompiler import get_default_compiler
PSYCOPG_VERSION = '2.0.7'
PSYCOPG_VERSION = '2.0.8'
version_flags = []
PLATFORM_IS_WINDOWS = sys.platform.lower().startswith('win')

View File

@ -25,7 +25,7 @@ import tests
class TypesBasicTests(unittest.TestCase):
"""Test presence of mandatory attributes and methods."""
"""Test that all type conversions are working."""
def setUp(self):
self.conn = psycopg2.connect(tests.dsn)

54
tests/types_extras.py Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/env python
# types_extras.py - tests for extras types conversions
#
# Copyright (C) 2008 Federico Di Gregorio <fog@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
try:
import decimal
except:
pass
import sys
import unittest
import psycopg2
import psycopg2.extras
import tests
class TypesBasicTests(unittest.TestCase):
"""Test that all type conversions are working."""
def setUp(self):
self.conn = psycopg2.connect(tests.dsn)
def execute(self, *args):
curs = self.conn.cursor()
curs.execute(*args)
return curs.fetchone()[0]
def testUUID(self):
try:
import uuid
psycopg2.extras.register_uuid()
except:
return
u = uuid.UUID('9c6d5a77-7256-457e-9461-347b4358e350');
s = self.execute("SELECT %s AS foo", (u,))
self.failUnless(u == s)
def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main()