From 196c840b2f658e3b743809d676a81a634f8d64cc Mon Sep 17 00:00:00 2001 From: Cris Ewing Date: Wed, 6 Mar 2013 22:21:37 -0800 Subject: [PATCH] fix mis-converted boolean field allow for boolean that is storing hexadecimal values '\x01' and '\x00' for true and false. --- mysql2pgsql/lib/postgres_writer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql2pgsql/lib/postgres_writer.py b/mysql2pgsql/lib/postgres_writer.py index b0f01ec..0aa14d3 100644 --- a/mysql2pgsql/lib/postgres_writer.py +++ b/mysql2pgsql/lib/postgres_writer.py @@ -148,7 +148,9 @@ def process_row(self, table, row): elif 'bit' in column_type: row[index] = bin(ord(row[index]))[2:] elif isinstance(row[index], (str, unicode, basestring)): - if column_type == 'bytea': + if column_type == 'boolean': + row[index] = 't' if row[index] == '\x01' else 'f' if row[index] == '\x00' else row[index] + elif column_type == 'bytea': row[index] = Binary(row[index]).getquoted()[1:-8] if row[index] else row[index] elif 'text[' in column_type: row[index] = '{%s}' % ','.join('"%s"' % v.replace('"', r'\"') for v in row[index].split(','))