mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-06-05 05:33:06 +03:00
The UUID adapter returns bytes instead of str in Python 3
Also added __conform__ method to the adapter.
This commit is contained in:
parent
cdbcd8a2e5
commit
6ab195d957
|
@ -450,13 +450,15 @@ class UUID_adapter(object):
|
||||||
def __init__(self, uuid):
|
def __init__(self, uuid):
|
||||||
self._uuid = uuid
|
self._uuid = uuid
|
||||||
|
|
||||||
def prepare(self, conn):
|
def __conform__(self, proto):
|
||||||
pass
|
if proto is _ext.ISQLQuote:
|
||||||
|
return self
|
||||||
|
|
||||||
def getquoted(self):
|
def getquoted(self):
|
||||||
return "'"+str(self._uuid)+"'::uuid"
|
return b("'%s'::uuid" % self._uuid)
|
||||||
|
|
||||||
__str__ = getquoted
|
def __str__(self):
|
||||||
|
return "'%s'::uuid" % self._uuid
|
||||||
|
|
||||||
def register_uuid(oids=None, conn_or_curs=None):
|
def register_uuid(oids=None, conn_or_curs=None):
|
||||||
"""Create the UUID type and an uuid.UUID adapter.
|
"""Create the UUID type and an uuid.UUID adapter.
|
||||||
|
@ -515,8 +517,8 @@ class Inet(object):
|
||||||
obj.prepare(self._conn)
|
obj.prepare(self._conn)
|
||||||
return obj.getquoted() + b("::inet")
|
return obj.getquoted() + b("::inet")
|
||||||
|
|
||||||
def __conform__(self, foo):
|
def __conform__(self, proto):
|
||||||
if foo is _ext.ISQLQuote:
|
if proto is _ext.ISQLQuote:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user