Commit 3df5253cc387c97f11e818e3a85fd10b0d17710c
1 parent
d2b882fa
Exists in
master
and in
4 other branches
Adds DB-sensitive tablename escape for backup task.
Uses ActiveRecord::Base.connection.quote_table_name. Fixes issue 2437.
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
lib/tasks/gitlab/backup.rake
@@ -178,8 +178,9 @@ namespace :gitlab do | @@ -178,8 +178,9 @@ namespace :gitlab do | ||
178 | ActiveRecord::Base.connection.tables.each do |tbl| | 178 | ActiveRecord::Base.connection.tables.each do |tbl| |
179 | print " * #{tbl.yellow} ... " | 179 | print " * #{tbl.yellow} ... " |
180 | count = 1 | 180 | count = 1 |
181 | + safe_tablename = ActiveRecord::Base.connection.quote_table_name(tbl) | ||
181 | File.open(File.join(backup_path_db, tbl + ".yml"), "w+") do |file| | 182 | File.open(File.join(backup_path_db, tbl + ".yml"), "w+") do |file| |
182 | - ActiveRecord::Base.connection.select_all("SELECT * FROM `#{tbl}`").each do |line| | 183 | + ActiveRecord::Base.connection.select_all("SELECT * FROM #{safe_tablename}").each do |line| |
183 | line.delete_if{|k,v| v.blank?} | 184 | line.delete_if{|k,v| v.blank?} |
184 | output = {tbl + '_' + count.to_s => line} | 185 | output = {tbl + '_' + count.to_s => line} |
185 | file << output.to_yaml.gsub(/^---\n/,'') + "\n" | 186 | file << output.to_yaml.gsub(/^---\n/,'') + "\n" |