rails/rails — pull request #12567 by kevinmook (2013-10-16 20:36:27+00:00)
Title: Fix loading a sql structure file on postgres when the file's path has whitespace in it

This pull request fixes a bug where loading a postgres structure.sql file that has whitespaces in the filename, fails.

Note: I tried to write a unit test that failed without this code, but was unable to get the test to fail. I tried to model my test after the DatabaseTasksStructureLoadTest in activerecord/test/cases/tasks/database_tasks_test.rb, but it appears that test doesn't actually invoke PostgreSQLDatabaseTasks' structure_load method. This might be due to ActiveRecord::Tasks::PostgreSQLDatabaseTasks being stubbed out?

I'm happy to include a test if someone can help me figure out how to properly test it, otherwise this pull request passes all tests and I have verified it does indeed solve the bug.

If one cares to reproduce the bug directly, simply make a postgres project in a directory with spaces in the path (~/code/some project with spaces/) and run "RAILS_ENV=test rake db:test:prepare". Without this pull request, the "db:test:prepare" rake task will fail with an error similar to "psql: FATAL: role "with" does not exist"