Commit 3df5253cc387c97f11e818e3a85fd10b0d17710c

Authored by Chris Lawlor
1 parent d2b882fa

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 178 ActiveRecord::Base.connection.tables.each do |tbl|
179 179 print " * #{tbl.yellow} ... "
180 180 count = 1
  181 + safe_tablename = ActiveRecord::Base.connection.quote_table_name(tbl)
181 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 184 line.delete_if{|k,v| v.blank?}
184 185 output = {tbl + '_' + count.to_s => line}
185 186 file << output.to_yaml.gsub(/^---\n/,'') + "\n"
... ...