Shouldn't it? Here is a test that I think should pass but currently
does not.
Index: tests/test_classic_dbwrapper.py
===================================================================
--- tests/test_classic_dbwrapper.py (revision 661)
+++ tests/test_classic_dbwrapper.py (working copy)
@@ -1069,6 +1069,7 @@
query("drop table test_table")
def testBytea(self):
+ insert = self.db.insert
query = self.db.query
query('drop table if exists bytea_test')
query('create table bytea_test ('
@@ -1084,6 +1085,12 @@
r = self.db.unescape_bytea(r)
self.assertIsInstance(r, bytes)
self.assertEqual(r, s)
+ s = b"It's all \\ kinds \x00 of\r nasty \xff stuff!\n"
+ insert('bytea_test', dict(data=s))
+ r = query('select * from bytea_test').getresult()[0][0]
+ r = self.db.unescape_bytea(r)
+ self.assertIsInstance(r, bytes)
+ self.assertEqual(r, s)
query('drop table bytea_test')
def testDebugWithCallable(self):
Here is the change that makes it work.
Index: pg.py
===================================================================
--- pg.py (revision 661)
+++ pg.py (working copy)
@@ -346,6 +346,9 @@
d = str(d)
return "'%s'" % self.escape_string(d)
+ def _quote_bytea(self, b):
+ return self.escape_bytea(b)
+
_bool_true = frozenset('t true 1 y yes on'.split())
def _quote_bool(self, d):
@@ -386,7 +389,7 @@
_quote_funcs = dict( # quote methods for each type
text=_quote_text, bool=_quote_bool, date=_quote_date,
int=_quote_num, num=_quote_num, float=_quote_num,
- money=_quote_money)
+ money=_quote_money, bytea=_quote_bytea)
def _quote(self, d, t):
"""Return quotes if needed."""
The test is incomplete as it should also test update but I believe that
either does the same.
It should also handle the get method so that we don't need the unescape.
Comments?
--
D'Arcy J.M. Cain
PyGreSQL Development Group
http://www.PyGreSQL.org IM:[email protected]
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql