aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorKevin Mook <kevin@kevinmook.com>2013-10-21 13:30:05 -0400
committerKevin Mook <kevin@kevinmook.com>2013-10-21 13:30:05 -0400
commita733e00b10e5f17a7fc70e55e9b1949a5e1128be (patch)
tree27e59ba2c4840ae470ff3fac9141e4476af2664a /activerecord
parent19639c7184bf40054dcedbbfe00eff164abf133f (diff)
downloadrails-a733e00b10e5f17a7fc70e55e9b1949a5e1128be.tar.gz
rails-a733e00b10e5f17a7fc70e55e9b1949a5e1128be.tar.bz2
rails-a733e00b10e5f17a7fc70e55e9b1949a5e1128be.zip
Fix loading a sql structure file on postgres when the file's path has whitespace in it
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md5
-rw-r--r--activerecord/lib/active_record/tasks/postgresql_database_tasks.rb2
-rw-r--r--activerecord/test/cases/tasks/postgresql_rake_test.rb7
3 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 76b89fa0d1..97a42ca95b 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Fix a bug where rake db:structure:load crashed when the path contained
+ spaces.
+
+ *Kevin Mook*
+
* `ActiveRecord::QueryMethods#unscope` unscopes negative equality
Allows you to call `#unscope` on a relation with negative equality
diff --git a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
index 4413330fab..3d02ee07d0 100644
--- a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
+++ b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
@@ -59,7 +59,7 @@ module ActiveRecord
def structure_load(filename)
set_psql_env
- Kernel.system("psql -q -f #{filename} #{configuration['database']}")
+ Kernel.system("psql -q -f #{Shellwords.escape(filename)} #{configuration['database']}")
end
private
diff --git a/activerecord/test/cases/tasks/postgresql_rake_test.rb b/activerecord/test/cases/tasks/postgresql_rake_test.rb
index f31896bc7f..90dac6399d 100644
--- a/activerecord/test/cases/tasks/postgresql_rake_test.rb
+++ b/activerecord/test/cases/tasks/postgresql_rake_test.rb
@@ -231,6 +231,13 @@ module ActiveRecord
ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename)
end
+
+ def test_structure_load_accepts_path_with_spaces
+ filename = "awesome file.sql"
+ Kernel.expects(:system).with("psql -q -f awesome\\ file.sql my-app-db")
+
+ ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename)
+ end
end
end