Remove \0 from string data. Replace '0000-00-00 00:00' date/datetime to '1970-01...
authorAnton Ageev <anton@ageev.name>
Wed, 10 Dec 2008 05:30:35 +0000 (08:30 +0300)
committerAnton Ageev <anton@ageev.name>
Wed, 10 Dec 2008 05:30:35 +0000 (08:30 +0300)
mysql2psql

index 9dba587..58ceb60 100755 (executable)
@@ -446,7 +446,7 @@ class PostgresDbWriter < PostgresWriter
           next
         end
         if row[index].is_a?(Mysql::Time)
-          row[index] = row[index].to_s 
+          row[index] = row[index].to_s.gsub('0000-00-00 00:00', '1970-01-01 00:00') 
           next
         end
         
@@ -459,7 +459,7 @@ class PostgresDbWriter < PostgresWriter
           if column_type(column) == "bytea"
             row[index] = PGconn.quote(row[index])
           else
-            row[index] = row[index].gsub(/\\/, '\\\\\\').gsub(/\n/,'\n').gsub(/\t/,'\t').gsub(/\r/,'\r') 
+            row[index] = row[index].gsub(/\\/, '\\\\\\').gsub(/\n/,'\n').gsub(/\t/,'\t').gsub(/\r/,'\r').gsub(/\0/, '')
           end
         end
       end