mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 02:13:44 +03:00
parent
66f85b5832
commit
6192a4fb17
9
NEWS
9
NEWS
|
@ -1,6 +1,15 @@
|
|||
Current release
|
||||
---------------
|
||||
|
||||
What's new in psycopg 2.6
|
||||
-------------------------
|
||||
|
||||
Bug fixes:
|
||||
|
||||
- Json apapter's `!str()` returns the adapted content instead of the `!repr()`
|
||||
(:ticket:`#191`).
|
||||
|
||||
|
||||
What's new in psycopg 2.5.3
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -92,6 +92,14 @@ class Json(object):
|
|||
s = self.dumps(self.adapted)
|
||||
return QuotedString(s).getquoted()
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def __str__(self):
|
||||
return self.getquoted()
|
||||
else:
|
||||
def __str__(self):
|
||||
# getquoted is binary in Py3
|
||||
return self.getquoted().decode('ascii', errors='replace')
|
||||
|
||||
|
||||
def register_json(conn_or_curs=None, globally=False, loads=None,
|
||||
oid=None, array_oid=None):
|
||||
|
|
|
@ -1055,6 +1055,17 @@ class JsonTestCase(ConnectingTestCase):
|
|||
self.assertEqual(data['a'], 100)
|
||||
self.assertEqual(data['b'], None)
|
||||
|
||||
@skip_if_no_json_module
|
||||
def test_str(self):
|
||||
snowman = u"\u2603"
|
||||
obj = {'a': [1, 2, snowman]}
|
||||
j = psycopg2.extensions.adapt(psycopg2.extras.Json(obj))
|
||||
s = str(j)
|
||||
self.assert_(isinstance(s, str))
|
||||
# no pesky b's
|
||||
self.assert_(s.startswith("'"))
|
||||
self.assert_(s.endswith("'"))
|
||||
|
||||
|
||||
class RangeTestCase(unittest.TestCase):
|
||||
def test_noparam(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user