Permalink
Browse files

Fix loading a sql structure file on postgres when the file's path has…

… whitespace in it
  • Loading branch information...
1 parent 19639c7 commit a733e00b10e5f17a7fc70e55e9b1949a5e1128be @kevinmook kevinmook committed Oct 21, 2013
@@ -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
@@ -59,7 +59,7 @@ def structure_dump(filename)
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
@@ -231,6 +231,13 @@ def test_structure_load
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

0 comments on commit a733e00

Please sign in to comment.