mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-17 01:20:32 +03:00
Support for NULLs in UUID
This commit is contained in:
parent
b92601306e
commit
56f6001d6d
|
@ -1,3 +1,8 @@
|
||||||
|
2008-09-23 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* Applied patch from Brian Sutherland that fixes NULL
|
||||||
|
valus in UUID support.
|
||||||
|
|
||||||
2008-09-19 Federico Di Gregorio <fog@initd.org>
|
2008-09-19 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* lib/extras.py: added UUID support, modeled after the code
|
* lib/extras.py: added UUID support, modeled after the code
|
||||||
|
|
|
@ -306,7 +306,7 @@ try:
|
||||||
"""Create the UUID type and an uuid.UUID adapter."""
|
"""Create the UUID type and an uuid.UUID adapter."""
|
||||||
if not oid: oid = 2950
|
if not oid: oid = 2950
|
||||||
_ext.UUID = _ext.new_type((oid, ), "UUID",
|
_ext.UUID = _ext.new_type((oid, ), "UUID",
|
||||||
lambda data, cursor: uuid.UUID(data))
|
lambda data, cursor: data and uuid.UUID(data) or None)
|
||||||
_ext.register_type(_ext.UUID)
|
_ext.register_type(_ext.UUID)
|
||||||
_ext.register_adapter(uuid.UUID, UUID_adapter)
|
_ext.register_adapter(uuid.UUID, UUID_adapter)
|
||||||
return _ext.UUID
|
return _ext.UUID
|
||||||
|
@ -321,4 +321,4 @@ except ImportError, e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
__all__ = [ k for k in locals().keys() if not k.startswith('_') ]
|
__all__ = [ k for k in locals().keys() if not k.startswith('_') ]
|
||||||
|
|
|
@ -45,6 +45,9 @@ class TypesBasicTests(unittest.TestCase):
|
||||||
u = uuid.UUID('9c6d5a77-7256-457e-9461-347b4358e350');
|
u = uuid.UUID('9c6d5a77-7256-457e-9461-347b4358e350');
|
||||||
s = self.execute("SELECT %s AS foo", (u,))
|
s = self.execute("SELECT %s AS foo", (u,))
|
||||||
self.failUnless(u == s)
|
self.failUnless(u == s)
|
||||||
|
# must survive NULL cast to a uuid
|
||||||
|
s = self.execute("SELECT NULL::uuid AS foo")
|
||||||
|
self.failUnless(s is None)
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user