8000 Handle missing database by steveh · Pull Request #140 · TalentBox/sequel-rails · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Handle missing database #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file 10000
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/sequel_rails/storage/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def _drop
with_pgpassword do
commands = ['dropdb']
add_connection_settings commands
add_flag commands, '--if-exists'
commands << database
safe_exec commands
end
Expand Down Expand Up @@ -64,6 +65,9 @@ def close_connections
# command. Seems to be only way to ensure *all* test connections
# are closed
nil
rescue Sequel::DatabaseConnectionError
# Will raise an error if the database doesn't exist.
nil
end

def encoding
Expand Down Expand Up @@ -104,9 +108,9 @@ def with_pgpassword
end

def add_connection_settings(commands)
add_option commands, '--username', username
add_option commands, '--host', host
add_option commands, '--port', port.to_s
add_option commands, '--username', username unless username.blank?
add_option commands, '--host', host unless host.blank?
add_option commands, '--port', port.to_s unless port.to_s.blank? || port.to_s == "0"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/sequel_rails/storage/postgres_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
describe '#_drop' do
it 'uses the dropdb command' do
expect(subject).to receive(:`).with(
"dropdb --username\\=#{username} --host\\=#{host} --port\\=#{port} #{database}"
"dropdb --username\\=#{username} --host\\=#{host} --port\\=#{port} --if-exists #{database}"
)
subject._drop
end
Expand Down
0