Ok, found the problem - str() removes one level of backslashes so I have
to double backslashes once again. See the attached patch - it passes all
tests.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.
Index: pgconnection.py
===================================================================
--- pgconnection.py	(revision 4535)
+++ pgconnection.py	(working copy)
@@ -359,4 +359,12 @@
 # Converter for psycopg Binary type.
 def PsycoBinaryConverter(value, db):
     assert db == 'postgres'
-    return str(value)
+    value = str(value)
+    if ('\\' in value):
+        if value.startswith("'") and value[-8:].lower().endswith("'::bytea"):
+            value = value[1:-8]
+        elif value.startswith("'") and value.endswith("'"):
+            value = value[1:-1]
+        value = value.replace('\\', '\\\\')
+        return "E'%s'::bytea" % value
+    return value
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to