From 4f5acaa2da218dc02742f7c490cd6a63eeb0879a Mon Sep 17 00:00:00 2001 From: halida Date: Sat, 28 Apr 2012 21:47:41 +0800 Subject: [PATCH 1/2] fix bug when use gem mysql2 --- lib/rails-backup-migrate.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rails-backup-migrate.rb b/lib/rails-backup-migrate.rb index b9774e5..2018d3c 100644 --- a/lib/rails-backup-migrate.rb +++ b/lib/rails-backup-migrate.rb @@ -114,8 +114,8 @@ def save_db_to_yml # into YAML on their own at all, let alone in a way that would be compatible with other databases records.map! do |record| record.inject({}) do |memo, (k,v)| - memo[k] = case v - when Mysql::Time + memo[k] = case v.class.name + when "Mysql::Time" datetime_from_mysql_time v else v From 64a5d21c48daa660df3aa602e62de914c25286bb Mon Sep 17 00:00:00 2001 From: halida Date: Sat, 28 Apr 2012 22:31:12 +0800 Subject: [PATCH 2/2] quote table column name with ` --- lib/rails-backup-migrate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rails-backup-migrate.rb b/lib/rails-backup-migrate.rb index 2018d3c..45d72ce 100644 --- a/lib/rails-backup-migrate.rb +++ b/lib/rails-backup-migrate.rb @@ -144,7 +144,7 @@ def restore_db_from_yml puts "Loading #{tbl}..." if VERBOSE YAML.load_file("#{tbl}.yml").each do |fixture| - ActiveRecord::Base.connection.execute "INSERT INTO #{tbl} (#{fixture.keys.join(",")}) VALUES (#{fixture.values.collect { |value| ActiveRecord::Base.connection.quote(value) }.join(",")})", 'Fixture Insert' + ActiveRecord::Base.connection.execute "INSERT INTO #{tbl} (#{fixture.keys.map{|k| "`#{k}`"}.join(",")}) VALUES (#{fixture.values.collect { |value| ActiveRecord::Base.connection.quote(value) }.join(",")})", 'Fixture Insert' end end end