mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix loading a sql structure file on postgres when the file's path has whitespace in it
This commit is contained in:
parent
19639c7184
commit
a733e00b10
3 changed files with 13 additions and 1 deletions
|
@ -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 @@ 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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue